Correcting what Marco Bonelli wrote:
If you want to use an event page or a fickle background page, as you call it, you must register the context menu via contextMenus.create in the runtime.onInstalled event runtime.onInstalled , since these registrations are "saved" in the context menu anyway.
You must add a listener function for the contextMenus.onClicked event each time the event page reloads, however, since the registration of your desire to listen to this event is saved, while the callback itself does not.
So, to do it right β’, register your context menu from runtime.onInstalled , but set the event handler callback itself using contextMenus.onClicked.addListener from the top level or another code that is guaranteed to be executed every time the event page is loaded. [ 1 ]
source share