Firefox exposes this service:
https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIPromptService
Great! It is possible to make firefox display all kind of prompts, alerts, confirm boxes etc.
But can I register event listener anywhere? Basically I want to know when any alert
, confirm
, basic auth
prompt, or even <select>
options list appears on the screen. Is it possible?
As you already found out, there is a DOMWillOpenModalDialog
event. This event might be sufficient for your needs, but you should keep some things in mind:
nsIPromptService
windows, but also for tab-modal (pseudo windows) and all other modal dialogs, such as Filepicker windows, sub-windows of the main preferences window, custom add-on provided windows.There are other possible solutions, though:
nsIPromptService
with your own implementation. You would then just keep a reference to the original implementation around that you got prior and pass the calls along after inspecting them or whatever.chrome://global/content/commonDialog.xul
and/or chrome://global/content/selectDialog.xul
to customize the window even more.