contextMenus.remove()

Removes a context menu item.

This is an asynchronous function that returns a Promise.

Syntax

var removing = browser.contextMenus.remove(
  menuItemId      // integer or string
)

Parameters

menuItemId
integer or string. The ID of the context menu item to remove.

Return value

A Promise that will be fulfilled with no arguments if removal was successful, or rejected with an error message if removal failed (for example, because the item could not be found).

Browser compatibility

ChromeEdgeFirefoxFirefox for AndroidOpera
Basic supportYesYes48NoYes

Examples

This extension adds a context menu item labeled "Remove me!". If you click the item, the extension removes it.

function onRemoved() {
  console.log("item removed successfully");
}
function onError() {
  console.log("error removing item:" + browser.runtime.lastError);
}
browser.contextMenus.create({
  id: "remove-me",
  title: "Remove me!",
  contexts: ["all"]
});
browser.contextMenus.onClicked.addListener(function(info, tab) {
  if (info.menuItemId == "remove-me") {
    var removing = browser.contextMenus.remove(info.menuItemId);
    removing.then(onRemoved, onError);
  }
});

Example extensions

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,