Greasy Fork is available in English.

移除框架广告 Remove Ads In iframes

Block Ads In Webpages. This Script Can Only Block Ads Which Are In "Iframe" Tags.

// ==UserScript==
// @name             移除框架广告 Remove Ads In iframes
// @namespace        https://ez118.github.io/
// @version          1.6
// @icon             https://adblockplus.org/favicon.ico
// @description      Block Ads In Webpages. This Script Can Only Block Ads Which Are In "Iframe" Tags.
// @author           ZZY_WISU
// @match            *://*/*
// @run-at document-end
// @license          GNU GPLv3
// ==/UserScript==

/*If this can't block your ads, add the url to block it!*/
var AdsUrlList = ["kunpeng-sc.csdnimg.cn", "googleads.g.doubleclick.net", "pos.baidu.com", "vt.ipinyou.com", "www.2345.com", "show-3.mediav.com",
                 "acdn.adnxs.com", "googleads.g.doubleclick.net", "gum.criteo.com", "ads.yieldmo.com", "ads.pubmatic.com", "bh.contextweb.com",
                 "contextual.media.net", "prebid.a-mo.net", "safeframe.googlesyndication.com", "tpc.googlesyndication.com", "s0.2mdn.net",
                 "c.aaxads.com"];
/*目前可拦截这些广告商的广告: CSDN, GOOGLE, BAIDU等 */

function BlockIt() {
    Array.prototype.forEach.call(document.querySelectorAll('iframe'), function(iframe) {
        /*iframe.parentElement.removeChild(iframe);*/
        for(let i = 0; i < AdsUrlList.length; i ++){
            if(iframe.src.includes(AdsUrlList[i])){
                try { iframe.remove(); }
                catch(e) { iframe.parentElement.removeChild(iframe); }
                break;
            }
        }
    });
}

(function() {
    'use strict';
    BlockIt();
    setTimeout(BlockIt, 1000)
    setInterval(BlockIt, 6000);
})();