fregante / webext-inject-on-install

Automatically add content scripts to existing tabs when your extension is installed. Chrome

Home Page:https://npm.im/webext-inject-on-install

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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 in permissions; in Manifest v3 you'll also need scripting
  • Context: background

Sponsored by PixieBrix šŸŽ‰

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

  1. It gets the list of content scripts from the manifest
  2. For each content script group, it looks for open tabs that are not discarded (discarded tabs are already handled by the browser)
  3. It injects the script into the tabs matching the matches patterns (exclude_matches is not supported fregante/webext-dynamic-content-scripts#5)
  4. If the tab count exceeds 10 (each), it injects into the tabs only when they become active. (persistent background pages only fregante/webext-dynamic-content-scripts#4)

Related

License

MIT Ā© Federico Brigante

About

Automatically add content scripts to existing tabs when your extension is installed. Chrome

https://npm.im/webext-inject-on-install

License:MIT License


Languages

Language:TypeScript 50.2%Language:JavaScript 49.8%