Removes a menu item.
For compatibility with other browsers, Firefox makes this method available via the contextMenus
namespace as well as the menus
namespace.
This is an asynchronous function that returns a Promise
.
var removing = browser.menus.remove( menuItemId // integer or string )
menuItemId
integer
or string
. The ID of the menu item to remove.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).
This extension adds a 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.menus.create({ id: "remove-me", title: "Remove me!", contexts: ["all"] }); browser.menus.onClicked.addListener(function(info, tab) { if (info.menuItemId == "remove-me") { var removing = browser.menus.remove(info.menuItemId); removing.then(onRemoved, onError); } });
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
remove |
Yes |
14 |
55
48
|
? |
Yes |
14 |
? |
? |
No |
? |
? |
? |
Note: This API is based on Chromium's chrome.contextMenus
API. This documentation is derived from context_menus.json
in the Chromium code.
© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/menus/remove