您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
隐藏 api.weibo.com 中包含指定 span 内容(发言人昵称)的 li 元素(聊天消息)
// ==UserScript== // @name 按发言人屏蔽微博聊天页面中的消息 // @namespace http://tampermonkey.net/ // @version 1.0 // @description 隐藏 api.weibo.com 中包含指定 span 内容(发言人昵称)的 li 元素(聊天消息) // @author 恰老 // @match *://api.weibo.com/* // @grant none // @license MIT // ==/UserScript== (function () { 'use strict'; // 🔧 自定义关键词(支持多个) const keywords = ['第一个人的名字', '第二个人的名字']; // 页面加载后执行 window.addEventListener('load', () => { hideTargetLi(); // 监听后续 DOM 变化,适配动态加载的内容 const observer = new MutationObserver(hideTargetLi); observer.observe(document.body, { childList: true, subtree: true }); }); function hideTargetLi() { const liElements = document.querySelectorAll('li'); liElements.forEach(li => { // 查询 class="name font12" 的 span const targetSpans = li.querySelectorAll('span.name.font12'); for (const span of targetSpans) { const text = span.textContent.trim(); if (keywords.some(keyword => text.includes(keyword))) { li.style.display = 'none'; break; } } }); } })();