一直用这个,再也没见过弹窗,也不用去维护@include列表。- // ==UserScript==
- // @name blockPopupWindow
- // @namespace http://www.czcp.co.cc/blockPopupWindow.user.js
- // @description 阻止弹窗
- // @include http*
- // @author zbinlin
- // @homepage http://www.czcp.co.cc
- // @version 0.0.2 添加 中国电信(广东)弹窗广告直接过滤
- // @version 0.0.1
- // @run-at document-start
- // ==/UserScript==
-
- document.addEventListener("beforescriptexecute", function (e) {
- document.removeEventListener("beforescriptexecute", arguments.callee, false);
- var win = window.wrappedJSObject;
- win.Fopen = win.open;
- win.open = function () {
- var args = Array.slice(arguments);
- var domain = document.domain;
- // 过滤中国电信(广东)弹窗广告
- // if (args[0].indexOf("http://gd.ct10000.com") == 0) return null;
- // 同域名或同一主机下的弹窗不阻止
- var result = args[0][0] == "\/" || args[0].match(/^(http(s)?:\/\/)?[^/]*/)[0].indexOf(domain) != -1;
- // if (!result) {
- // try {
- // // 提示是否阻止弹窗
- // result = win.confirm("是否允许弹窗!\n" + args[0]);
- // } catch (ex) {
- // result = false;
- // }
- // }
- if (result) {
- return win.Fopen.apply(this, args);
- }
- return null;
- };
- }, false);
复制代码 |