// ==UserScript== // @name 屏蔽虎扑网红表情图 // @namespace http://tampermonkey.net/ // @version 0.3 // @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== //用户添加自己要屏蔽的,放到initBlacklist中 // 比如这张图,https://i3.hoopchina.com.cn/hupuapp/bbs/0/0/thread_0_20220731165903_s_25909_o_w_810_h_595_79234.jpg?x-oss-process=image/resize,w_225/qulity,Q_60, // 取thread_后面的两串数字,0_20220731165903,加到initBlacklist,变成 // let initBlacklist = ["0_20220731165903"]; let initBlacklist = []; let imageMap = new Map(); imageMap.set("img1", "26124659_20220502102437"); imageMap.set("img2", "37338109_20210220183736"); let blacklist = new Set(); function updateBlackList() { let checkIds = GM_getValue("checked_ids", new Set()); blacklist = new Set(initBlacklist); for (let id of checkIds) { let hpid = imageMap.get(id); if (hpid) { blacklist.add(hpid); } } } (function () { 'use strict'; updateBlackList(); GM_registerMenuCommand("打开设置", setting, "h"); $(document).ready(function () { $('.post-reply-list').each(function (i, e) { //console.log(e); removeImg(e); $(e).bind("DOMNodeInserted", function () { removeImg(e); }) }) }); })(); //e是.image-wrapper function removeImg(e) { $(e).find(".thread-img").each(function (i2, e2) { let src = $(e2).attr("src"); for (let black of blacklist) { if (src.includes(black)) { $(e2).parents(".image-wrapper").first().remove(); break; } } }); } 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("
"); 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); } }) }