捕捉弹出窗口并通知Firefox用户 [英] Catch popup window and notify user in Firefox
问题描述
在此先感谢。
nsIWindowWatcher - https://developer.mozilla.org/en-US/docs/ XPCOM_Interface_Reference / nsIWindowWatcher
nsiWindowMediator - https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIWindowMediator
这是nsiwindowmediator的一种方式:
$ $ $ $ $ $ $ $ $ start $ window $ var windowListener = {
onOpenWindow:function(aXULWindow){
//等待窗口完成加载
让aDOMWindow = aXULWindow.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowInternal | | Ci.nsIDOMWindow);
aDOMWindow.addEventListener('load',function(){
aDOMWindow.removeEventListener('load',arguments.callee,false);
//加载窗口,现在网站会加载addeventlistener为
//检查网站加载是在这里,如果它的竞选事情然后阻止
},false);
},
onCloseWindow:function(aXULWindow){},
onWindowTitleChange:function(aXULWindow,aNewTitle){},
};
/ * end - windowlistener * /
Services.wm.addListener(windowListener);
//Services.wm.removeListener(windowListener);
所以现在在onOpenWindow中,你可以看到什么是开窗器,如果是那个网站,然后关闭那个窗口。
There is a web site that randomly shows up some campaign popup windows on their web site. It would be very useful if a user would be notified when a popup is shown up on that site in Firefox, etc. Can it be possible with the help of javascript, or any add-on, etc.? Thanks in advance.
Two options.
nsIWindowWatcher - https://developer.mozilla.org/en-US/docs/XPCOM_Interface_Reference/nsIWindowWatcher
nsiWindowMediator - https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIWindowMediator
This is the nsiwindowmediator way:
/*start - windowlistener*/
var windowListener = {
onOpenWindow: function (aXULWindow) {
// Wait for the window to finish loading
let aDOMWindow = aXULWindow.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowInternal || Ci.nsIDOMWindow);
aDOMWindow.addEventListener('load', function () {
aDOMWindow.removeEventListener('load', arguments.callee, false);
//window loaded, now the website will load so addeventlistener for that
//check what the website loading is here, if its your campain thing then block it
}, false);
},
onCloseWindow: function (aXULWindow) {},
onWindowTitleChange: function (aXULWindow, aNewTitle) {},
};
/*end - windowlistener*/
Services.wm.addListener(windowListener);
//Services.wm.removeListener(windowListener);
so now in the onOpenWindow, you can see what is the window opener, if it was that website, then close that window.
这篇关于捕捉弹出窗口并通知Firefox用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!