Is there any way to detect that a tab was removed and then reopened in a container by Firefox Multi-Account Containers or other extensions? I’m developing an extension that groups tabs. It works correctly without containers - for example, users can open a new tab in the same group as the currently active tab. This is done using tab IDs. However, it breaks when containers are enabled, because when a user opens a website that is assigned to a container, this actually removes the tab and reopens it with a new ID. Is there any reliable way to detect that a tab was reopened in a container without user intervention? I could compare URLs and cookieStoreIds and keep track of that, but users might want to just open the same website in another tab (in another group), so I cannot really do that. Any advice?
Well, I can’t think of anything easy or stable, but what could help is to check how the “Multi-Account Containers” addon works:
-
here it registers
onBeforeRequest
handler:
https://github.com/mozilla/multi-account-containers/blob/59e951e5d2345abd36362c740df48c0c767fa9d1/src/js/background/assignManager.js#L410 -
and then here the new tab is created and old one is removed:
https://github.com/mozilla/multi-account-containers/blob/59e951e5d2345abd36362c740df48c0c767fa9d1/src/js/background/assignManager.js#L317C39-L317C39
So you could watch new tab being created and then old (active) being removed right away (let’s say within one second). That could be good enough .
Maybe you can also use the “openerTabId
” property to check if the new tab was created by the old one (it seems that the addon is setting it correctly).
I hoped there was a more reliable way, but this is good enough. Thanks for the reply.