Greasy Fork

Greasy Fork is available in English.

百度去广告

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

当前为 2018-05-03 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         百度去广告
// @namespace    http://tampermonkey.net/
// @version      5.03.1511
// @description  百度去广告(首页、搜索结果)
// @author       lidonghui
// @match        *://www.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();
                    }
                }
            });
            // 列表广告
            $(".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();
            }
        }
        // 启动定时器
        setInterval(function () {
            clearAD();
        }, 1000);
    }


})();