commonlib

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

Από την 02/10/2023. Δείτε την τελευταία έκδοση.

Αυτός ο κώδικας δεν πρέπει να εγκατασταθεί άμεσα. Είναι μια βιβλιοθήκη για άλλους κώδικες που περιλαμβάνεται μέσω της οδηγίας meta // @require https://update.sleazyfork.org/scripts/476583/1259165/commonlib.js

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         commonlib
// @namespace    websiteEnhancement
// @author   jimmly
// @version      2023.9.25
// @description  增加页面顶部底部按钮和一键下种按钮
// @create         2023-9-21
// @include        *
// @grant         GM_getValue
// @grant         GM_setValue
// @grant         GM.getValue
// @grant         GM.setValue
// @require       https://openuserjs.org/src/libs/sizzle/GM_config.min.js
// @license MIT
// @run-at document-idle
// ==/UserScript==

function withJQuery(callback, safe) {
    if (typeof jQuery == "undefined") {
        let script = document.createElement("script")
        script.type = "text/javascript"
        script.src = "https://code.jquery.com/jquery-3.6.1.min.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 创建超链接,不会被拦截 
function createSuperLabel(url, id, download) {
    if (!id)
        id = url;
    // 防止反复添加
    if (!document.getElementById(id) && !localStorage[id]) {
        let tmpLink = document.createElement("a");
        localStorage[id] = true
        if (download)
            tmpLink.download = download;
        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) {
    if (a.replace(/(\r\n|\n|\r|\t| )/gm, "").toLowerCase().indexOf(b.replace(/(\r\n|\n|\r|\t| )/gm, "").toLowerCase()) > -1) {
        return true;
    }
    return false;
}