Greasy Fork

Greasy Fork is available in English.

百度去广告

百度去广告(首页、搜索结果)

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         百度去广告
// @namespace    http://tampermonkey.net/
// @version      9.22.1900
// @description  百度去广告(首页、搜索结果)
// @author       lidonghui
// @match        *://www.baidu.com/*
// @match        *://zhidao.baidu.com/*
// @match        *://wenku.baidu.com/*
// @match        *://jingyan.baidu.com/*
// @grant        none
// ==/UserScript==

(function () {
    'use strict';
    // 获取当前地址url
    var url = location.href;
    // 正则匹配首页部分
    var baidusearch = /www.baidu.com/i;
    if (baidusearch.test(url)) {
        function clearAD() {
            // 搜索结果推广广告
            $(".ec_tuiguang_ppouter").parents().map(function () {
                var thisid = $(this).attr("id");
                var id = new RegExp('300');
                if (thisid != undefined && thisid != "undefined") {
                    if (id.test(thisid)) {
                        $("#" + thisid).remove();
                    }
                }
            });
            // 百度推广广告
            $(".c-abstract").parents().map(function () {
                var thisid1 = $(this).attr("id");
                var id1 = new RegExp('400');
                var id2 = new RegExp('500');
                if (thisid1 != undefined && thisid1 != "undefined") {
                    if (id1.test(thisid1) || id2.test(thisid1)) {
                        $("#" + thisid1).remove();
                    }
                }
            });
            // 列表广告
            $("span.m").map(function () {
                if ($(this).text() == "广告") {
                    $(this).parent().parent().remove();
                }
            });
            // 列表广告
            $("span").map(function () {
                if ($(this).text() == "广告") {
                    $(this).parent().parent().remove();
                }
            });
            // 首页右边广告
            $(".ad-block").parent().parent().parent().remove();
            if ($("#content_right").children("div").get(0) != undefined && $("#content_right").children("div").get(0) != "undefined") {
                $($("#content_right").children("div").get(0)).remove();
            };
            // 百度右边整体隐藏
            $(".hit_top_new").remove();
            // $("#content_right").remove();
            $("#content_right").css("position", "absolute");
            $("#content_right").css("top", "0px");
            $("#content_right").css("left", "700px");
            $("#wrapper_wrapper").css("background-color", "#F5F5F5");
            $("#container").css("background-color", "#F5F5F5");
            $("#wrapper>#container").css("width", "100%");
            // 百度视频
            $(".video_list.video_short").css("background-color", "#fff");
            $(".video_list.video_short").css("padding", "20px");
            $(".video_list.video_short").css("border-radius", "5px");
            $(".video_list.video_short").css("box-shadow", "0 0 20px 2px rgba(0, 0, 0, .1)");
            $(".result ").css("background-color", "#fff");
            $(".result ").css("padding", "20px");
            $(".result ").css("border-radius", "5px");
            $(".result ").css("box-shadow", "0 0 20px 2px rgba(0, 0, 0, .1)");
            $("#rs").css("background-color", "#F5F5F5");
            $(".result-op ").css("background-color", "#fff");
            $(".result-op ").css("padding", "20px");
            $(".result-op ").css("border-radius", "5px");
            $(".result-op ").css("box-shadow", "0 0 20px 2px rgba(0, 0, 0, .1)");
            // 登录首页
            $("#s_top_wrap").remove();
            $("#s_upfunc_menus").remove();
            $("#u_sp").remove();
            $("#bottom_container").remove();
            // 未登录首页
            $("#qrcode").remove();
            $("#ftCon").remove();
            // 搜索页-反馈
            $("#foot").remove();
            // 重置特殊显示
            $(".c-container.result").css("width", "560px");
            $("#content_left .result-op").css("width", "560px");
            $("#content_left .result-op").css("padding", "20px");
            // $("#content_left .result-op").css("display", "none");
            $(".new-pmd.c-container").css("width", "560px");
            $(".result-op.c-container").css("width", "560px");
            $(".result-op.c-container.xpath-log").css("width", "560px");
            $(".new-pmd.c-container").css("background-color", "#fff");
            $(".new-pmd.c-container").css("padding", "20px");
            $(".new-pmd.c-container").css("border-radius", "5px");
            $(".new-pmd.c-container").css("box-shadow", "0 0 20px 2px rgba(0, 0, 0, .1)");
            $(".wrapper_new .sam_newgrid~#page strong, .wrapper_new .sam_newgrid~#page a").css("box-shadow", "0 0 20px 2px rgba(0, 0, 0, .1)");
            // 热点样式调整
            $(".c-group-wrapper").css("margin-left", "0px");
            $(".c-group-wrapper").css("box-shadow", "0 0 20px 2px rgba(0, 0, 0, .1)");
            $(".c-group-wrapper .result-op").css("box-shadow", "none");
            $(".result-op .result.c-container").css("box-shadow", "none");
            $(".result-op .result.c-container").css("padding", "0px");
            $(".new-pmd .c-border").css("box-shadow", "none");
            $(".new-pmd .c-border").css("border-radius", "0px");
            $('div[class ^= "re-box_"]').css("border-radius", "0px");
            $('div[class ^= "re-box_"]').css("box-shadow", "none");
            $('table[class = "result-op"]').remove();
            $('.result-op.c-container>.c-border').css("border", "none");
            $('.result-op.c-container>.c-border').css("box-shadow", "none");
            // 样式
            $(".c-border.ec-pl-container").css("width", "560px");
            $(".c-border.ec-pl-container").css("background-color", "#fff");
            $(".c-border.ec-pl-container").css("padding", "20px");
            $(".c-border.ec-pl-container").css("border-radius", "5px");
            $(".c-border.ec-pl-container").css("box-shadow", "0 0 20px 2px rgba(0, 0, 0, .1)");

            // 去掉
            $('.c-container.b2c-universal-card.new-pmd').css("box-shadow", "none");
            $('.c-container.b2c-universal-card.new-pmd').css("border-radius", "none");
            $('.c-container.b2c-universal-card.new-pmd').css("padding", "0px");
            $('.EC_result.new-pmd.c-container>div').css("box-shadow", "none");
            $('.EC_result.new-pmd.c-container>div').css("border-radius", "none");
            $('.EC_result.new-pmd.c-container>div').css("padding", "0px");

        }
        // 启动定时器
        setInterval(function () {
            clearAD();
        }, 1000);
    }
    // 百度知道搜索列表
    var baiduzhidao = /zhidao.baidu.com\/search/i;
    if (baiduzhidao.test(url)) {
        function clearzdAD() {
            // 知道列表广告
            if (document.getElementsByClassName("bannerdown")[0] != undefined && document.getElementsByClassName("bannerdown")[0] != "undefined") {
                document.getElementsByClassName("bannerdown")[0].innerHTML = "";
            }
            document.getElementsByClassName("aside-inner")[0].innerHTML = "";
            document.getElementsByClassName("wgt-bottom-ask")[0].innerHTML = "";
            document.getElementsByClassName("wgt-bottom-ask")[0].style.height = "0px";
        }
        clearzdAD();
    }
    // 百度知道
    var baiduzhidaodet = /zhidao.baidu.com\/question/i;
    if (baiduzhidaodet.test(url)) {
        function clearzddetAD() {
            document.getElementById("qb-side").innerHTML = "";
            document.getElementsByClassName("qb-section")[0].nextElementSibling.innerHTML = "";
        }
        clearzddetAD();
    }
    // 百度文库
    var baiduwenku = /wenku.baidu.com\/search/i;
    if (baiduwenku.test(url)) {
        function clearwkAD() {
            document.getElementsByClassName("aside")[0].style.display = 'none';
            document.getElementsByClassName("search-topicBox-wrap")[0].style.display = 'none';
            document.getElementById("fengchaoad").style.display = 'none';
            document.getElementById("wkad5").style.display = 'none';
        }
        setInterval(function () {
            clearwkAD();
        }, 1000);
    }
    // 文库文档页面
    var baiduwenkudet = /wenku.baidu.com\/view/i;
    if (baiduwenkudet.test(url)) {
        function clearwkdetAD() {
            document.getElementById("ggbtm").style.display = 'none';
            document.getElementById("wkgg").style.display = 'none';
            document.getElementsByClassName("main")[0].nextElementSibling.innerHTML = "";

        }
        setInterval(function () {
            clearwkdetAD();
        }, 1000);
    }
    // 文库首页
    var baiduwenkudet = /wenku.baidu.com/i;
    if (baiduwenkudet.test(url)) {
        function clearwkinAD() {
            document.getElementById("banner-ad1").style.display = 'none';
            document.getElementById("banner-ad2").style.display = 'none';
        }
        setInterval(function () {
            clearwkinAD();
        }, 1000);
    }
    // 百度经验
    var baidujingyan = /jingyan.baidu.com/i;
    if (baidujingyan.test(url)) {
        function clearjyAD() {
            var iframe = $('iframe');
            for (var i = 0; i < iframe.length; i++) {
                iframe.remove();
            };
        }
        setInterval(function () {
            clearjyAD();
        }, 1000);
    }
})();