I’m developing an extension that registers an event listener in a content script (on the document
element). I load this extension via about:debugging
. Whenever I reload the extension with the “Reload” button, the event listener is registered again and I end up with two.
How can I prevent this from happening? I think the correct thing would be to remove the listener and then add the new one. I tried to do this using browser.runtime.onUpdateAvailable
but I think this event is only available to background scripts because it appears undefined in the content script.