Greasy Fork

妖火:我不屑与你这样的妖油为伍

屏蔽妖火网特定用户的帖子和回复

// ==UserScript==
// @name         妖火:我不屑与你这样的妖油为伍
// @namespace    http://tampermonkey.net/
// @version      2.0
// @description  屏蔽妖火网特定用户的帖子和回复
// @author       yaohuogg
// @match        *://yaohuo.me/bbs*
// @match        *://www.yaohuo.me/bbs*
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    // 设置需要屏蔽的用户ID和用户名
    const blockedUserIds = ['999', '999']; //纯数字,识别回复靠用户ID更精准,这是唯一值
    const blockedUsernames = ['用户名1', '用户名2']; //用户名用来遍历主题,因为主题界面没有用户ID,所有只能这样

    function hideReplies() {
        document.querySelectorAll('.reline.list-reply').forEach(reply => {
            const userIdElement = reply.querySelector('.renickid');
            const usernameElement = reply.querySelector('.renick a');

            if (userIdElement && blockedUserIds.includes(userIdElement.textContent.trim())) {
                reply.style.display = 'none';
                return;
            }

            if (usernameElement && blockedUsernames.some(name => usernameElement.textContent.trim().includes(name))) {
                reply.style.display = 'none';
                return;
            }
        });
    }

    function hideTopics() {
        document.querySelectorAll('.listdata.line1, .listdata.line2').forEach(topic => {
            const usernameElement = topic.querySelector('.louzhunicheng');

            if (usernameElement && blockedUsernames.some(name => usernameElement.textContent.trim().includes(name))) {
                topic.style.display = 'none';
            }
        });
    }

    hideReplies();
    hideTopics();

    const observer = new MutationObserver(() => {
        hideReplies();
        hideTopics();
    });

    observer.observe(document.body, { childList: true, subtree: true });
})();