Adding external script in an extension

So I’ve been experimenting with this now and it behaves totally different than what I’ve expected. Not only the register doesn’t inject the scripts right away, but the unregister doesn’t unload the scripts at all and page has to be reload in order to kill the script.
So yeah, this sucks. I’m sorry for the confusion :frowning:.

@juraj.masiar Glad in a way that I was not going crazy. Is there any other way you think I can do what I need to do with injecting scripts or do you think there is nothing else I can do to get around the addon reviewer restrictions here?

Well, this is the only way to execute remote scripts without being rejected.
So the solution is to simply work-around these issues by reloading the target tab.

All you have to do is use browser.tabs.reload() to reload the tab after you’ve registered the script and then reload it again after you have unregistered it.

But I’m not sure this is good enough for your use case.

@juraj.masiar The switch usually is in a separate tab with extended options. So reloading that will not be useful. Seems like there is no way around my blockers then. We will have to release the tool with more limited functionality on the FF version.

Thanks for trying to get it working though, if nothing it has been an interesting insight into some limitaitons and additional parts of the API that I haven’t dabbled with yet.

1 Like