Greasy Fork

Greasy Fork is available in English.

屏蔽虎扑网红表情图

try to take over the world!

当前为 2023-02-11 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         屏蔽虎扑网红表情图
// @namespace    http://tampermonkey.net/
// @version      0.2
// @license       MIT
// @description  try to take over the world!
// @author       You
// @match        https://bbs.hupu.com/*.html
// @icon         https://www.google.com/s2/favicons?sz=64&domain=hupu.com
// @grant        GM_registerMenuCommand
// @grant        GM_setValue
// @grant        GM_getValue
// @grant        GM_deleteValue
// @require      https://cdn.staticfile.org/jquery/3.4.1/jquery.min.js

// ==/UserScript==

let imageMap = new Map();
imageMap.set("img1", "26124659_20220502102437");
imageMap.set("img2", "37338109_20210220183736");
let blacklist = [];

function updateBlackList() {
    let checkIds = GM_getValue("checked_ids", new Set());
    blacklist = [];
    for (let id of checkIds) {
        let hpid = imageMap.get(id);
        if (hpid) {
            blacklist.push(hpid);
        }
    }
    console.log("update blacklist");
    console.log(blacklist);
}

(function () {
    'use strict';
    updateBlackList();
    GM_registerMenuCommand("打开设置", setting, "h");

    $(document).ready(function () {
        $('.image-wrapper').each(function (i, e) {
            //console.log(e);
            $(e).bind("DOMNodeInserted", function () {
                //console.log("change");
                $(e).find("img").each(function (i2, e2) {
                    let src = $(e2).attr("src");
                    for (let black of blacklist) {
                        if (src.includes(black)) {
                            console.log(src);
                            $(e).remove()
                            break;
                        }
                    }
                })
            })
        })
    });


    // Your code here...
})();

function selectCheckbox(e) {
    let checked = e.checked;
    let id = $(e).attr("id");
    let checkIds = new Set(GM_getValue("checked_ids", []));
    if (checked) {
        checkIds.add(id);
    } else {
        checkIds.delete(id);
    }
    GM_setValue("checked_ids", Array.from(checkIds));
    updateBlackList();
}

function setting() {
    // 初始化打开开关
    $("body").append("<div style='right: 10px;top: 100px;background: #f8f8f8;color:#ffffff;overflow: hidden;z-index: 9999;position: fixed;padding:5px;text-align:center;width: 175px;max-height: 600px;border-radius: 4px;border-style:solid;\n" +
        " border-width:1px; border-color:black;'>\n" +
        "    <div style=\"margin-bottom: 20px\"><span style=\"color:black;\">选择要屏蔽的图</span></div>\n" +
        "    <table border=\"0\" style=\"width: 100%;\">\n" +
        "        <tr>\n" +
        "            <td style=\"width: 200px;\"><input type=\"checkbox\" id=\"img1\" class=\"hp-cbx\"/></td>\n" +
        "            <td><img src=\"https://i.328888.xyz/2023/02/11/RqAOA.jpeg\" height=\"100px\"/>\n" +
        "        </tr>\n" +
        "        <tr>\n" +
        "            <HR align=center width=300 color=#987cb9 SIZE=1/>\n" +
        "        </tr>\n" +
        "        <tr>\n" +
        "            <td style=\"width: 200px;\"><input type=\"checkbox\" id=\"img2\" class=\"hp-cbx\"/></td>\n" +
        "            <td><img src=\"https://i.328888.xyz/2023/02/11/RqDeo.jpeg\" height=\"100px\"/>\n" +
        "        </tr>\n" +
        "    </table>\n" +
        "</div>");
    let checkIds = new Set(GM_getValue("checked_ids", []));
    $(".hp-cbx").each(function (i, e) {
        $(e).click(function () {
            selectCheckbox(this)
        })
        let id = $(e).attr("id");
        if (checkIds.has(id)) {
            $(e).prop("checked", true);
        }
    })
}