contextMenus.removeAll()

Removes all context menu items added by this add-on.

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

Chrome Edge Firefox Firefox for Android Opera
Basic support Yes Yes 48.0 No 33

Examples

This example adds two context menu items. When the user clicks the item labeled "Remove all!", the add-on 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: wbamberg, Makyen
 Last updated by: wbamberg,