Automatically add content scripts to existing tabs when your extension is installed.
Safari and Firefox actually already do this natively, so this module is automatically disabled there.
- Browsers: Chrome 130+
- Manifest: v3 (v2 was last supported in
webext-inject-on-install v2.3.0
) - Permissions:
scripting
,storage
, (tabs
orhost_permissions
that includes all the hosts specified incontent_scripts
) - Context:
background
Sponsored by PixieBrix 🎉
npm install webext-inject-on-install
Or download the standalone bundle to include in your manifest.json
.
It registers automatically:
import "webext-inject-on-install";
- It gets the list of content scripts from the manifest
- For each content script group, it looks for open tabs that are not discarded (discarded tabs are already handled by the browser)
- It injects the scripts into the focused tabs matching the
matches
patterns (exclude_matches
is not supported #5) - The remaining tabs are tracked and they receive the applicable scripts when they're activated.
- Once the list of tracked tabs is empty, the listeners are removed.
- webext-dynamic-content-scripts - Automatically registers your
content_scripts
on domains added viapermission.request
- webext-content-scripts - Utility functions to inject content scripts in WebExtensions.
- webext-options-sync - Helps you manage and autosave your extension's options.
- More…
MIT © Federico Brigante