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:
- You need to actually add an event listener to all windows that you're interested in and that could open a modal dialog.
- The event will be fired not only for
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:
- Override
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. - You can overlay the actual modal prompt windows like any other XUL window, at least on Firefox Desktop, e.g.
chrome://global/content/commonDialog.xul
and/orchrome://global/content/selectDialog.xul
to customize the window even more.