Best UI option for a confirm dialog in a background script?

I have a Reload All Tabs command for the tab context menu. For any tabs that are currently playing media ( == true) I’d like to offer the user a confirm dialog. At a minimum, it would have Yes and No buttons, but it also could have Alway, Never, or a Do this every time checkbox.

I’m having trouble finding a nice way to present that. What doesn’t seem to work is:

That leaves creating a new window, which could be annoying, but is the only thing I still see as an option. Any other ideas?


You could inject HTML into page content but this will not work with privileged urls (about:*). Open a new window/tab seems to be the best solution.

Yep. This is not as straight-forward as it could be. I faced the same issue a while back and think I ended up with a pretty satisfying solution based on popup windows. Notably, it:

  • closes on blur
  • removes itself from the closed windows

The only really ugly thing it the title bar, whose text still can’t be changed (AFAIK).

You can see an example by installing this extension and runing this in its debugger:

require.async('background/prompt').then(_=>_.requestPermission({ message: 'Some Text', }))

If you like it, you’ll need to extract the relevant code from 'background/prompt.js' and 'node_modules/web-ext-utils/loader/views.js' yourself, though.

Thanks all.

It’s frustrating that setting either top or left in windows.create() leads to a centered popup. I see from the following bug that I can set the position after the fact using windows.update(), but this is not so appealing, visually.

Yet another hour lost trying to figure out why something doesn’t work as documented. Sigh. I guess I need to edit MDN.