getAll()

Gets all commands for the extension that you have registered using the commands manifest.json key.

The commands are returned as an array of commands.Command objects. Alternately, if you are using the promise-based version of the API, browser.commands.getAll(), the commands are passed into the onFulfilled argument to Promise.then().

Syntax

js
let getCommands = browser.commands.getAll();

Parameters

None.

Return value

A Promise that will be fulfilled with an array of commands.Command objects, one for each command registered for the extension. If no commands were registered, the array will be empty.

Examples

js
function logCommands(commands) {
  commands.forEach((command) => {
    console.log(command);
  });
}

let getCommands = browser.commands.getAll();
getCommands.then(logCommands);

Example extensions

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Firefox for Android
Safari on iOS
getAll
Chrome – Full support
Chrome 58 (Release date: 2017-04-19)
footnote Full support
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote Full support
Firefox – Full support
Firefox 48 (Release date: 2016-08-02)
footnote Full support
Opera – Full support
Opera 45 (Release date: 2017-05-10)
footnote Full support
Safari – Full support
Safari 14 (Release date: 2020-09-16)
footnote Full support
Firefox for Android – No support
Firefox for Android
footnote No support
Safari on iOS – Full support
Safari on iOS 15 (Release date: 2021-09-20)
footnote Full support

Legend

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

Full support
Full support
No support
No support

Note: This API is based on Chromium's chrome.commands API.