Skip to content

Instantly share code, notes, and snippets.

@ankushg
Forked from TApicella/mount_fade_out.user.js
Last active February 7, 2016 17:30
Show Gist options
  • Save ankushg/f02329aa41421f1b1e41 to your computer and use it in GitHub Desktop.
Save ankushg/f02329aa41421f1b1e41 to your computer and use it in GitHub Desktop.
Mount fade out for Habitica (formerly HabitRPG)
// ==UserScript==
// Sources: http://stackoverflow.com/questions/2246901/how-can-i-use-jquery-in-greasemonkey-scripts-in-google-chrome
// @name Mount Fader
// @namespace habiticaMountFader
// @include https://habitica.com/*
// @author Tom Apicella (jquery by Erik Vergobbi Vold & Tyler G. Hicks-Wright)
// @description This userscript fades out your mount when you mouse over your hero
// ==/UserScript==
// a function that loads jQuery and calls a callback function when jQuery has finished loading
function addJQuery(callback) {
var script = document.createElement("script");
script.setAttribute("src", "//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js");
script.addEventListener('load', function() {
var script = document.createElement("script");
script.textContent = "window.jQ=jQuery.noConflict(true);(" + callback.toString() + ")();";
document.body.appendChild(script);
}, false);
document.body.appendChild(script);
}
// the guts of this userscript
function main() {
// Note, jQ replaces $ to avoid conflicts.
jQ(".herobox").hover(function(){
jQ(this).find("[class*=Mount_Head],[class*=Mount_Body]").delay(400).fadeTo("slow", 0.3);
}, function(){
jQ(this).find("[class*=Mount_Head],[class*=Mount_Body]").fadeTo("fast", 1.0);
});
}
// load jQuery and execute the main function
addJQuery(main);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment