My extension should provide him some service, and part of his job is to listen to tab creation events. I have all my javascript in popup.js and chrome.tabs.onCreated.addListener itself is called (function (tab) {
The fact is that the extension only listens for tab creation events if the user clicks on the extension symbol (if he opens the extension and then activates popup.js), and if the poupup screen is closed, all listening for events stops. (I checked this by writing a console, and it makes sense if you stop thinking about it) My question is: I want to listen to events for the duration of my life (in other words, since the user opens the chrome), and not only when user popup extension.
I know what the background page is called there, should I try to move all my code there? Am I the normal practice for background pages? It's just that event listeners depend on more functions and more objects, and it seems that almost all of my code will go there. popup.js will remain virtually unchanged. Another thing is that I'm not sure if it is possible to register events on the background page before the "domcontentloaded" event was fired (and this event only fires when the user pops up an extension).
Any help would be appreciated!
source share