Why is $ undefined when I try to use jQuery in GreaseMonkey?
I'm totally new to GreaseMonkey, but I'm trying to make a little script. // ==UserScript== // @require http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js // ==/UserScript== (function() { $ = unsafeWindow.jQuery; alert($); // this gives 'undefined' }()); Why does the alert give undefined and how to fix this? UPDATE I tried this: (function(){ //boilerplate greasemonkey to wait until jQuery is defined... function GM_wait() { alert('ok'); if(typeof unsafeWindow.jQuery == 'undefined') window.setTimeout(GM_wait,100); else unsafeWindow.jQuery(function() { letsJQuery(unsafeWindow.jQuery); });