A plugin for Addon Bone that automatically registers and injects content scripts when your browser extension is installed.
- Immediate Content Script Activation: Automatically injects your content scripts into existing tabs that match your URL patterns when the extension is first installed
- Full Support for Content Script Options: Works with all manifest content script properties including
run_at
,all_frames
,match_about_blank
, and execution world - Error Handling: Gracefully handles injection failures with detailed error logging
- Zero Configuration: Works out of the box with your existing manifest content script definitions
When your extension is installed, this plugin:
- Reads the
content_scripts
section from your extension's manifest - Finds all open tabs that match the URL patterns defined in your content scripts
- Injects the specified JavaScript and CSS files into those tabs
- This ensures users can immediately see and use your extension without needing to refresh their tabs
This plugin requires the following permissions in your manifest:
tabs
: Needed to query and access tab information for content script injectionscripting
: Required to inject scripts and CSS into web pages
These permissions are automatically requested by the plugin and are essential for its functionality.
Using npm:
npm install @adnbn/plugin-reg-cs
Using Yarn:
yarn add @adnbn/plugin-reg-cs
Using pnpm:
pnpm add @adnbn/plugin-reg-cs
In your adnbn.config.ts
:
import {defineConfig} from "adnbn";
import registerContentScript from "@adnbn/plugin-reg-cs";
export default defineConfig({
plugins: [registerContentScript()],
// other Addon Bone settings...
});
If your content scripts aren't being injected:
- Make sure you have included the necessary URL patterns in
host_permissions
in your manifest, otherwise the API won't have access to those tabs
MIT © Addon Bone