// ==UserScript== // @name Older-Mature.net 广告清理 (Ad Cleaner) // @namespace https://github.com/local/older-mature-adcleaner // @version 1.1.0 // @description 隐藏右下角 video-slider 广告 (click_vl_*)、trudigo LIVE 直播 (#ajopr)、whitetrafsa LIVE 直播网格、内容区横幅。三层防御:GM_addStyle 主力 + 源头拦截广告脚本/iframe + DOM 清理兜底。 // @author you // @match *://*.older-mature.net/* // @run-at document-start // @grant GM_addStyle // @license MIT // ==/UserScript== (function () { 'use strict'; /* ============================================================ * 配置区 * ============================================================ */ const CFG = { sourceBlock: true, // 源头拦截:阻止广告域名脚本/iframe 加载(最彻底,处理容器 id 不可预测的直播广告) hideLiveAd: true, // trudigo LIVE 直播容器 (#ajopr) hideSlider: true, // 右下角 video-slider 广告 (click_vl_*) hideBanners: true, // 内容区 / 顶部横幅 iframe hidePush: true, // acscdn / adexchangerapid in-page push 推送卡片 debug: false, // 控制台打印清理日志 }; /* ============================================================ * 已知广告域名清单(抓自实际网络请求) * ============================================================ */ const AD_HOSTS = [ 'ads.exoclick.com', 'syndication.exoclick.com', // ExoClick 'a.realsrv.com', 'syndication.realsrv.com', // ExoClick native CDN(注入 whitetrafsa widget) 'live.trudigo.com', 'creative.trudigo.com', // trudigo LIVE 直播 + videoslider 'acscdn.com', 'adscdn.com', // in-page push 'a.pemsrv.com', 's.pemsrv.com', // popunder / venor 'gorillatraffic.xyz', // 内容区横幅 'creative.whitetrafsa.com', 'go.whitetrafsa.com', // LIVE 直播视频网格(2×2 girls widget) 'adexchangerapid.com', // in-page push(右下/顶部) 'trafficstars.com', 'juicyads.com', 'popcash.net',// 常见兜底广告网络 ]; const AD_RE = new RegExp(AD_HOSTS.map(h => h.replace(/[.]/g, '\\.')).join('|'), 'i'); const isAd = (u) => !!(u && typeof u === 'string' && AD_RE.test(u)); const log = (...a) => CFG.debug && console.log('[OM-AdClean]', ...a); /* ============================================================ * 第 1 层:GM_addStyle —— 主力 CSS 隐藏 * ============================================================ */ const CSS = ` /* trudigo LIVE 直播容器 */ #ajopr, div[id^="ajopr"] { display: none !important; } /* 右下角 video-slider:click_vl__content 点击层 + 常见根容器命名 */ div[id^="click_vl_"], div[id*="_vl_"][id$="_content"], div[id^="imoxy"], div[id^="imSlider"], div[class*="videoslider"], div[class*="adMoxy"] { display: none !important; } /* 内容区 / 顶部横幅 iframe(按广告域名匹配)*/ iframe[src*="exoclick"], iframe[src*="realsrv"], iframe[src*="pemsrv"], iframe[src*="trudigo"], iframe[src*="acscdn"], iframe[src*="gorillatraffic"], iframe[src*="whitetrafsa"], iframe[src*="adexchangerapid"], iframe[src*="trafficstars"], iframe[src*="juicyads"], iframe[src*="popcash"], /* 顶部 728 横幅位:仅当里面装了 iframe 时隐藏,避免误伤 */ div[style*="728px"]:has(iframe) { display: none !important; } /* in-page push / ExoClick native widget */ .exo-native-widget, [class^="exo-"], [id^="exo-"], [id^="ac-push"], [class*="inpage-push"], [class*="push-notification"] { display: none !important; } `; const addCSS = () => { if (typeof GM_addStyle === 'function') { GM_addStyle(CSS); } else { const s = document.createElement('style'); s.id = 'om-adcleaner'; s.textContent = CSS; (document.head || document.documentElement).appendChild(s); } }; addCSS(); /* ============================================================ * 第 2 层:源头拦截 —— 阻止广告脚本/iframe 加载 * whitetrafsa 直播网格等容器 id 不可预测,与其事后隐藏, * 不如直接不让它的脚本加载。 * ============================================================ */ if (CFG.sourceBlock) { const neuter = (el) => { const src = el.src || el.getAttribute('src') || ''; if (!isAd(src)) return false; try { el.removeAttribute('src'); } catch (e) {} try { el.src = 'about:blank'; } catch (e) {} el.remove(); log('源头拦截', src); return true; }; // a) hook