S1 User Blocker

Block certain user's content

目前为 2021-01-11 提交的版本。查看 最新版本

// ==UserScript==
// @name         S1 User Blocker
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  Block certain user's content
// @author       冰箱研会长
// @match        https://bbs.saraba1st.com/2b/*
// ==/UserScript==

var User_Blocked = new Array(`要屏蔽的用户1`,`这里用的是键盘左上角的backtick符号`,`逗号分隔主体`);
var Correspond_Section = new Array(`和用户1对应的板块名称`,`PC数码`,`动漫论坛PC数码`);

function getElementByXpath(path) {
    return document.evaluate(path, document, null, 
                             XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
}

function S1_Reply_Blocker(){
    var PostLists = getElementByXpath(`/html/body/div[8]/div[4]/div[2]`);
    if(PostLists){
        var PostCounter = 1;
        while(getElementByXpath(`/html/body/div[8]/div[4]/div[2]/div[${PostCounter}]`)){
            var PostAuthor = getElementByXpath(`/html/body/div[8]/div[4]/div[2]/div[${PostCounter}]/table/tbody/tr[1]/td[1]/div/div[1]/div/a`);
            if(PostAuthor){
                if( User_Blocked.includes(PostAuthor.innerText) ){
                    var PostSection = getElementByXpath(`/html/body/div[8]/div[2]/div/a[4]`).innerText;
                    if(Correspond_Section[User_Blocked.indexOf(PostAuthor.innerText)] == ""){
                        getElementByXpath(`/html/body/div[8]/div[4]/div[2]/div[${PostCounter}]`).style.display = `none`;
                    }else if(Correspond_Section[User_Blocked.indexOf(PostAuthor.innerText)].includes(PostSection)){
                        getElementByXpath(`/html/body/div[8]/div[4]/div[2]/div[${PostCounter}]`).style.display = `none`;
                    }
                }
            }
            PostCounter = PostCounter + 1;
        }
    }
}

function S1_Sure_Blocker(){
    var SureList = getElementByXpath('/html/body/div[8]/div[4]/div/div/div[5]/div[2]/form/table');
    if(SureList){
        var SureCounter = 1;
        while(getElementByXpath(`/html/body/div[8]/div[4]/div/div/div[5]/div[2]/form/table/tbody[${SureCounter}]`)){
            var SureAuthor = getElementByXpath(`/html/body/div[8]/div[4]/div/div/div[5]/div[2]/form/table/tbody[${SureCounter}]/tr/td[2]/cite/a`);
            if(SureAuthor){
                if(User_Blocked.includes(SureAuthor.innerText)){
                    var SureSection = getElementByXpath(`/html/body/div[8]/div[2]/div/a[4]`).innerText;
                    if(Correspond_Section[User_Blocked.indexOf(SureAuthor.innerText)] == ""){
                        getElementByXpath(`/html/body/div[8]/div[4]/div/div/div[5]/div[2]/form/table/tbody[${SureCounter}]`).style.display = `none`;
                    }else if(Correspond_Section[User_Blocked.indexOf(SureAuthor.innerText)].includes(SureSection)){
                        getElementByXpath(`/html/body/div[8]/div[4]/div/div/div[5]/div[2]/form/table/tbody[${SureCounter}]`).style.display = `none`;
                    }
                }
            }
            SureCounter = SureCounter + 1;
        }
    }
}

S1_Reply_Blocker();
S1_Sure_Blocker();

QingJ © 2025

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