// ==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 // @downloadURL none // ==/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("
\n" + "
选择要屏蔽的图
\n" + " \n" + " \n" + " \n" + " \n" + " \n" + "
\n" + " \n" + " \n" + " \n" + " \n" + "
\n" + "
\n" + "
\n" + "
"); 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); } }) }