block let user

屏蔽 lowendtalk 指定用户的帖子,支持点击用户名屏蔽

当前为 2025-03-25 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         block let user
// @namespace    yournamespace
// @version      1.1
// @description  屏蔽 lowendtalk 指定用户的帖子,支持点击用户名屏蔽
// @author       ayasetan
// @match        https://lowendtalk.com/categories/offers*
// @grant        GM_getValue
// @grant        GM_setValue
// @grant        GM_deleteValue
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    // 从存储中获取屏蔽用户列表,如果没有则使用默认空数组
    let blockedUsers = JSON.parse(GM_getValue('blockedUsers', '[]'));

    // 主功能:屏蔽帖子
    function hideBlockedUsers() {
        const items = document.querySelectorAll('.ItemDiscussion');  // 获取所有帖子的元素

        items.forEach(item => {
            const authorLink = item.querySelector('.DiscussionAuthor a');
            if (!authorLink) return;

            const username = authorLink.textContent.trim();

            if (blockedUsers.includes(username)) {
                item.style.display = 'none';  // 隐藏被屏蔽用户的帖子
            } else {
                // 添加点击事件监听器
                authorLink.addEventListener('click', function(e) {
                    e.preventDefault();
                    e.stopPropagation();

                    if (confirm(`是否要屏蔽用户 ${username} 的所有帖子?`)) {
                        if (!blockedUsers.includes(username)) {
                            blockedUsers.push(username);
                            GM_setValue('blockedUsers', JSON.stringify(blockedUsers));
                            alert(`已屏蔽用户 ${username}`);
                            hideBlockedUsers(); // 重新执行屏蔽
                        }
                    }
                });
            }
        });
    }

    // 初始执行
    hideBlockedUsers();


})();