// ==UserScript== // @name 搜索引擎官网净化器-增强版 // @namespace http://tampermonkey.net/ // @version 1.4 // @description 精准识别官网/智能屏蔽虚假结果(支持百度/谷歌/必应) // @author AI助手优化版 // @license MIT // @match *://www.baidu.com/* // @match *://www.google.com/* // @match *://www.bing.com/* // @grant GM_addStyle // @grant GM.getValue // @grant GM.setValue // @grant GM.registerMenuCommand // @require https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js // @noframes // @downloadURL none // ==/UserScript== (function() { 'use strict'; // 增强视觉样式 GM_addStyle(` .official-site-mark { background: linear-gradient(135deg, #2196F3 0%, #1976D2 100%) !important; border-radius: 12px; padding: 2px 8px; color: white; font-size: 12px; margin-left: 8px; position: relative; top: -1px; animation: popIn 0.3s ease; } @keyframes popIn { 0% { transform: scale(0); } 90% { transform: scale(1.1); } 100% { transform: scale(1); } } .dangerous-result { position: relative; opacity: 0.3; transition: opacity 0.3s; } .dangerous-result::after { content: "⚠️ 危险结果已模糊处理"; position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); color: #d32f2f; font-weight: bold; background: rgba(255,255,255,0.9); padding: 8px 16px; border-radius: 4px; box-shadow: 0 2px 8px rgba(0,0,0,0.1); } `); // 动态配置中心 const SearchEngineConfig = { 'www.baidu.com': { selectors: { container: '#content_left', results: '.c-container, .result-op, [mu]', title: 'h3.t, h3 a', officialMark: [ '.c-icon-certified', // 百度官方认证图标 { type: 'text', pattern: /官网$/ }, { type: 'attribute', selector: '[data-landmark="official"]' } ], dangerMark: [ '.c-tips-icon-warning', // 百度风险提示图标 { type: 'text', pattern: /(彩票|网赚|代购|刷单)/ } ] }, dangerDomains: [ /\.(xyz|top|loan|tk|ml)/i, /(wangzhan|seo|baidu\.zhuanlan)/i ], officialDomains: [ /\.(gov|edu)\.cn$/, /(baidu|alibaba|tencent|jd)\.com$/ ] }, 'www.google.com': { selectors: { container: '#search', results: '.g:not(.ULSxyf)', title: 'h3, [role="heading"]', officialMark: [ '.VuuXrf', // Google认证标记 { type: 'text', pattern: / - Official Site$/i }, { type: 'attribute', selector: '[aria-label="Verified"]' } ], dangerMark: [ '.iDjcJe[aria-label="Warning"]', // Google危险提示 { type: 'text', pattern: /(casino|porn|pharmacy)/i } ] }, dangerDomains: [ /\.(xyz|top|bid|loan)/i, /(freevpn|cheapdrugs|fake)/i ], officialDomains: [ /\.(gov|edu|mil)$/, /(google|microsoft|apple)\.com$/ ] }, 'www.bing.com': { selectors: { container: '#b_results', results: '.b_algo', title: 'h2 > a', officialMark: [ '[aria-label="官方站点"]', { type: 'text', pattern: /Official Site/i } ], dangerMark: [ '.b_attribution > .b_dotext[href*="danger"]', { type: 'text', pattern: /(赌博|诈骗)/i } ] }, dangerDomains: [ /\.(stream|gq|cf)/i, /(poker|bitcoin)/i ], officialDomains: [ /\.(gov|edu)/i, /(microsoft|bing)\.com$/i ] } }; class SearchGuard { constructor() { this.engine = location.hostname; this.config = SearchEngineConfig[this.engine]; if (!this.config) return; this.initState(); this.enhanceUI(); this.setupObservers(); } async initState() { this.enabled = await GM.getValue('searchGuardEnabled', true); this.debugMode = await GM.getValue('debugMode', false); this.log('初始化完成'); } log(...args) { if (this.debugMode) console.log('[SearchGuard]', ...args); } enhanceUI() { // 添加调试面板 const panel = document.createElement('div'); panel.innerHTML = `