Greasy Fork

Greasy Fork is available in English.

移除广告

移除网页中的广告

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name                移除广告
// @name:CN:zh          移除广告
// @namespace           https://github.com/GuoChen-thlg
// @version             0.1.4
// @description         移除网页中的广告
// @homepage            http://greasyfork.icu/zh-CN/users/750817-thlg
// @author              THLG
// @supportURL          [email protected]
// @contributionURL     https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=CK755FJ9PSBZ8
// @contributionAmount  1
// @require             https://code.jquery.com/jquery-2.1.4.min.js
// @match               *://*.baidu.com/*
// @match               *://*.csdn.net/*
// @match               *://csdn.net/*
// @match               *://segmentfault.com/*
// @match               *://*.iqiyi.com/*
// @grant               none
// @run-at              document-end
// ==/UserScript==
(function ($) {
    'use strict';
    jQuery.noConflict(true);
    function clearEl (c_select, p_select) {
        if (p_select) {
            $(c_select.join(',')).closest(p_select.join(',')).each((i, el) => {
                if (el) { el.remove() }
            })
        } else {
            $(c_select.join(',')).remove()
        }
    }
    function clearAds () {
        if (/\w{4,5}:\/\/(www\.)?baidu.com\/s.*/.test(location.href)) {
            clearEl([
                "[cmatchid] [class*=tuiguang]",
                ".result [class*=tuiguang]",
                "[data-click] [data-tuiguang]",
            ], [
                "[cmatchid]",
                ".result",
                "[data-click]",
            ])
        }
        if (/\w{4,5}:\/\/jingyan.baidu.com\/s.*/.test(location.href)) {
            clearEl([
                "#task-panel-wrap",
                "#fresh-share-exp-e"
            ])
        }
        if (/\w{4,5}:\/\/wenku.baidu.com\/s.*/.test(location.href)) {
            clearEl([
                "[id*=bdfs] [href*='e.baidu.com']",
            ], [
                "[id*=bdfs]",
            ])
        }
        if (/\w{4,5}:\/\/zhidao.baidu.com\/.*/.test(location.href)) {
            clearEl([
                ".list-header [class*='ec-tuiguang']",

            ], [
                ".list-header",
            ])
        }
        if (/\w{4,5}:\/\/.*csdn.net\/.*/.test(location.href)) {
            clearEl([
                "ins.adsbygoogle",
                "[id*='-ad'] iframe",
            ])
        }
        if (/\w{4,5}:\/\/.*segmentfault.*/.test(location.href)) {
            clearEl([
                "[class*='ad-']",
            ])
        }
        if (/\w{4,5}:\/\/.*iqiyi\.com.*/.test(location.href)) {
            clearEl([
                "[adid]"
            ])
            if ($('.bottom-public').is(':visible') && $('.bottom-public a.skippable-after') && $('.bottom-public a.skippable-after').length > 0) {
                $('.bottom-public a.skippable-after')[0]['click']();
            }
            if ($('.cupid-pause-max-close-btn').length > 0) {
                $('.cupid-pause-max-close-btn')[0]['click']();
            }
        }
    }
    setInterval(clearAds, 20)
})(jQuery);