// ==UserScript== // @name 通用去广告(比较暴力,谨用)V0.1 // @namespace http://tampermonkey.net/zxc/common/adblock4iframe // @version 0.1 // @description 专治广告联盟的iframe // @author zxc // @match http*://*/* // @grant none // @compatible chrome // @incompatible IE678 // @downloadURL none // ==/UserScript== (function() { 'use strict'; blockAd(); window.setTimeout(blockAd,1000);//防止后面加载的广告 window.setTimeout(blockAd,5000);//防止后面加载的广告 /************main end*************************/ /************functions*************************/ function blockAd (){ //console.dir('blockAd'); var selectors = [ 'iframe']; var adDoms = getElements(selectors); hideElements(adDoms); } function getElements (selectors){ var adDoms = []; if(selectors && selectors.length){ var ad; var ads; for(var j=0,len0=selectors.length;j 0){ var prefix = selector.substr(0,1); var subfix = selector.length > 1 ? selector.substring(1) : ''; switch(prefix){ case '#': ad = document.getElementById(subfix);//右下角. ads = [ad]; break; case '.': ads = document.getElementsByClassName(subfix);//登录提示条 break; default: ads = document.getElementsByTagName(selector); } joinArray(adDoms, ads); } } } return adDoms; } function joinArray(arr1,arr2){ arr1 = arr1 || []; if(arr2 && arr2.length){ for(var i=0,len=arr2.length; i