S1 User Blocker

Block certain user's content

目前為 2021-01-12 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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();