V2EX 脚本
689

广告屏蔽脚本,哈哈!
// ==UserScript== // @name V2EX 广告清理 // @name:zh-CN V2EX 广告清理 // @namespace https://v2ex.com/ // @version 1.0.0 // @description 屏蔽 V2EX 页面中的 PRO 推广位(Promoted by 广告盒)、万维广告(wwads)与 Google AdSense 广告,并清理广告移除后残留的间距 // @author COM // @match *://v2ex.com/* // @match *://*.v2ex.com/* // @run-at document-start // @grant none // ==/UserScript== (function () { 'use strict'; var ADS_CSS = [ /* ---- 1. V2EX 官方 PRO 推广位(侧边栏 / 列表里 "Promoted by xxx" 的广告盒) ---- */ '#pro-campaign-container,', '[class^="pro-unit"],', '[class*=" pro-unit"],', /* ---- 2. 万维广告 wwads(列表中带 "广告" 角标、"Shop Now" 按钮的横幅) ---- */ '.wwads-cn,', '[class^="wwads"],', '[class*=" wwads"],', /* ---- 3. Google AdSense 及常见第三方广告 iframe ---- */ 'ins.adsbygoogle,', '.adsbygoogle,', '.google-auto-placed,', '[id^="google_ads"],', '[id^="aswift"],', 'iframe[id^="aswift"],', 'iframe[src*="googlesyndication"],', 'iframe[src*="doubleclick"] {', ' display: none !important;', ' visibility: hidden !important;', ' height: 0 !important;', ' min-height: 0 !important;', ' max-height: 0 !important;', ' width: 0 !important;', ' min-width: 0 !important;', ' margin: 0 !important;', ' padding: 0 !important;', ' border: 0 !important;', ' overflow: hidden !important;', ' pointer-events: none !important;', '}', /* ---- 4. 广告盒隐藏后,顺带吃掉它上方多余的 20px 间距(旧浏览器不支持 :has 会自动忽略) ---- */ 'div.sep20:has(+ #pro-campaign-container),', 'div.sep20:has(+ div > .wwads-cn) {', ' display: none !important;', '}' ].join('\n'); function injectCSS() { var root = document.head || document.documentElement; if (!root) return; var style = document.createElement('style'); style.type = 'text/css'; style.textContent = ADS_CSS; root.appendChild(style); } /* 广告容器被隐藏后,若 wwads 的外层只剩一个空壳,一并收掉,避免残留视觉缝隙 */ function cleanupEmptyShell() { var ads = document.querySelectorAll('.wwads-cn'); for (var i = 0; i < ads.length; i++) { var box = ads[i].parentElement; if (box && box.tagName === 'DIV' && !box.id && box.children.length === 1) { box.style.display = 'none'; } } } /* document-start 阶段就注入,早于广告脚本渲染,避免闪烁 */ injectCSS(); if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', function () { injectCSS(); cleanupEmptyShell(); }, { once: true }); } else { cleanupEmptyShell(); } })();- 收藏支持反对打赏
没账号

没账号 + 1

没账号







没账号
没账号

奇怪 为什么我进去没开任何去广告的插件 看不到一个广告

没账号 太贵
佬来个邀请码 我去帮你试试
