Greasy Fork

屏蔽百度广告,csdn博客广告

try to take over the world!

当前为 2020-06-03 提交的版本,查看 最新版本

// ==UserScript==
// @name         屏蔽百度广告,csdn博客广告
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  try to take over the world!
// @author       Skity666
// @match        https://www.baidu.com/*
// @match        https://blog.csdn.net*
// @include        https://www.baidu.com/*
// @include        https://blog.csdn.net*
// @grant        none
// @require         https://cdn.staticfile.org/jquery/2.1.4/jquery.min.js
// ==/UserScript==
//更新了百度首页广告去除,csdn博客广告去除
jQuery.noConflict();
(function($) {
    '屏蔽百度广告,csdn博客广告';

    //在dom加载前先清除一遍
    if(location.href.indexOf('//blog.csdn.net') > 0){
        //博客首页
        $(".banner-ad-box").remove()
        $(".right_extension.slide-outer").remove()
        //我的博客或者别人的博客
        $(".csdn-tracking-statistics.mb8.box-shadow").remove()
        $("#footerRightAds").remove();
        $("#dmp_ad_58").remove();
        $(".recommend-item-box.recommend-recommend-box").remove();
    }else{
        refresh()
    }
    $(document).ready(function() {
        refresh()
        var url=window.location.href;
        setInterval(function(){
            if(window.location.href!=url){
                url=window.location.href;
                refresh();
            }
            refresh();
        }, 1000);

        //console.log(location.href.indexOf('//blog.csdn.net/'))
        // console.log(location.href)
        //if(location.href.indexOf('//blog.csdn.net/') > 0){
        //这里是csdn广告去除
        if(location.href.indexOf('//blog.csdn.net') > 0){
            //博客首页
            $(".banner-ad-box").remove()
            $(".right_extension.slide-outer").remove()
            //论坛
            $(".ad_top.bbs_left_box").remove()
            //我的博客或者别人的博客
            $(".csdn-tracking-statistics.mb8.box-shadow").remove()
            $("#footerRightAds").remove();
            $("#dmp_ad_58").remove();
            $(".recommend-item-box.recommend-recommend-box").remove();


        }

    });

    function refresh(){
        //if(location.href.indexOf('www.baidu.com/s') > 0){
        if(location.href.indexOf('www.baidu.com') > 0){
            $(".EC_ppim_new_gap_bottom").remove()
            $("#content_right").remove();
            $("#s_wrap").remove();
            setTimeout(function(){
                $("span").each(function() {
                    if ($(this)[0].innerHTML == '广告') {
                        console.log($(this)[0].innerHTML);
                        $(this).parent().parent().remove();
                    }
                })
                $("a").each(function() {
                    if ($(this)[0].innerHTML == '评价') {
                        console.log($(this)[0].innerHTML);
                        $(this).parent().parent().remove();
                    }
                })
                $(".EC_ppim_new_gap_bottom").remove()
                $("#content_right").remove();
            }, 1000);
        }

    }
    // Your code here...
})(jQuery);