煎蛋屏蔽特定用户

按用户名屏蔽特定用户。

// ==UserScript==
// @name         煎蛋屏蔽特定用户
// @namespace    jandan.net
// @description  按用户名屏蔽特定用户。
// @match       https://jandan.net/treehole*
// @match       https://jandan.net/top*
// @match       https://jandan.net/duan*
// @match       https://jandan.net/pic*
// @match       https://jandan.net/api/top*
// @require     https://scriptcat.org/lib/637/1.4.5/ajaxHooker.js#sha256=EGhGTDeet8zLCPnx8+72H15QYRfpTX4MbhyJ4lJZmyg=
// @grant       none
// @version     1.0
// @author      JuanWoo
// @license     MIT
// ==/UserScript==

/* globals ajaxHooker,$ */

const blockUsers = [""]; // 要屏蔽的用户名,格式:["a","b","c"]

const commentNodes = document.querySelectorAll("div[class^=comment-row]");
let author = "";
commentNodes.forEach((v) => {
    author = v.querySelector('span[class^=author-]').textContent;
    if (blockUsers.includes(author)) {
        v.remove();
    }
});

ajaxHooker.hook(request => {
    request.response = response => {
        if (response.finalUrl.indexOf('/api/top/')>0) {
            let res = JSON.parse(response.response).data;
            for (var i = 0; i < res.length; i++){
                if(blockUsers.includes(res[i].author)){
                    res.splice(i, 1);
                    i--;
                }
            }
            let modifiedResponse = JSON.parse(response.response);
            modifiedResponse.data = res;

            response.responseText = new Promise(resolve => {
                setTimeout(() => {
                    resolve(JSON.stringify(modifiedResponse));
                }, 50);
            });
        }
    };
});

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址