Greasy Fork

Greasy Fork is available in English.

贴吧广告清理

清理ADB与ADP未能清理掉的贴吧列表伪装广告、帖内伪装广告与推荐应用广告

当前为 2016-10-20 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==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);
        }
    }
})();