我实在看不下去这萌娘百科的广告了,这广告在这我怎么看背景图(
找到广告属性
右键这个广告,点检查,然后右边弹出来的元素工具栏里高亮的部分就是这个广告的元素属性
然后找到这些广告的一些通用的属性(例如它们的类之间的关系,跳转的网址等),为寻找并删除做铺垫
删除
使用伟大的篡改猴(已经允许用户脚本的)进行编写脚本,并使用了伟大的deepseek生成脚本:
// ==UserScript==
// @name 通用网站 - 移除广告被屏蔽提示 + 自定义类名广告删除
// @namespace https://github.com/CPlayerCHN
// @version 1.1
// @description 移除网站因为广告屏蔽插件被检测到而展示的提示内容,并支持删除指定类名特征的广告元素。
// @author CPlayerCHN
// @match *://*/*
// @grant GM_addStyle
// ==/UserScript==
(function() {
'use strict';
const rules = [
{
domain: /moegirl\.org\.cn|moegirl\.uk|moegirl\.icu/,
remove: [
'#adblock-detecter',
'.adblock-notice',
'[class*="_448rw0"]',
'[class*="_ylzvr2"]',
'[class*="xUkJeF1d7d"',
'a[href^="https:"]',
]
},
{
domain: /bilibili\.com/,
remove: [
'.adblock-tips',
'.bpx-player-guide'
]
},
{
domain: /zhihu\.com/,
remove: [
'.Modal-closeButton',
'.css-1q1z0rv'
]
},
];
rules.forEach(rule => {
if (rule.domain.test(window.location.hostname)) {
rule.remove.forEach(selector => {
const elements = document.querySelectorAll(selector);
elements.forEach(el => el.remove());
});
}
});
const observer = new MutationObserver(() => {
rules.forEach(rule => {
if (rule.domain.test(window.location.hostname)) {
rule.remove.forEach(selector => {
document.querySelectorAll(selector).forEach(el => el.remove());
});
}
});
});
observer.observe(document.body, { childList: true, subtree: true });
})();可以看到你想要删除什么就在 rules 里加上就好了
domain是可搜索的网址,使用正则表达式匹配,/.*/可搜索所有网址;remove里加的就是你要删的属性:
'#sth'就是删除id是sth的,'[id*="sth"]'就是删除id包含sth的'.sth"='就是删除class是sth的,'[class*="sth"]"='就是删除class包含sth的'a[href^="sth"]'就是删除href(即跳转的网址)包含sth的
基本上大部分广告要么有单独的 class 或 id ,要么像萌娘百科一样,正经的链接一般前缀相同不会加 https,广告都是跳转到单独的网址所以有 https
有了这些你只要遇到广告就放到黑名单里(rules)即可
(萌娘百科的广告 class 似乎要么后缀是 _448rw0,要么是 _ylzvr2,居然还有随机性)
展示页面清洁效果:
可以看到完全删完了,能看到背景图(九鸟~),非常强劲

