WebExtension module: Browser-action context menu to request permission for the current tab.
Works great when paired with webext-dynamic-content-scripts if you want to also inject content scripts on the new domains.
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-domain-permission-toggle
import addDomainPermissionToggle from 'webext-domain-permission-toggle';
// In background.js
addDomainPermissionToggle();
{
"browser_action": { /* Firefox support */
"default_icon": "icon.png"
},
"permissions": [
"contextMenus",
"activeTab"
],
"optional_permissions": [
"http://*/*",
"https://*/*"
],
"background": {
"scripts": [
"webext-domain-permission-toggle.js",
"background.js"
]
}
}
Adds an item to the browser action icon's context menu (as shown in the screenshot).
The user can access this menu by right clicking the icon. If your extension doesn't have any action or popup assigned to the icon, it will also appear with a left click.
Type: string
Default: 'Enable ${extensionName} on this domain'
The title of the action in the context menu.
Type: boolean
string
Default: Do you want to reload this page to apply ${extensionName}?
If the user accepts the new permission, they will be asked to reload the current tab. Set a string
to customize the message and false
to avoid the reload and its request.
- webext-dynamic-content-scripts - Automatically registers your content_scripts on domains added via permission.request
- webext-additional-permissions - Get any optional permissions that users have granted you.
- webext-permissions-events-polyfill - Polyfill for
onAdded
andonRemoved
permission events for Firefox. (included inwebext-dynamic-content-scripts
)
- webext-options-sync - Helps you manage and autosave your extension's options. Chrome and Firefox.
- webext-storage-cache - Map-like promised cache storage with expiration. Chrome and Firefox
- webext-detect-page - Detects where the current browser extension code is being run. Chrome and Firefox.
- webext-content-script-ping - One-file interface to detect whether your content script have loaded.
- web-ext-submit - Wrapper around Mozilla’s web-ext to submit extensions to AMO.
- Awesome-WebExtensions - A curated list of awesome resources for WebExtensions development.
MIT © Federico Brigante