您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
完全隐藏 .gg_link 广告(display: none),并禁止点击
// ==UserScript== // @name ITDOG 广告去无踪 // @version 1.6 // @description 完全隐藏 .gg_link 广告(display: none),并禁止点击 // @author Dahi // @match *://www.itdog.cn/* // @grant GM_addStyle // @run-at document-start // @license MIT // @namespace https://greasyfork.org/users/1442595 // ==/UserScript== (function() { 'use strict'; // 1. 强制全局CSS:完全隐藏 + 禁止交互 GM_addStyle(` .gg_link, [class*="gg_link"] { display: none !important; pointer-events: none !important; } `); // 2. 监控动态加载的广告 const observer = new MutationObserver(function(mutations) { document.querySelectorAll('.gg_link, [class*="gg_link"]').forEach(el => { el.style.setProperty('display', 'none', 'important'); el.style.setProperty('pointer-events', 'none', 'important'); }); }); observer.observe(document, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); // 3. 防止JS强行恢复广告 const originalSetAttribute = Element.prototype.setAttribute; Element.prototype.setAttribute = function(name, value) { if (name === 'class' && value.includes('gg_link')) { value += ' hidden-ad'; // 标记广告元素 } originalSetAttribute.call(this, name, value); }; })();