Why it doesn't work in Chrome:
To run this on Firefox, you need to install the Greasemonkey add-on. Likewise, to run this in Chrome, you need to install the Tampermonkey extension.
Chrome has limited, native support for userscripts, but it doesn't support @require
and a bunch of other goodies. Save yourself some hassle and use Tampermonkey.
Avoid conflicts: Requiring jQuery is good, but unfortunately, due to changes in Greasemonkey (and now Tampermonkey), it can cause conflicts with some websites if the sandbox is switched off. To avoid potential conflicts, always use an explicit @grant
to control the sandbox.
Change the end of your metadata block to:
// @grant GM_addStyle
// ==/UserScript==
/*- The @grant directive is needed to work around a design change
introduced in GM 1.0. It restores the sandbox.
*/
About the alt
attribute:
Remember that the alt
attribute is only supposed to be displayed if the image doesn't load for some reason. Is the image loading?
Perhaps you want the title
attribute, since it's often used for tooltips.
Change this code snippet:
if (retrievedText === "") {
link.href = "http://grooveshark.com";
grooveyImage.alt = "Grooveshark";
} else {
link.href = "http://grooveshark.com/#!/search?q=" + retrievedText;
grooveyImage.alt = "Search for '" + retrievedText + "' on Grooveshark";
}
to this:
if (retrievedText === "") {
link.href = "http://grooveshark.com";
grooveyImage.alt = "Grooveshark icon supposed to be here";
grooveyImage.title = "Grooveshark";
} else {
link.href = "http://grooveshark.com/#!/search?q=" + retrievedText;
grooveyImage.alt = "Grooveshark icon supposed to be here";
grooveyImage.title = "Search for '" + retrievedText + "' on Grooveshark";
}
Or just set the image's alt
once to "Grooveshark icon", and only switch the title
.