// ==UserScript==
// @name Any jQuery,页面注入jQuery,方便控制台调试代码
// @namespace http://bbs.91wc.net/any-jquery.htm
// @version 0.2.1
// @description write once run anywhere,注入jQuery,方便控制台调试代码
// @author Wilson
// @match http*://*/*
// @require https://cdn.jsdelivr.net/npm/jquery@3.2.1/dist/jquery.min.js
// @resource jquery https://cdn.jsdelivr.net/npm/jquery@3.2.1/dist/jquery.min.js
// @grant unsafeWindow
// @grant GM_getResourceText
// @downloadURL none
// ==/UserScript==
//main
function main() {
//Your codes here
//你也可以像这样向页面中写全局变量或函数
//_g.a="test a";
//_g.b = function(){
// console.log("test b");
//}
}
//注入jQuery和全局变量_g
this.$ = this.jQuery = jQuery.noConflict(true);
$("body").append('');
var init = function(){
//初始化_jq变量
_g._jq = _g.jQuery;
_g._jq.version=_g._jq.fn.jquery;
//脚本信息
_g.myinfo = {};
_g.myinfo.name=GM_info.script.name;
_g.myinfo.ver=GM_info.script.version;
_g.myinfo.jqurl=GM_info.script.resources[0].url;
//call main
main();
};
if(_g._jq === null){
setTimeout(function(){
//动态设置jQuery
var jq_code = GM_getResourceText('jquery');
$("body").append('');
//初始化_jq变量
init();
}, 0);
} else {
//初始化_jq变量
init();
}