1

I know there is the openPopup API to open a browserAction popup.

However, when it is open and a user e.g. selected something, can I somehow close it?

The same applies for a pageAction.


Cross-posted at Mozilla Discourse.

rugk
  • 4,755
  • 2
  • 28
  • 55
  • Possible duplicate of [Closing popup window created by Google Chrome extension](https://stackoverflow.com/questions/3950981/closing-popup-window-created-by-google-chrome-extension) – rugk Apr 25 '19 at 13:25

1 Answers1

2

Actually, as for any other website a simple window.close(); works totally fine!

This was too simple.

Only tested in Firefox though.

Edit: As @juraj.masiar made me aware this won't work for Firefox for Android though:

You will have to use browser.tabs.getCurrent().then(tab => browser.tabs.remove(tab.id)). Plus you need to detect that you are running Android using browser.runtime.getPlatformInfo() function.

rugk
  • 4,755
  • 2
  • 28
  • 55