block let user

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

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

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==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();


})();