S1 User Blocker

Block certain user's content

当前为 2021-01-12 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         S1 User Blocker
// @namespace    http://tampermonkey.net/
// @version      0.4
// @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 S1_Reply_Blocker(){
    var PostLists = getElementByXpath(`//div[@id='postlist']`);
    if(PostLists){
             var PostCounter = 1;
            while(getElementByXpath(`//div[@id='postlist']/div[${PostCounter}]`)){
                var PostAuthor = getElementByXpath(`//div[@id='postlist']/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(`//div[@id='postlist']/div[${PostCounter}]`).style.display = `none`;
                        }else if(Correspond_Section[User_Blocked.indexOf(PostAuthor.innerText)].includes(PostSection)){
                            getElementByXpath(`//div[@id='postlist']/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');
    var SureList = getElementByXpath(`//*[@id="threadlisttableid"]`);
    if(SureList){
        var SureCounter = 1;
        //while(getElementByXpath(`/html/body/div[8]/div[4]/div/div/div[5]/div[2]/form/table/tbody[${SureCounter}]`)){
          while(getElementByXpath(`//*[@id="threadlisttableid"]/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`);
            var SureAuthor = getElementByXpath(`//*[@id="threadlisttableid"]/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(`//*[@id="threadlisttableid"]/tbody[${SureCounter}]`).style.display = `none`;
                    }else if(Correspond_Section[User_Blocked.indexOf(SureAuthor.innerText)].includes(SureSection)){
                        getElementByXpath(`//*[@id="threadlisttableid"]/tbody[${SureCounter}]`).style.display = `none`;
                    }
                }
            }
            SureCounter = SureCounter + 1;
        }
    }
}

S1_Reply_Blocker();
S1_Sure_Blocker();