V2EX 11小时前
[分享创造] 看我干爆 v 站的加密货币
index_new5.html
../../../zaker_core/zaker_tpl_static/wap/tpl_guoji1.html

 

本文介绍了一款Tampermonkey脚本,用于在V2EX网站上屏蔽包含特定关键词的帖子,如“币”或“sol”,通过移除或隐藏标题实现。

这段时间加密货币在 v 站可真是有够烦人的,我就是来划水的,受不了了,干翻算了,vibe code 了一段 tampermonkey script ,宁愿误伤 1000 也要干爆敌军 100 ,各位随便用

// ==UserScript==// @name         V2EX 关键词屏蔽(强制隐藏或移除)// @namespace    http://tampermonkey.net/// @version      0.4// @description  强制屏蔽标题中包含 “币”、或 “sol” 的帖子 —— 可选移除或 !important 隐藏。带日志辅助调试。忽略大小写。 。// @author       YourName// @match        https://www.v2ex.com/*// @grant        none// ==/UserScript==(function() {    'use strict';    const keywords = ['币', 'sol'];    const re = new RegExp(keywords.map(k => k.replace(/[-\/\\^$*+?.()|[\]{}]/g,'\\$&')).join('|'), 'i');    function filterPosts() {        document.querySelectorAll('div').forEach((tr, idx) => {            const link = tr.querySelector('.item_title a.topic-link');            if (!link) {                console.log(`[过滤][${idx}] 无标题链接`);                return;            }            const text = link.textContent.trim();            const matched = re.test(text);            console.log(`[过滤][${idx}] "${text}" => 匹配: ${matched}`);            if (matched) {                // —— 方案 A: 直接从 DOM 中移除 ——//                 tr.remove();//                 console.log(`[过滤][${idx}] 已移除`);                // —— 方案 B: 强制添加 !important 隐藏 ——                tr.style.setProperty('display', 'none', 'important');                console.log(`[过滤][${idx}] 已隐藏(!important )`);            }        });    }    // 首次过滤    filterPosts();    // 监听异步加载    new MutationObserver(muts => {        muts.forEach(m => {            if (m.addedNodes.length) {                filterPosts();            }        });    }).observe(document.body, { childList: true, subtree: true });})();

Fish AI Reader

Fish AI Reader

AI辅助创作,多种专业模板,深度分析,高质量内容生成。从观点提取到深度思考,FishAI为您提供全方位的创作支持。新版本引入自定义参数,让您的创作更加个性化和精准。

FishAI

FishAI

鱼阅,AI 时代的下一个智能信息助手,助你摆脱信息焦虑

联系邮箱 441953276@qq.com

相关标签

V2EX 加密货币 关键词屏蔽 Tampermonkey 脚本
相关文章