I am writing a simple GreaseMonkey script that has a jQuery plugin called hoverIntent embedded in it. (I am embedding it rather than hosting it because it's a very small plugin.)
My problem: after the plugin attaches its event handler to a DOM object, the event triggers an error message that says: "jQuery is not defined."
Is it a scope issue? Here is my entire script:
if(unsafeWindow.console){
var GM_log = unsafeWindow.console.log;
}
(function($){
//HoverIntent
$.fn.hoverIntent=function(f,g){...};
//Removed the plugin code. You can see it in the link at the bottom
//of the post.
//DOM is ready
//Fetch all the rows with arrows
$('.arrow')
.each(function(){
$(this).hoverIntent(mouseOver,mouseOut);
});
//mouseOver
function mouseOver(){
//THIS IS WHERE THE ERROR HAPPENS
$(this).click();
}
//mouseOut
function mouseOut(){ //nothing here.
}
})(unsafeWindow.jQuery);
It works fine when I copy paste it, removing all GM specific tags, and run it from my console. And this is the plugin I am embedding.