欢迎光临
我们一直在努力

浮动广告查杀脚本

/ ==UserScript==// @name jsKillAD// @namespace jsKillAD// @include http://*// @include https://*// @grant none// @version 1// ==/UserScript==(function () { var bc = Array.prototype.forEach;//Callback function getStyle(o, s) { if(o.style[s])//内联样式 return o.style[s]; else if(document.defaultView && document.defaultView.getComputedStyle){//DOM //s = s.replace(/([A-Z])/g,’-$1′).toLowerCase(); var x = document.defaultView.getComputedStyle(o,”); return x.getPropertyValue(s); } } function testStyle(o) { var s = getStyle(o, “position”); return s === “fixed” || s === “absolute”; }/* function sameDomain(o) { try { return o.document.body; } catch (e) { return 0; } }*/ function isFloatLay(o) { var x = o.offsetParent; return !x || x.tagName === “BODY” || x.tagName === “HTML”; } function delNode(x) { x.parentNode.removeChild(x); } function scan(el) { [“iframe”, “img”, “object”, “embed”, “video”].forEach(function(s) { bc.call(el.getElementsByTagName(s), function(x) { while (x) { if (isFloatLay(x)) { //要删除的层得同时满足二个条件 if (testStyle(x)) delNode(x); break; } x = x.offsetParent; } }); }); } /* //扫描广告脚本 bc.call(document.getElementsByTagName(“script”), function(o) { if (o.src && o.readyState !== “complete”) delNode(o); }); //没用哦,因为DIV中可能已经生成了元素 bc.call(document.querySelectorAll ? document.querySelectorAll(“div>script”) : document.getElementsByTagName(“script”), function(x) { x = x.parentNode; if (x.childNodes.length === 1) delNode(x); }); */ document.addEventListener(“DOMContentLoaded”, function(){scan(document);}, false); bc.call(frames, function(x) { try { scan(x.contentDocument); } catch (e) {} });})();

赞(0)
未经允许不得转载:阿强爱分享 » 浮动广告查杀脚本

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址