Any jQuery,页面注入jQuery,方便控制台调试代码

write once run anywhere,注入jQuery,方便控制台调试代码

目前为 2020-09-16 提交的版本。查看 最新版本

// ==UserScript==
// @name         Any jQuery,页面注入jQuery,方便控制台调试代码
// @namespace    http://bbs.91wc.net/any-jquery.htm
// @version      0.1
// @description  write once run anywhere,注入jQuery,方便控制台调试代码
// @author       Wilson
// @match        http*://*/*
// @require      https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js
// @grant        unsafeWindow
// ==/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('<script id="_g_script">var _g=window, _w=_g, _jq=(typeof jQuery === "undefined") ? null : jQuery;</script>');
if(_g._jq === null){
    $.getScript("https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js", function(){
        //初始化_jq变量
        _g._jq = _g.jQuery;
        _g._jq.version=_g._jq.fn.jquery;
        //call main
        main();
    });
}

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址