SCBOY论坛增强黑名单

过滤页面中黑名单用户的主题和回复

目前为 2022-02-20 提交的版本。查看 最新版本

// ==UserScript==
// @name         SCBOY论坛增强黑名单
// @namespace    *://www.scboy.cc/
// @version      1.0
// @description  过滤页面中黑名单用户的主题和回复
// @author       RustyHare
// @match        *://*.scboy.cc/*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        GM_getValue
// @grant        GM_setValue
// @license      MIT
// ==/UserScript==

function refresh()
{
    var blackList=[];
    $.ajax({
        url:"https://www.scboy.cc/?my-blacklist.htm",
        type:"get",
        dataType:"html",
        success:function(data,status){
            var searchPattern="user-[0-9]"
            var index=Array.from(data.matchAll(searchPattern));
            for(var i=0;i<index.length;i++){
                let head=-1,tail=-1;
                for(var s=0;s<30;s++){
                    if(data[index[i].index+s]==">" && head==-1){
                        head=s;
                    }
                    if(data[index[i].index+s]=="<" && tail==-1){
                        tail=s;
                        break;
                    }
                }
                blackList.push(data.slice(index[i].index+head+1,index[i].index+tail));
                //看到这段代码的人可千万别杀了我做了兔肉放在淘宝店——我的代码力仅限于此(不一定,但是实在是太懒了)
            }
            GM_setValue("blackList",blackList)
        },
        error:function(){
        }
    })
}

function forumCleaning(){
    var sps=$("span.username.hidden-sm");
    for(var i=0;i<sps.length;i++){
        if(window.blackList.indexOf(sps[i].innerText)!=-1){
            sps[i].parentElement.parentElement.parentElement.parentElement.remove();
            //四层父节点awa好像都是
        }
    }
}
window.threadCleaning=function(){
    var ats=$("a.text-muted.font-weight-bold");
    for(var i=0;i<ats.length;i++){
        if(window.blackList.indexOf(ats[i].innerText)!=-1){
            if(ats[i].parentElement.parentElement.parentElement.nodeName=="DD"){
                ats[i].parentElement.parentElement.parentElement.remove();
            }
            else if(ats[i].parentElement.parentElement.parentElement.parentElement.parentElement.nodeName=="LI"){
                ats[i].parentElement.parentElement.parentElement.parentElement.parentElement.remove();
            }
        }
    }
}

function main()
{
    window.blackList=GM_getValue("blackList")
    var date=new Date();
    if(GM_getValue("needsRefresh")==1){
        refresh();
        GM_setValue("needsRefresh",0)
    }
    if(date.toDateString()!=GM_getValue("lastrun")){
        refresh();
        GM_setValue("lastrun",date.toDateString());
    }
    if(window.location.href=="https://www.scboy.cc/?my-blacklist.htm"){
        GM_setValue("needsRefresh",1)
    }

    if(window.location.href.search("forum")>-1){
        forumCleaning()
    }
    if(window.location.href.search("thread")>-1){
        window.threadCleaning()
        $("i").click(function(){setTimeout(window.threadCleaning(),1000)})
    }
    console.log(GM_getValue("blackList"))
}

main()

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址