Ncore limit

Allows real time filtering of the listed torrents by specifying the minimum amount for the given column

当前为 2020-02-29 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Ncore limit
// @description  Allows real time filtering of the listed torrents by specifying the minimum amount for the given column
// @namespace    http://tampermonkey.net/
// @version      0.3
// @match        https://ncore.cc/torrents.php*
// @grant        none
// ==/UserScript==
(function() {
    "use strict";

    const descriptors = {
        s: ".box_s2 > .torrent",
        l: ".box_l2 > .torrent",
        dl: ".box_d2"
    };

    function addInputBoxes(header) {
        const dlContainer = header.querySelectorAll(".box_alap")[4].querySelectorAll(".alcim > tbody > tr > td")[1];
        const sContainer = header.querySelectorAll(".box_alap")[5].querySelectorAll(".alcim > tbody > tr > td")[1];
        const lContainer = header.querySelectorAll(".box_alap")[6].querySelectorAll(".alcim > tbody > tr > td")[1];

        dlContainer.innerHTML = "";
        sContainer.innerHTML = "";
        lContainer.innerHTML = "";

        const dl_input = createInput("dl_input", (text) => {
            s_input.value = ''
            l_input.value = ''

            dl_input.value = new Array(text.length + 1).join('+')
            hideBelowTreshold("dl", text.length)
        })
        const s_input = createInput("s_input", (text) => {
            l_input.value = ''
            dl_input.value = ''
            hideBelowTreshold("s", parseInt(text))
        })
        const l_input = createInput("l_input", (text) => {
            s_input.value = ''
            dl_input.value = ''
            hideBelowTreshold("l", parseInt(text))
        })

        dlContainer.appendChild(dl_input);
        sContainer.appendChild(s_input);
        lContainer.appendChild(l_input);
    }

    function createInput(className, callback) {
        const child = document.createElement("input");
        child.classList.add(className);
        child.classList.add("keresesMezo");
        child.style.width = "30px";
        child.style.padding = "0px";

        child.addEventListener('input', function() {
            callback(child.value)
        });

        return child
    }

    function hideBelowTreshold(descriptor, treshold) {
        let localTreshold = 0
        if (treshold) {
            localTreshold = treshold
        }

        document.querySelectorAll(".box_torrent").forEach(node => {
            node.style.display = "block"
            let parameterNode = node.querySelector(
                `.box_nagy > ${descriptors[descriptor]}`
            );
            if (!parameterNode) {
                parameterNode = node.querySelector(
                    `.box_nagy2 > ${descriptors[descriptor]}`
                );
            }

            if (parameterNode) {
                if (descriptor === "dl") {
                    if (parameterNode.innerHTML.length < treshold) {
                        node.style.display = "none";
                    }

                    return;
                }

                const count = parseInt(parameterNode.innerHTML);
                if (count < treshold) {
                    node.style.display = "none";
                }
            }
        });
    }

    const header = document.querySelector(".lista_all > .box_alcimek_all").cloneNode(true)
    header.querySelector(".box_tipus").innerHTML = ""
    header.querySelector(".box_nev").innerHTML = ""
    header.querySelector(".box_feltoltve").innerHTML = ""
    header.querySelector(".box_meret").innerHTML = ""
    header.querySelector(".box_feltolto").innerHTML = ""
    header.style.background = "transparent"

    const torrentek = document.querySelector(".lista_all > .box_torrent_all")
    document.querySelector(".lista_all").insertBefore(header, torrentek)

    addInputBoxes(header)

})();