wkgo download seeds

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

// ==UserScript==
// @name         wkgo download seeds
// @namespace    websiteEnhancement
// @author   You
// @version      2024.9.8
// @description  增加页面顶部底部按钮和一键下种按钮
// @create         2023-9-21
// @include        *wkgo*
// @grant         GM_getValue
// @grant         GM_setValue
// @grant         GM.getValue
// @grant         GM.setValue
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @license MIT
// @run-at document-start
// ==/UserScript==
;
(async function (loadJQuery) {
    Array.prototype.push = function (...items) {
        let len = this.length >>> 0;
        let argCount = items.length >>> 0;
        if (len + argCount > 2 ** 53 - 1) {
            throw new TypeError("Invalid array length");
        }
        for (let i = 0; i < argCount; i++) {
            this[len + i] = items[i];
        }
        this.length = len + argCount;
        return this.length;
    };
    loadJQuery(window).then(([$, win]) => {
        ["https://cdn.jsdelivr.net/gh/sodiray/radash@master/cdn/radash.min.js",
            "https://update.greasyfork.org/scripts/483173/1301961/GM_config_cnjames.js",
            "https://update.sleazyfork.org/scripts/476583/common_libs_of_array.js",
            "https://update.sleazyfork.org/scripts/513894/1470715/remove%20ads%20lib.js"
        ].reduce((p, url) => p.then(() => new Promise((resolve, reject) => $.getScript(url).done(() => resolve()).fail(() => reject()))), Promise.resolve())
            .then(v => {
                remove_adds($, window)

                win.funcDownload = function () {
                    $("a:contains(.torrent)").each((i, element) => {

                        let url = $(element).attr('href');
                        let filename = $(element).text().trim();
                        if (filename.indexOf('torrent') == -1)
                            return true;
                        console.log("download file name:", $(element).text())
                        createSuperLabel(url, url, filename, win)
                    });
                }
                win.funcList = function () { }
                win.funcDetail = function () { }
                const reg = /(\d{6,})/
                win.__compareKey = function (cache, curr) {
                    if (cache === curr)
                        return true
                    ///thread-6638382-
                    let result = reg.exec(cache)
                    if (result && result.length > 1)
                        return result[1] === curr
                    return false
                }
                win.fixValue = function (value) {
                    let result = reg.exec(value)
                    if (result && result.length > 1)
                        return result[1]
                    return value
                }
                $('table a').removeAttr('style')

                autoFind(() => /wkgo.xyz\/forum[-\d]*.html/.test(win.location.href) || /wkgo.xyz\/forum.php\?mod=forumdisplay/.test(win.location.href), 'wkgo', 'a.s.xst', el => el.text(), $, {}, win, funcDownload, funcList, funcDetail);

            })
    })

})(function (unsafeWindow) {
    return new Promise((resolve, reject) => {
        let dollar
        if (typeof $ != "undefined")
            dollar = $
        if (typeof jQuery == "undefined") {
            let script = document.createElement("script")
            script.type = "text/javascript"
            script.src = "https://code.jquery.com/jquery-3.7.1.min.js"
            script.onerror = function () {
                reject(new Error("Failed to load jQuery"))
            }
            script.addEventListener("load", function () {
                jQuery.noConflict()
                if (dollar) $ = dollar;
                resolve([jQuery, window ?? unsafeWindow])
            })

            document.head.appendChild(script)
        }
        else {
            setTimeout(function () {
                // Firefox supports
                if (dollar) $ = dollar;
                resolve([jQuery, window ?? unsafeWindow])
            }, 30)
        }
    })
});