Greasy Fork

Greasy Fork is available in English.

【去广告 屏蔽广告 广告拦截 百度广告 百度联盟广告 谷歌广告】@LYS-广告拜拜助手(适配手机)

1、屏蔽百度搜索结果中插入广告;2、屏蔽百度联盟推广广告;3、屏蔽谷歌推广广告;4、屏蔽CSDN推广广告;5、可屏蔽自定义推广广告……

当前为 2022-05-04 提交的版本,查看 最新版本

// ==UserScript==
// @name         【去广告 屏蔽广告 广告拦截 百度广告 百度联盟广告 谷歌广告】@LYS-广告拜拜助手(适配手机)
// @namespace    http://tampermonkey.net/
// @version      1.6
// @description  1、屏蔽百度搜索结果中插入广告;2、屏蔽百度联盟推广广告;3、屏蔽谷歌推广广告;4、屏蔽CSDN推广广告;5、可屏蔽自定义推广广告……
// @author       LYS
// @match        */*
// @icon         none
// @grant        none
// @license      MIT
// ==/UserScript==
(function () {
    'use strict';
    //自定义屏蔽ifram广告推送规则
    var ads = ["kunpeng-sc.csdnimg.cn/", //csdn广告推送
        "pos.baidu.com/", //百度广告推送
        "g.doubleclick.net", //谷歌广告推送
        "pagead2.googlesyndication.com", //谷歌广告推送
        "tpc.googlesyndication.com", //谷歌广告推送
        "cs.emxdgt.com",
        "sync.richaudience.com",
        "gum.criteo.com",
        "ads.pubmatic.com",
        "eus.rubiconproject.com",
        "hde.tynt.com",
        "ssbsync.smartadserver.com",
        "simage2.pubmatic.com",
        "onetag-sys.com",
        "sync.aniview.com",
        "imasdk.googleapis.com",
        "mp.4dex.io",
        "acdn.adnxs.com",
        "safeframe.googlesyndication.com",
        "s.amazon-adsystem.com",
        "rtb.gumgum.com",
        "ap.lijit.com",
        "usersync.gumgum.com",
        "sync.inmobi.com"
    ]
    for (var i = 0; i < ads.length; i++) {
        if (window.location.href.includes(ads[i])) {
            document.getElementsByTagName('head').innerHTML = "";
            document.getElementsByTagName('title').innerHTML = "";
            document.getElementsByTagName('body')[0].innerHTML = "";
            break
        }
    }



    if (window.location.href.includes("www.baidu.com/")) {
        setInterval(function () {
            $('#content_left div:contains("广告")').slideUp()
        }, 500)
    }

    if (window.location.href.includes("m.baidu.com/")) {
        setInterval(function () {
            $('.ec_ad_results').hide()
        }, 500)
    }

    if (typeof jQuery != "undefined") {
        console.log("ok")
    } else {
        var script = document.createElement("script");
        script.type = "text/javascript";
        script.src = "https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js";
        document.getElementsByTagName('head')[0].appendChild(script);
    }


    var killads = function () {
        $('*').each(function (index, DOMe) {
            var src = $(DOMe).attr("src")
            if (typeof src != "undefined") {
                for (var i = 0; i < ads.length; i++) {
                    if (src.includes(ads[i])) {
                        $(DOMe).hide()
                        break
                    }
                }
            }
        })
    }

    window.lys = setInterval(function () {
        if (typeof jQuery != "undefined") {
            killads();
            clearInterval(lys)
            return
        }
    }, 500)

})();