Skip to content
WebExtension module: Automatically registers your content_scripts on domains added via permission.request
TypeScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.editorconfig
.gitignore
.npmrc
.travis.yml
how-to-add-github-enterprise-support-to-web-extensions.md
index.ts
license
package.json
readme.md
tsconfig.json

readme.md

webext-dynamic-content-scripts Travis build status npm version

WebExtension module: Automatically registers your content_scripts on domains added via permission.request

For example, when your users enable more domains via webext-domain-permission-toggle, this module will automatically register your content_scripts from manifest.json into the new domain.

The main use case is to add support for GitHub/GitLab Enterprise domains to your GitHub/GitLab extension: you start with github.com and then users can add new domains; this way you don't need to use a broad <all_urls> permission.

Notice: this plugin includes polyfills for contentScript.register (for Chrome) and Permission Events (for Firefox)

Guides

Migration instructions from v5 to v6.

How to let your users enable your extension on any domain.

Install

You can just download the standalone bundle (it might take a minute to download) and include the file in your manifest.json, or:

npm install webext-dynamic-content-scripts
// This module is only offered as a ES Module
import 'webext-dynamic-content-scripts';

Usage

Include webext-dynamic-content-scripts as a background script and add optional_permissions to allow new permissions to be added. The scripts defined in content_scripts will be added on the new domains (matches will be replaced)

// example manifest.json
{
	"optional_permissions": [
		"http://*/*",
		"https://*/*"
	],
	"background": {
		"scripts": [
			"webext-dynamic-content-scripts.js",
			"background.js"
		]
	},
	"content_scripts": [
		{
			"matches": [
				"https://github.com/*"
			],
			"css": [
				"content.css"
			],
			"js": [
				"content.js"
			]
		}
	]
}

Related

Permissions

Others

License

MIT © Federico Brigante

You can’t perform that action at this time.