contextMenus.removeAll()

Removes all context menu items added by the extension.

This is an asynchronous function that returns a Promise.

Syntax

var removing = browser.contextMenus.removeAll()

Parameters

None.

Return value

A Promise that will be fulfilled with no arguments when all items have been removed.

Browser compatibility

ChromeEdgeFirefoxFirefox for AndroidOpera
Basic supportYesYes48NoYes

Examples

This example adds two context menu items. When the user clicks the item labeled "Remove all!", the extension removes both items using removeAll().

function onRemoved() {
  console.log("items removed successfully");
}
browser.contextMenus.create({
  id: "click-me",
  title: "Click me!",
  contexts: ["all"]
});
browser.contextMenus.create({
  id: "remove-all",
  title: "Remove all!",
  contexts: ["all"]
});
browser.contextMenus.onClicked.addListener(function(info, tab) {
  if (info.menuItemId == "remove-all") {
    var removing = browser.contextMenus.removeAll();
    removing.then(onRemoved);
  }
});

Acknowledgements

This API is based on Chromium's chrome.contextMenus API. This documentation is derived from context_menus.json in the Chromium code.

Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.

Document Tags and Contributors

 Contributors to this page: andrewtruongmoz, wbamberg, Makyen
 Last updated by: andrewtruongmoz,