清理ADB与ADP未能清理掉的贴吧列表伪装广告、帖内伪装广告与推荐应用广告
ของเมื่อวันที่
// ==UserScript==
// @name 贴吧广告清理
// @namespace hoothin
// @version 0.1
// @description 清理ADB与ADP未能清理掉的贴吧列表伪装广告、帖内伪装广告与推荐应用广告
// @author hoothin
// @match http*://tieba.baidu.com/*
// @grant none
// @run-at document-start
// ==/UserScript==
(function() {
'use strict';
var tcss = "div.l_post.l_post_bright.j_l_post.clearfix{display: none !important;} .j_encourage_entry{display: none !important;} .encourage_entry{display: none !important;}";
var snod = document.createElement('style');
snod.innerHTML = tcss;
document.getElementsByTagName("head")[0].appendChild(snod);
var content = document.querySelector("#content");
if(content){
var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;
var observer = new MutationObserver(function(records){
delAD();
});
var option = {
'childList': true,
'subtree': true
};
observer.observe(content, option);
}
function delAD(){
var threadList = document.querySelector("#thread_list");
if(!threadList) return;
var delList = [];
for(let thread of threadList.childNodes){
if(thread.tagName == "STYLE"){
delList.push(thread);
}
}
for(let del of delList){
var previousSibling = del.previousSibling;
previousSibling = previousSibling.tagName == "LI"?previousSibling:previousSibling.previousSibling;
threadList.removeChild(previousSibling);
threadList.removeChild(del);
}
}
})();