jQueryとGreasemonkey

私は頻繁にグリースモンキーでusersrciptを使用します。jQueryも非常に気に入っています。すべてのプロジェクトで使用しています。
GreasemonkeyのスクリプトでjQueryを使用するための小さなスニペットを見つけました

// 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 .


オリジナル: jQueryとGreasemonkey

または、jQueryをGoogleCodeで使用できます-jqueryjs.googlecode.com/files/jquery-1.2.6.pack.js


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


All Articles