webext-inject-on-install
v2.2.1
Published
Automatically add content scripts to existing tabs when your extension is installed
Downloads
2,480
Maintainers
Readme
webext-inject-on-install
Automatically add content scripts to existing tabs when your extension is installed.
Firefox actually already does this natively, so this module is automatically disabled there.
- Browsers: Chrome, Firefox, and Safari
- Manifest: v2 and v3
- Permissions:
tabs
+ explicit host permissions inpermissions
; in Manifest v3 you'll also needscripting
- Context:
background
Sponsored by PixieBrix :tada:
Install
npm install webext-inject-on-install
Or download the standalone bundle to include in your manifest.json
.
Usage
It registers automatically:
import "webext-inject-on-install";
How it works
- 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 script into the tabs matching the
matches
patterns (exclude_matches
is not supported https://github.com/fregante/webext-dynamic-content-scripts/issues/5) - If the tab count exceeds 10 (each), it injects into the tabs only when they become active. (persistent background pages only https://github.com/fregante/webext-dynamic-content-scripts/issues/4)
Related
- 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…
License
MIT © Federico Brigante