NGA User Script Loader

NGA User Script Loader 实现两个功能:1.在页面未加载 jQuery 时加载 jQuery ;2.在点击“加载上一页/下一页”按钮后重新运行用户脚本(需脚本自身配合)。

20.01.2020 itibariyledir. En son verisyonu görün.

Bu script direkt olarak kurulamaz. Başka scriptler için bir kütüphanedir ve meta yönergeleri içerir // @require https://update.greasyfork.org/scripts/39014/766910/NGA%20User%20Script%20Loader.js

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

You will need to install an extension such as Tampermonkey to install this script.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name         NGA User Script Loader
// @namespace    https://greasyfork.org/zh-CN/scripts/39014-nga-user-script-loader
// @version      0.0.4.20200121
// @icon         http://bbs.nga.cn/favicon.ico
// @description  NGA User Script Loader 实现两个功能:1.在页面未加载 jQuery 时加载 jQuery ;2.在点击“加载上一页/下一页”按钮后重新运行用户脚本(需脚本自身配合)。
// @author       AgLandy
// @include      /^https?:\/\/(bbs\.ngacn\.cc|nga\.178\.com|bbs\.nga\.cn)/
// @grant        none
// ==/UserScript==

(function(){

    if(!window.commonui)
        commonui = {};

    setTimeout(function(){

        try{
            if(commonui.userScriptLoader.$)
                return;
        }
        catch(e){
            let btn = 'a[title^="加载"]',
                init = function($){
                    commonui.userScriptLoader = {
                        $: $,
                        userScriptData: {},
                        reload: function(){
                            let usl = commonui.userScriptLoader;
                            if(usl.mo)
                                return;
                            usl.mo = new MutationObserver(function(){
                                $(btn).bind('click.userScriptLoader', usl.reload);
                                $.each(usl.userScriptData, function(k, v){
                                    v();
                                });
                                usl.mo.disconnect();
                                delete usl.mo;
                            });
                            usl.mo.observe($('div#mc')[0], {
                                childList: true,
                                subtree: true,
                            });
                        },
                        lS: (function(s){
                            if(!!s){
                                try{
                                    s.testkey = 'testvalue';
                                    s.removeItem('testkey');
                                    return true;
                                }
                                catch(e){
                                    return false;
                                }
                            }
                            else
                                return false;
                        })(window.localStorage)
                    };
                    $(btn).bind('click.userScriptLoader', commonui.userScriptLoader.reload);
                };
            if(typeof jQuery == 'undefined' && !document.getElementById('ngaUSL')){
                let s = document.createElement('script');
                s.type = 'text/javascript';
                s.src = 'https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js';
                s.id = 'ngaUSL';
                s.onload = s.onreadystatechange = function(){
                    if(!this.readyState || 'loaded' === this.readyState || 'complete' === this.readyState){
                        init(jQuery.noConflict());
                        this.onload = this.onreadystatechange = null;
                    }
                };
                document.head.appendChild(s);
            }
            else
                init(jQuery);
        }

    }, Math.floor(Math.random() * 1000));

})();