common_libs_of_array

增加页面顶部底部按钮和一键下种按钮

Stan na 11-02-2024. Zobacz najnowsza wersja.

Ten skrypt nie powinien być instalowany bezpośrednio. Jest to biblioteka dla innych skyptów do włączenia dyrektywą meta // @require https://update.sleazyfork.org/scripts/476583/1326145/common_libs_of_array.js

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         common_libs_of_array
// @namespace    websiteEnhancement
// @author   jimmly
// @version      2024.1.25
// @description  增加页面顶部底部按钮和一键下种按钮
// @create         2023-9-21
// @include        *
// @grant         GM_getValue
// @grant         GM_setValue
// @grant         GM.getValue
// @grant         GM.setValue
// @license MIT
// @run-at document-idle
// ==/UserScript==

async function withJQuery(callback, safe, unsafeWindow) {
    if (typeof jQuery == "undefined") {
        let script = document.createElement("script")
        script.type = "text/javascript"
        script.src = "https://code.jquery.com/jquery-3.7.1.js"
        if (safe) {
            let cb = document.createElement("script")
            cb.type = "text/javascript"
            cb.textContent = "jQuery.noConflict();(" + callback.toString() + ")(jQuery, window);"
            script.addEventListener("load", function () {
                document.head.appendChild(cb)
            })
        } else {
            let dollar = undefined
            if (typeof $ != "undefined") dollar = $
            script.addEventListener("load", function () {
                jQuery.noConflict()
                $ = dollar
                callback(jQuery, window)
            })
        }
        document.head.appendChild(script)
    } else {
        setTimeout(function () {
            //Firefox supports
            callback(jQuery, typeof unsafeWindow === "undefined" ? window : unsafeWindow)
        }, 30)
    }
}
//addStyle 
function addStyle(css) {
    var s = document.createElement('style');
    s.appendChild(document.createTextNode(css));
    document.getElementsByTagName('head')[0].appendChild(s);
}
//createSuperLabel 创建超链接,不会被拦截 
async function createSuperLabel(url, id, downloadName, win) {
    win = win ?? window;
    if (downloadName) {
        if (win.closeTimer) {
            win.clearTimeout(win.closeTimer)
        }
        win.closeTimer = setTimeout(function () {
            win.open("about:blank", "_self").close();
        }, 500)
    }

    if (!id)
        id = url;
    // 防止反复添加
    if (!document.getElementById(id) && !localStorage[id]) {
        let tmpLink = document.createElement("a");
        localStorage[id] = true
        if (downloadName)
            tmpLink.download = downloadName;
        tmpLink.setAttribute("href", url);
        tmpLink.setAttribute("target", "_blank");
        tmpLink.setAttribute("id", id);
        document.body.appendChild(tmpLink);
        tmpLink.click();
        return true
    }
    return false;
}

function unique(arr) {
    let obj = {};
    return arr.filter(function (item, index, arr) {
        return obj.hasOwnProperty(typeof item + item) ? false : (obj[typeof item + item] = true)
    })
}

///ignore \r \t \n space and caseinsitive
function a_Contains_b(a, b) {
    a = a.replace(/(\r\n|\n|\r|\t| )/gm, "").toLowerCase();
    b = b.replace(/(\r\n|\n|\r|\t| )/gm, "").toLowerCase();
    if (!!a && !!b && a.indexOf(b) > -1) {
        return true;
    }

    return false;
}

async function autoFind(funcIsRun, cmgId, selector, funcText, $, elBindOpen, unsafeWindow) {
    new Promise(resovle => resovle(new GM_config({
        id: `GM_config_${cmgId}`,
        title: 'javdb Configurable Options Script',
        fields: {
            'asdf': {
                'label': 'Search keys',
                'type': 'textarea',
                'rows': 30,
                'cols': 50,
                'default': '调J; 阴环;18;19;20;gvh;sm;tki;一字马;一线天;乳环;固定;圈养;奴隶;奴隸;实录;性奴;拘;拘束;拷問;捆綁;捆绑;攣;无毛;束;束縛;束缚;母G;母狗;無毛;痙;白虎;緊縛;萝莉;調教;调教;軟派;軟體;软体;縛;身動;绑;;肛塞;尾巴;极品;奴宠; 淫媚;極品;尤物;凌辱;屈辱;少女'
            },
            'isRunInNewTabs': {
                'options': ['Auto Run In New Tab', 'Not Run In New Tab'],
                'label': 'Auto Run In New Tab?',
                'type': 'radio',
                'default': 'Auto Run In New Tab'
            },
        },
        'events':
        {
            'open': function () {
                let vals = unique(this.get('asdf').split(/;|;|,|,/gi)).join(';')
                this.set('asdf', vals)
            },
            'save': function () {
                let vals = unique(this.get('asdf').split(/;|;|,|,/gi)).join(';')
                this.set('asdf', vals)
            }
        }
    })))
        .then(gmc => {
            setTimeout(() => $(elBindOpen).click(() => gmc.open()), 500);
            return gmc;
        })
        .then(gmc => {
            (unsafeWindow || window).gmc = gmc;
            if (!funcIsRun(gmc)) throw Error(`no run due to contion failed`)
            return gmc
        })
        .then(gmc => {
            return { gmc, conf: gmc.get('asdf') }
        }

        )
        .then(({ gmc, conf }) => {
            console.log('config value of keys', conf)
            return ({ gmc, 'keys': conf.split(/;|;|,|,/i) })
        })
        .then(({ gmc, keys }) => {
            $(selector).each((i, element) => {
                let el = $(element)
                $.each(keys, (inex, key) => {
                    if (a_Contains_b(funcText(el), key)) {
                        createSuperLabel(el.prop('href'), el.prop('href')).then(res => console.log(key, res, el.prop('href')))
                        return false;
                    }
                })

            });
            return { gmc, keys }
        })
        .catch(e => console.log('error', e))


};