Pardus Shadowban - Forum

Hide posts, quotes, threads from blocked users, and optionally remove Off Topic forum.

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

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

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

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

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

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

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Pardus Shadowban - Forum
// @license MIT
// @namespace    https://pardus.at/
// @version      1.01
// @description  Hide posts, quotes, threads from blocked users, and optionally remove Off Topic forum.
// @author       Solarix
// @match        https://forum.pardus.at/*
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    // === SETTINGS ===
    const hideOffTopicForum = false;
    const blockedUsers = ['Jinx','Artie','Rabid Duck','Hired Gun','InsertNameHere']; // case-insensitive usernames

    const isBlocked = (name) =>
        blockedUsers.some(blocked => name.trim().toLowerCase() === blocked.toLowerCase());

    const containsQuoteFromBlockedUser = (html) =>
        blockedUsers.some(blocked =>
            html.includes(`${blocked} @`) || html.includes(`>${blocked} wrote:`)
        );

    // === 1. Hide posts by blocked users or quotes from them ===
    if (window.location.href.includes('showtopic=')) {
        document.querySelectorAll('table').forEach((table) => {
            try {
                const nameCell = table.querySelector('span.normalname > a');
                const postDiv = table.querySelector('div.postcolor');

                if ((nameCell && isBlocked(nameCell.textContent)) ||
                    (postDiv && containsQuoteFromBlockedUser(postDiv.innerHTML))) {
                    table.style.display = 'none';
                }
            } catch (e) {
                console.warn('Post hiding error:', e);
            }
        });
    }

    // === 2. Hide thread rows started by blocked users ===
    if (window.location.href.includes('act=SF') || window.location.href.includes('showforum=')) {
        document.querySelectorAll('table > tbody > tr').forEach(row => {
            const starterCell = row.querySelectorAll('td')[3];
            const starterLink = starterCell?.querySelector('a');
            if (starterLink && isBlocked(starterLink.textContent)) {
                row.style.display = 'none';
            }
        });
    }

    // === 3. Hide Off Topic forum from index ===
    if (hideOffTopicForum) {
        const queryString = window.location.search;
        const urlParams = new URLSearchParams(queryString);
        const isSearchScreen = urlParams.has('act') && urlParams.get('act') === 'Search';

        const topicLinkEls = document.querySelectorAll('.row4 a');
        for (let loop = 0; loop < topicLinkEls.length; loop++) {
            if (topicLinkEls[loop].href.includes('showforum=6')) {
                let nodeToHide = topicLinkEls[loop].parentNode.parentNode;
                if (!isSearchScreen) nodeToHide = nodeToHide.parentNode;
                nodeToHide.style.display = 'none';
                if (!isSearchScreen) break;
            }
        }
    }
})();