action.getUserSettings()

Gets the user-specified settings for the browser action.

Note: This API is available in Manifest V3 or higher.

This is an asynchronous function that returns a Promise.

Syntax

js
let userSettings = await browser.action.getUserSettings();

Parameters

This function takes no parameters.

Return value

A Promise that fulfills with an object with these properties:

userSettings

An object containing the user-specified settings for the browser action with these properties:

isOnToolbar Optional

boolean. Whether the user has pinned the action's icon to the browser UI. This setting does not indicate whether the action icon is visible. The icon's visibility depends on the size of the browser window and the layout of the browser UI.

Examples

This code logs a message indicating whether the action is pinned or not:

js
function gotSettings(userSettings) {
  if (userSettings.isOnToolbar) {
    console.log("Action is pinned to toolbar.");
  } else {
    console.log("Action is not pinned to toolbar.");
  }
}

let gettingUserSettings = browser.action.getUserSettings();
gettingUserSettings.then(gotSettings);

Browser compatibility

BCD tables only load in the browser

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