Re-visiting the swap all coats Grease Monkey script

Previously I wrote a Grease Monkey script that swapped all the coats back to the v3 default coats for all of the breeds in the game, and it’s on v11 now, I think.  At the same time I was working on other scripts to swap only a single breed archetypes default coat, but that is problematic in that if you use that method you create an unnecessary amount of overhead if you don’t want to swap all of the coats, but only a few as they all run when the page loads because they all run on the same pages.  To prevent this from happening and clean the mess up I created a variant of the swap all script and called it the swap select script.  What this does is set up a set of variables that are either set to 1 or 0.  If the variable is set to 1, the script will swap that breed archetype’s coat otherwise it won’t.

Due to certain restrictions on Grease Monkey and JavaScript the variables that determine which breeds to swap and which to not swap have to be manually edited by the user.  The default for the variables sets them to 1, and anytime the script gets updated, any changes to the variables will be reset from what the user set them to.  To prevent the script from being updated automatically, you can go to the Add-ons manager in Firefox >> User Scripts tab, and go to the script titled “Howrse_Swap_Select_v4_v3_Default_Coats”, right-click and select the “Automatically check for updates” option at the bottom if there is a check-mark next to it.

I mentioned the swap is based on breed archetypes not specific breeds.  A breed archetype is how Owlient has categorized each breed to determine what coat directory to use.  For example, the Arabian Horse breed archetype is arabe.  The two breeds that use this archetype are the Arabian Horse and the Shagya Arabian breeds.  Another example would be the iberique archetype which is used by the Lusitano, Canadian, Peruvian Paso, Purebred Spanish Horse and Barb breeds.  It’s why some breeds look the same.  When they updated the coats to v4 they gave Tennessee Walkers their own directory, so they no longer use the trotteur archetype.

In the script each breed archetype variable is followed by a comment that specifies what breeds fall under that archetype.  If the breed whose coat you want to change back to the v3 coats falls under a specific breed archetype, the associated variable needs to be a 1.  If the variable associated with a breed archetype is 0 then all breeds that use that coat will not be swapped.  The default for the script is to swap all coat files.  If you don’t want all of the coats to be swapped, the script should be edited so that the breeds you don’t want swapped are set to 0.

The following is the only part the user needs to modify if they don’t want all of the coats for all of the breeds to be swapped.  Changing something elsewhere is likely to break the script.

//	Breed coat archetypes
	akhalTeke = 1;	//	Akhal-Teke
	americain = 1;	//	Appaloosa, Argentinean Criollo, Paint Horse, Quarter Horse
	arabe = 1;	//	Arabian Horse, Shagya Arabian
	curly = 1;	//	Curly
	fjord = 1;	//	Fjord
	frison = 1;	//	Friesian
	highlandPony = 1;	//	Highland Pony
	iberique = 1;	//	Barb, Canadian horse, Lusitano, Peruvian Paso, Purebred Spanish Horse
	knabstrup = 1;	//	Knabstrupper
	marwari = 1;	//	Marwari
	mustang = 1;	//	Mustang
	nokota = 1;	//	Nokota
	poneyLeger = 1;	//	Connemara
	poneyLourd = 1;	//	Chincoteague Pony
	poneyPrimitif = 1;	//	Newfoundland Pony
	poneySport = 1;	//	Australian Pony, Welsh
	primitif = 1;	//	Brumby, Icelandic horse
	shetland = 1;	//	Shetland
	sportLeger = 1;	//	Quarter Pony, Trakehner
	sportMassif = 1;	//	Hanoverian, Holsteiner, Irish Hunter, KWPN, Russian Don Horse
	thoroughbred = 1;	//	Thoroughbred
	tinker = 1;	//	Gypsy Vanner
	trotteur = 1;	//	Hackney, Morgan, Standardbred
	tenWalker = 1;	//	Tennessee Walker

If the script gets updated, the values in the section above in the script will be set back to 1.

MonkeyGuts:  Howrse Default Coat Swap Select

Greasy Fork:  Howrse Default Coat Swap Select

Since I only use the script on Firefox I cannot guarantee it will work on any browser other than Firefox, but it might.

Advertisements

Default coat swap on Howrse

In April I created a Greasemonkey script to change the default coat for the Friesian breed to the v3 coat because I liked the v3 coat better.  At the time I thought the logic needed to change all of the default coats to the v3 default coats would take a lot more coding than it actually did, mostly because of how I initially wrote the script for the Friesian breed and how I wrote the script for this one.  Because the devs at Owlient kept the file names for the coat files the same and only changed the directory organization while leaving the v3 coats on the server it was a relatively simple task to create the code that would re-create the links so the page could display the v3 default coat for the breed and coat.

One of the problems I had with the Friesian script was it was unable to change the horse icons on pages like the breeding farm page.  The reason for this is due to the fact that the breeding farm is populated after the page is loaded and all GM scripts without delays are already run meaning there isn’t anything for the script to actually change at the time it runs.  To deal with this minor issue I put the part that swaps the horse icons into a function I can call using setTimeout to call the function after the breeding farm has been populated.  With the way the breeding farm page works when you switch to a different breeding farm, the page isn’t actually reloaded, the breeding farm grid is populated with horses from the selected breeding farm which means the script won’t be run again and the icons wouldn’t be switched.  This was fixed by using setInterval to have the function run every few seconds which shouldn’t cause any noticeable lag issues.  The rest of the pages that utilize horse icons won’t fire a setInterval call to the function, and will only run once when the page is initially loaded.

If you use the script you’ll notice that some of the default coats don’t swap and that is/should be some of the icons for foals.  The reason is that some aren’t tied to a specific breed but their species like “poney”.  Because of this it was easier to leave those with the v4 icons, but that should only be for the places the icons are displayed and not the horse’s page.  This is partly due to the differences in how the two parts of the script create the new image tag source.  The function that deals with icons disassembles the image tags source link while the part that deals with the default coat on the horse’s page ignores the style element that displays the horse and searches the page itself for clues to the horse’s breed and coat and uses those to put together the link to the v3 coat.

The pages that the script runs on are player presentations, EC presentations, horse pages both public and private, the player’s breeding farm page, horse description pages, safe haven, heaven and the horse sales.

Links to the script:

Userscripts:  Howrse Default Coat SwapAll

Greasy Fork:  Howrse Default Coat SwapAll

Since I only use the script on Firefox I cannot guarantee it will work on any browser other than Firefox, but it might.

 

Getting Howrse to use the Friesian V.3 coats

With Owlient updating the default coats as they start working on implementing visible tack I’ve found that I’m not a fan of one of the new coats, the Friesian v4 coat.  Since it’s unlikely the coat will be changed anytime soon, I’ve decided to create a GreaseMonkey script to fix this little problem for me.  What the script does is determine first if the horse is actually a Friesian, and if it has a default coat.  If it does, it adds an IMG tag with the V3 default coat for it’s species and age.  Because Owlient hasn’t deleted the v3 coats yet the script re-uses the links from the International version of Howrse.

This can be done with any of the breeds on Howrse; however, it gets really complicated with the breeds that have more than one coat as each coat has several variants (4 adult variants, and 2 foal variants).  The Friesian coats are the easiest due to only needing only 6 lines of code to swap over to one of the 6 variants.  Other breeds, like the Gypsy Vanner, which has 17 different coats would require 102 lines of code to deal with all of the the variations.

In the future I might, or might not, include changing the v4 icons to the v3 icons, but that could increase the time needed to finish running the script and might prove to be unnecessary.  It can, however, be done.  After some work on that part, it seems the breeding farms are loaded after all the scripts are run such that the icons in the breeding farms are immune to being changed at the moment.

The script is hosted on userscripts.org here and requires the GreaseMonkey add-on for Firefox: Friesian V.4 >> V.3 Coat Swap