本帖最后由 潘钜森 于 2023-9-18 16:30 编辑
# 如下图,微软必应(关键词:苹果)搜索结果,品牌广告占屏🤬
## 首先,把他的广告背景图给给干掉,杀了😇
document.querySelector("#b_ims_bza_pole").style.setProperty("display", "none", "important");
## 正片开始🔞
var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;
var bing_header = document.querySelector("#b_header");
var observer = new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
if (mutation.type == "attributes") {
bing_header.style.backgroundColor = "";
bing_header.style.borderBottom = "1px solid #ececec";
}
});
});
observer.observe(bing_header, {
attributes: true,
attributeFilter: ['style']
});
### 🔥脚本实例如下:
// ==UserScript==
// @name 【MutationObserver实例】监听样式变化还原样式
// @namespace https://bbs.tampermonkey.net.cn/
// @version 0.1.0
// @description try to take over the world!
// @author You
// @match *://*.bing.com/*
// @grant GM_addStyle
// @run-at document-start
// ==/UserScript==
GM_addStyle(`
#b_ims_bza_pole {
display: none !important;
}
`);
var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;
var bing_header = document.querySelector("#b_header");
var observer = new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
if (mutation.type == "attributes") {
bing_header.style.backgroundColor = "";
bing_header.style.borderBottom = "1px solid #ececec";
}
});
});
observer.observe(bing_header, {
attributes: true,
attributeFilter: ['style']
});