您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Clean up Google Search spam links
当前为
// ==UserScript== // @name Google Spam Filter // @name:vi Dọn dẹp link rác Google Search // @namespace http://tampermonkey.net/ // @version 1.4 // @description Clean up Google Search spam links // @description:vi Dọn dẹp link rác trên Google Search // @author Yuusei // @icon https://www.google.com/favicon.ico // @match https://www.google.com/search* // @grant none // @license GPL-3.0-only // ==/UserScript== (function() { 'use strict'; // options domains const spamDomains = new Set([ '.fr', '.pl', ]); // Cache for URLs checked const urlCache = new Map(); const CACHE_EXPIRY = 12 * 60 * 60; // 12 hours // Check if the URL is spam function isSpamUrl(url) { const now = Date.now(); // Check cache first if (urlCache.has(url)) { const {result, timestamp} = urlCache.get(url); if (now - timestamp < CACHE_EXPIRY) { return result; } urlCache.delete(url); } const urlLower = url.toLowerCase(); let isSpam = false; // Check spam domains for (const domain of spamDomains) { if (urlLower.includes(domain)) { isSpam = true; break; } } // Save result to cache with timestamp urlCache.set(url, { result: isSpam, timestamp: now }); return isSpam; } // Debounce function to prevent calling too many times function debounce(func, wait) { let timeout; return function executedFunction(...args) { const later = () => { clearTimeout(timeout); func(...args); }; clearTimeout(timeout); timeout = setTimeout(later, wait); }; } // Filter and hide spam results const filterSpamResults = debounce(() => { // Select all search results const searchResults = document.querySelectorAll('#search .g, #rso .g'); let spamCount = 0; let totalResults = 0; searchResults.forEach(result => { totalResults++; // Get link and cite const link = result.querySelector('a'); const cite = result.querySelector('cite'); if (link && ( isSpamUrl(link.href) || (cite && isSpamUrl(cite.textContent)) )) { // Hide spam results completely result.style.display = 'none'; spamCount++; } }); // Show notification about the number of spam links filtered if (spamCount > 0) { console.log(`Filtered ${spamCount}/${totalResults} spam results (${Math.round(spamCount/totalResults*100)}%)`); } }, 250); // Run when the page loads window.addEventListener('DOMContentLoaded', filterSpamResults); // Observe content changes (Google dynamic loading) const observer = new MutationObserver((mutations) => { if (mutations.some(mutation => mutation.addedNodes.length > 0)) { filterSpamResults(); } }); observer.observe(document.documentElement, { childList: true, subtree: true }); })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址