您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Remove repeating parts of spam messages in chat window
当前为
// ==UserScript== // @name Chat Spam Filter For fishtank.live // @namespace http://tampermonkey.net/ // @version 2.0 // @description Remove repeating parts of spam messages in chat window // @author Blungs // @match https://*.fishtank.live/* // @icon https://www.google.com/s2/favicons?sz=64&domain=fishtank.live // @license MIT // @grant none // ==/UserScript== (function() { 'use strict'; // Function to remove repeated phrases function removeRepeatedText(text) { const words = text.split(' '); const seen = {}; const result = []; words.forEach(word => { const lowerWord = word.toLowerCase(); if (!seen[lowerWord]) { seen[lowerWord] = true; result.push(word); } }); return result.join(' '); } // Function to process and modify chat messages function processChatMessage(messageSpan) { if (messageSpan && messageSpan.tagName === 'SPAN') { const originalText = messageSpan.textContent.trim(); const filteredText = removeRepeatedText(originalText); // Only log if the message has been changed if (filteredText !== originalText) { messageSpan.textContent = filteredText; // Update the text content console.log(`Message changed: "${originalText}" to "${filteredText}"`); } } else { console.warn("Message span is undefined or not a span element."); } } // Function to start observing the chat messages container function startObserving() { const chatMessagesDiv = document.getElementById('chat-messages'); if (chatMessagesDiv) { const observer = new MutationObserver((mutations) => { mutations.forEach((mutation) => { mutation.addedNodes.forEach((node) => { if (node.nodeType === Node.ELEMENT_NODE && node.tagName === 'SPAN') { processChatMessage(node); // Process new chat message } else if (node.nodeType === Node.ELEMENT_NODE) { // Check for spans within added elements const spans = node.querySelectorAll('span'); spans.forEach(span => { processChatMessage(span); }); } }); }); }); observer.observe(chatMessagesDiv, { childList: true, subtree: true }); } else { setTimeout(startObserving, 2000); // Retry every 2 seconds } } // Start the observation process startObserving(); })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址