Back to Content

permissions.remove()

files/en-us/mozilla/add-ons/webextensions/api/permissions/remove/index.md

latest1.5 KB
Original Source

Revokes the permissions listed in a {{WebExtAPIRef("permissions.Permissions")}} object.

Permissions must come from those defined in the extension's optional_permissions key or gecko.data_collection_permissions.optional property of the browser_specific_settings key of its manifest.json file.

Syntax

js-nolint
let removing = browser.permissions.remove(
  permissions                // Permissions object
)

Parameters

  • permissions
    • : A {{WebExtAPIRef("permissions.Permissions")}} object.

Return value

A Promise fulfilled with true if the browser is no longer granting the permissions listed in the permissions argument to the extension, or false otherwise.

Examples

This code adds a click handler that removes a permission.

js
const permissionToRemove = {
  permissions: ["history"],
};

async function remove() {
  console.log("removing");
  const removed = await browser.permissions.remove(permissionToRemove);
  console.log(removed);
}

document.querySelector("#remove").addEventListener("click", remove);

{{WebExtExamples}}

Browser compatibility

{{Compat}}

[!NOTE] This API is based on Chromium's chrome.permissions API.