webext-dynamic-content-scripts
webext-dynamic-content-scripts copied to clipboard
Automatically listen to activetab (optionally?)
trafficstars
In some cases (most?) you'd also want the content script to be automatically available on the activeTab as well. This would avoid conflicting scripts trying to inject the script via different code paths:
- https://github.com/pixiebrix/pixiebrix-extension/issues/3510
ActiveTab-tracking code can be found here and will likely be extracted, maybe into webext-tools:
- https://github.com/pixiebrix/pixiebrix-extension/blob/3d23b8063637aa5fd8734cabe7d3137cdd616c3a/src/background/activeTab.ts
On top of that, I think it also needs to listen to tabs and manually inject the scripts instead of relying on registerContentScripts. However it seems that the API supports activeTab in MV3: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/scripting/registerContentScripts
To preserve the side-effects-only nature of the module, I think it can export an additional entry point:
import 'webext-dynamic-content-scripts/including-activetab';