mteam根据评论筛选

mteam 根据 评论数高亮颜色, 筛选,隐藏0评论的种子,骑兵

// ==UserScript==
// @name         mteam根据评论筛选
// @namespace    http://tampermonkey.net/
// @version      2021.5.1
// @description  mteam  根据 评论数高亮颜色, 筛选,隐藏0评论的种子,骑兵
// @author       Sean
// @match        https://kp.m-team.cc/*
// @grant        GM_log
// @run-at document-end
// @supportURL https://greasyfork.org/en/scripts/
// ==/UserScript==


(function () {
    try {
        console.log("start 馒头筛选");

        let totalHide = 0;
        let totalHideCensored = 0;

        var table = document.querySelector("#form_torrent > table");

        var len = table.rows.length; //101

        function hideOrShow(n) {

            for (let i = len - 1; i > 1; i--) {
                var searchText = table.rows[i].cells[2].innerText;//取得table行,列的值

                let number = parseInt(searchText);
                if (number > 0) {

                } else {
                    totalHide++;
                    table.rows[i].style.display = n;//隐藏行操作
                }

                var cat = table.rows[i].cells[0].getElementsByTagName("a")[0].href.toString();//取得table行,列的值
                var censored = cat.indexOf("cat=431") > 0 || cat.indexOf("cat=424") > 0 || cat.indexOf("cat=410") > 0 || cat.indexOf("cat=437") > 0;

                if (censored == true) {
                    totalHideCensored++;
                    table.rows[i].style.display = n;//隐藏行操作
                }

            }
        }

        hideOrShow('none');


        let bodyElement = document.querySelector("body")
        let divall = document.createElement("div");
        divall.style = "padding-left: 10%;\n" +
            "padding-right: 30%;\n" +
            "font-size: x-large;\n" +
            "background: #409EFF;\n" +
            "margin-left: 5%;\n" +
            "margin-right: 5%;\n" +
            "width: 920px;" +
            "color: #fff";
        divall.textContent = "成功隐藏了:" + totalHide + "个0评论的种子," + totalHideCensored + "个骑兵的种子"

        let buttonElement = document.createElement("button");
        buttonElement.style = "color: #409eff;\n" +
            "background: #ecf5ff;\n" +
            "border-color: #b3d8ff;" +
            "display: inline-block;\n" +
            "line-height: 1;\n" +
            "white-space: nowrap;\n" +
            "cursor: pointer;" +
            "-webkit-appearance: none;\n" +
            "text-align: center;\n" +
            "box-sizing: border-box;\n" +
            "outline: none;\n" +
            "margin: 8px;\n" +
            "transition: .1s;\n" +
            "font-weight: 300;" +
            "padding: 6px 10px;\n" +
            "    font-size: 14px;\n" +
            "    border-radius: 4px;"
        buttonElement.addEventListener('click', function () {

            if (buttonElement.innerText == "点击显示") {
                hideOrShow('');
                buttonElement.innerText = "点击隐藏";
            } else {
                hideOrShow('none');
                buttonElement.innerText = "点击显示";
            }

        }, false)

        buttonElement.innerText = "点击显示"
        divall.appendChild(buttonElement)
        let tableElement = document.querySelector("body > table.mainouter")
        bodyElement.insertBefore(divall, tableElement)


    } catch (e) {
        GM_log(e)
    }

})();