📜 ⬆️ ⬇️

jQuery & Greasemonkey

I often use usersrcipt in greasemonkey, I also love jQuery very much - I use it in all projects.
Found a small snippet for using jQuery in scripts for Greasemonkey

// jQuery
var GM_JQ = document .createElement( 'script' );
GM_JQ.src = 'http://jquery.com/src/jquery-latest.js' ;
GM_JQ.type = 'text/javascript' ;
document .getElementsByTagName( 'head' )[0].appendChild(GM_JQ);

// jQuery
function GM_wait() {
if ( typeof unsafeWindow.jQuery == 'undefined' ) { window.setTimeout(GM_wait,100); }
else { $ = unsafeWindow.jQuery; letsJQuery(); }
}
GM_wait();

// userscript
function letsJQuery() {
alert($); // $("#something")
}


* This source code was highlighted with Source Code Highlighter .


Original: jQuery & Greasemonkey

Alternatively, you can use jQuery with GoogleCode - jqueryjs.googlecode.com/files/jquery-1.2.6.pack.js

')

Source: https://habr.com/ru/post/48835/


All Articles