How to get user input in background page

In WebExtensions, you can’t use window.prompt() in background page.
Chrome incompatibilities - Mozilla | MDN
Is there a workaround for this?
How can I get user input from background page?

You will need to open some kind of add-on page for that. be it a tab, a pop-up, the page-/browserAction or a side- or toolbar.

yes… I inject a script for the prompt from the background page:
chrome.tabs.executeScript({code: "prompt(.....)"}, function(result) {...})

It is a hack but sadly there isnt an API.

Note: tabs.executeScript() will not work on about:* or addons.mozilla.org.
It will only work on supported schemes ie “http”, “https”, “file”, “ftp”.

1 Like

Got it, thanks.
I’m currently prompting from content script, I wanted to know if there is a better way.