这段时间加密货币在 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 });
})();
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.