This package has been deprecated

Author message:

Starting from Firefox 77 (June 2nd, 2020) this polyfill is no longer necessary.

webext-permissions-events-polyfill

1.0.1 • Public • Published

webext-permissions-events-polyfill

WebExtensions: Polyfill for permissions.onAdded and permissions.onRemoved events for Firefox.

Travis build status npm version

Optional permissions can be added and removed by both Chrome and Firefox, but Firefox doesn't yet support Permission Events: https://bugzilla.mozilla.org/show_bug.cgi?id=1444294

This polyfill will add those two events to Firefox.

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-permissions-events-polyfill
import 'webext-permissions-events-polyfill';
require('webext-permissions-events-polyfill');

Usage

Include the polyfill as a background script and then refer to the original Permissions Events documentation.

This polyfill will exclusively work if permissions are requested/removed from the same page where the listener is. That means, if you run chrome.permissions.request in the background page, only the same exact page will receive the event.

If you want to request from options.html or popup.html, add your request here or send a PR to add support via runtime.sendMessage

chrome.permissions.onAdded.addListener(permissions => {
    console.log('New permissions');
    console.log(permissions.origins);
    console.log(permissions.permissions);
});
 
chrome.permissions.onRemoved.addListener(permissions => {
    console.log('Permissions that have been removed');
    console.log(permissions.origins);
    console.log(permissions.permissions);
});

Related

License

MIT © Federico Brigante — Twitter

Package Sidebar

Install

npm i webext-permissions-events-polyfill

Weekly Downloads

28

Version

1.0.1

License

MIT

Unpacked Size

8.05 kB

Total Files

4

Last publish

Collaborators

  • fregante