Run a function on each new 'popup' event for a Chrome extension (Manifest v3)

Viewed 218

I'm writing a Chrome extension using Manifest v3 and I'd like:

  1. The action to specify a popup page (i.e. popup.html) and
  2. Have a function run each time that popup is displayed.

I know the Chrome Extension API has the action.onClicked event (to which I could subscribe in background.js), but the documentation (here) states:

The action.onClicked event will not be dispatched if the extension action has specified a popup to show on click on the current tab.

Unfortunately, I want to both show the popup page and run a quick function (to update that popup page) on each fresh extension button push. Since the popup page is itself a web page, is there some other event to which I can subscribe for when the popup is displayed (each time)?

1 Answers

Eh, solved. It appears the popup.html page (and any associated <script>) is simply reloaded on each button push. (I'd mistakenly thought perhaps it was loaded once then hidden but kept in-memory.)

Related