S1 User Blocker

Block certain user's content

اعتبارا من 12-01-2021. شاهد أحدث إصدار.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)

// ==UserScript==
// @name         S1 User Blocker
// @namespace    http://tampermonkey.net/
// @version      0.5
// @description  Block certain user's content
// @author       冰箱研会长
// @match        https://bbs.saraba1st.com/2b/*
// @grant GM_getValue
// @grant GM_setValue
// @require http://code.jquery.com/jquery-3.5.1.min.js
// @require https://greasyfork.org/scripts/420061-super-gm-setvalue-and-gm-getvalue-greasyfork-mirror-js/code/Super_GM_setValue_and_GM_getValue_greasyfork_mirrorjs.js?version=890160
// ==/UserScript==


var User_Array = GM_SuperValue.get(`User Blocked`,new Array());
var Section_Array = GM_SuperValue.get(`Section 4 Each`,new Array());


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

function Blockbutton_Appender(HtmlDiv,Block_Target,Block_Section,Counter){
    HtmlDiv.innerHTML = HtmlDiv.innerHTML.concat(`
        <div><button type="button" id="secblock-${Counter}">板块屏蔽</button></div>
        <div><button type="button" id="allblock-${Counter}">全局屏蔽</button></div>`);

    $(`#secblock-${Counter}`).click({bt:Block_Target,bs:Block_Section},function(event){
        console.log(event.data.bt+":"+event.data.bs);
        if(User_Array.includes(event.data.bt)){
            Section_Array[User_Array.indexOf(event.data.bt)] = Section_Array[User_Array.indexOf(event.data.bt)].concat(`${event.data.bs}`);
        }else{
            User_Array.push(event.data.bt);
            Section_Array[User_Array.indexOf(event.data.bt)] = event.data.bs;
        }
        GM_SuperValue.set(`User Blocked`,User_Array);
        GM_SuperValue.set(`Section 4 Each`,Section_Array);
        console.log(User_Array);
        console.log(Section_Array);
    });

    $(`#allblock-${Counter}`).click({bt:Block_Target},function(event){
        console.log(event.data.bt+":")
        if(User_Array.includes(event.data.bt)){
            Section_Array[User_Array.indexOf(event.data.bt)] = ``;
        }else{
            User_Array.push(event.data.bt);
            Section_Array[User_Array.indexOf(event.data.bt)] = ``;
        }
        GM_SuperValue.set(`User Blocked`,User_Array);
        GM_SuperValue.set(`Section 4 Each`,Section_Array);
        console.log(User_Array);
        console.log(Section_Array);
    });
}


function S1_Reply_Blocker(){
    var PostLists = getElementByXpath(`//div[@id='postlist']`);
    if(PostLists){
        var PostSection = getElementByXpath(`/html/body/div[8]/div[2]/div/a[4]`).innerText;
        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`);
            var PostAruthorColumn = getElementByXpath(`//div[@id='postlist']/div[${PostCounter}]/table[1]/tbody[1]/tr[1]/td[1]/div[1]`);
            if(PostAruthorColumn){
                Blockbutton_Appender(PostAruthorColumn,PostAuthor.innerText,PostSection,PostCounter);
            }
            if(PostAuthor){
                if( User_Array.includes(PostAuthor.innerText) ){
                    if(Section_Array[User_Array.indexOf(PostAuthor.innerText)] == ""){
                        getElementByXpath(`//div[@id='postlist']/div[${PostCounter}]`).style.display = `none`;
                    }else if(Section_Array[User_Array.indexOf(PostAuthor.innerText)].includes(PostSection)){
                        getElementByXpath(`//div[@id='postlist']/div[${PostCounter}]`).style.display = `none`;
                    }
                }
            }
            PostCounter = PostCounter + 1;
        }
    }
}

function S1_Sure_Blocker(){
    var SureList = getElementByXpath(`//*[@id="threadlisttableid"]`);
    if(SureList){
        var SureCounter = 1;
        while(getElementByXpath(`//*[@id="threadlisttableid"]/tbody[${SureCounter}]`)){
            var SureAuthor = getElementByXpath(`//*[@id="threadlisttableid"]/tbody[${SureCounter}]/tr/td[2]/cite/a`);
            if(SureAuthor){
                if(User_Array.includes(SureAuthor.innerText)){
                    var SureSection = getElementByXpath(`/html/body/div[8]/div[2]/div/a[4]`).innerText;
                    if(Section_Array[User_Array.indexOf(SureAuthor.innerText)] == ""){
                        getElementByXpath(`//*[@id="threadlisttableid"]/tbody[${SureCounter}]`).style.display = `none`;
                    }else if(Section_Array[User_Array.indexOf(SureAuthor.innerText)].includes(SureSection)){
                        getElementByXpath(`//*[@id="threadlisttableid"]/tbody[${SureCounter}]`).style.display = `none`;
                    }
                }
            }
            SureCounter = SureCounter + 1;
        }
    }
}

S1_Reply_Blocker();
S1_Sure_Blocker();
console.log(User_Array);
console.log(Section_Array);