NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript==
// @name Fuck Tieba Ads
// @namespace http://tampermonkey.net/
// @version 0.2
// @description 屏蔽贴吧广告
// @author Alex chen
// @license MIT
// @match https://tieba.baidu.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=google.com
// @grant none
// ==/UserScript==
(function() {
'use strict';
// global css 右侧的悬浮广告
const heads = document.querySelector('head');
const style = document.createElement('style');
style.setAttribute('type', 'text/css');
style.innerHTML = `
#aside-ad, .topic_list_box, .app_download_box, #celebrity {
display: none !important;
}
`;
heads.append(style);
// rule 1 悬浮在左侧的广告和伪装成正常帖子的广告
let times = 25;
let clean = function() {
console.log('exec');
let floatList = document.querySelectorAll(".clearfix");
for (let i of floatList) {
if (i.classList.contains("forum_content") || i.classList.contains("content_leftList") || i.classList.contains("content") || i.classList.contains("pb_content")) {
continue;
}
for (let j of i.getElementsByTagName('span')) {
if (j.textContent === "广告") {
// console.log(i);
i.style.display = "none";
}
}
}
times--;
if (times > 0) {
setTimeout(clean, 200);
}
}
clean();
})();