Injecting content scripts consistently in tabs

I’ve been trying to update my extension to using the webextensions api. In the current version I was creating new tabs and disabling redirections. However as noted in this bug report, this functionality will not be made part of the webextensions api and I was asked to use the content scripts instead. I’ve managed to do that fine, as shown in this branch in the repository, except that once thunderbird is closed and reopen, the javascript that I injected in the tab is not injected again automatically. Moreover, as the tab was opened by Thunderbird, I’m not even the owner of the tab anymore, so I do not have permission to inject the script again.

I’ve done some experiments in which I locally store which tabs were opened by the extensions and then I close them, open them again and inject the javascript again. However there are several problems with this approach:

  1. It’s not obvious how to uniquely identify tabs across restarts, as the tab id changes. The setTabValue seemed like a good way but it’s not part of the Thunderbird API.
  2. It’s not clear how to make sure all the tabs are processed, in the sense I couldn’t find any information on whether the extension code will always be executed after all the tabs have been open.
  3. This requires the storage permission, which for this simple extension is difficult to justify to the users.

All of this seems like an over complicated solution to the initial problem of stopping thundbird from redirecting the user to a browser when they click on the link in the tab in thunderbird. Could anyone give me some advice into how to approach this issue?

I suggest you raise this here, where Mark Banner often posts:

Thanks for the advice. As you suggested, I’ve posted the issue there.