menus.removeAll()

Removes all menu items added by the extension.

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.

Syntax

js
let removing = browser.menus.removeAll()

Parameters

None.

Return value

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

Examples

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

js
function onRemoved() {
  console.log("items removed successfully");
}

browser.menus.create({
  id: "click-me",
  title: "Click me!",
  contexts: ["all"],
});

browser.menus.create({
  id: "remove-all",
  title: "Remove all!",
  contexts: ["all"],
});

browser.menus.onClicked.addListener((info, tab) => {
  if (info.menuItemId === "remove-all") {
    let removing = browser.menus.removeAll();
    removing.then(onRemoved);
  }
});

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Firefox for Android
Safari on iOS
removeAll
Chrome – Full support
Chrome 6 (Release date: 2010-09-02)
altname
altname Alternate name: contextMenus.removeAll
Edge – Full support
Edge 79 (Release date: 2020-01-15)
altname
altname Alternate name: contextMenus.removeAll
Firefox – Full support
Firefox 48 (Release date: 2016-08-02)
altname
altname Alternate name: contextMenus.removeAll
Firefox – Full support
Firefox 55 (Release date: 2017-08-08)
footnote Full support
Opera – Full support
Opera 15 (Release date: 2013-07-02)
altname
altname Alternate name: contextMenus.removeAll
Safari – Full support
Safari 14 (Release date: 2020-09-16)
altname
altname Alternate name: contextMenus.removeAll
Firefox for Android – No support
Firefox for Android
footnote No support
Safari on iOS – No support
Safari on iOS
footnote No support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
Uses a non-standard name
Has more compatibility info.

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