diff --git a/files/en-us/mozilla/add-ons/webextensions/api/browseraction/getusersettings/index.md b/files/en-us/mozilla/add-ons/webextensions/api/browseraction/getusersettings/index.md new file mode 100644 index 000000000000000..532411b5589371c --- /dev/null +++ b/files/en-us/mozilla/add-ons/webextensions/api/browseraction/getusersettings/index.md @@ -0,0 +1,56 @@ +--- +title: browserAction.getUserSettings() +slug: Mozilla/Add-ons/WebExtensions/API/browserAction/getUserSettings +page-type: webextension-api-function +browser-compat: webextensions.api.browserAction.getUserSettings +--- + +{{AddonSidebar}} + +Gets the user-specified settings for the browser action. + +This is an asynchronous function that returns a [`Promise`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise). + +## Syntax + +```js-nolint +let userSettings = await browser.browserAction.getUserSettings(); +``` + +### Parameters + +This function takes no parameters. + +### Return value + +A [`Promise`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/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_inline}} + - : `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 browser action is pinned or not: + +```js +function gotSettings(userSettings) { + if (userSettings.isOnToolbar) { + console.log("Browser action is pinned to toolbar."); + } else { + console.log("Browser action is not pinned to toolbar."); + } +} + +let gettingUserSettings = browser.browserAction.getUserSettings(); +gettingUserSettings.then(gotSettings); +``` + +{{WebExtExamples}} + +## Browser compatibility + +{{Compat}} diff --git a/files/en-us/mozilla/add-ons/webextensions/api/browseraction/index.md b/files/en-us/mozilla/add-ons/webextensions/api/browseraction/index.md index e33ac6b037e42f5..6aa0a8e1f816f35 100644 --- a/files/en-us/mozilla/add-ons/webextensions/api/browseraction/index.md +++ b/files/en-us/mozilla/add-ons/webextensions/api/browseraction/index.md @@ -57,6 +57,8 @@ With the `browserAction` API, you can: - : Sets the badge's text color. - {{WebExtAPIRef("browserAction.getBadgeTextColor()")}} - : Gets the badge's text color. +- {{WebExtAPIRef("browserAction.getUserSettings()")}} + - : Gets the user-specified settings for the browser action. - {{WebExtAPIRef("browserAction.enable()")}} - : Enables the browser action for a tab. By default, browser actions are enabled for all tabs. - {{WebExtAPIRef("browserAction.disable()")}} diff --git a/files/en-us/mozilla/firefox/releases/116/index.md b/files/en-us/mozilla/firefox/releases/116/index.md index bb7e56af1811903..567270e133e861d 100644 --- a/files/en-us/mozilla/firefox/releases/116/index.md +++ b/files/en-us/mozilla/firefox/releases/116/index.md @@ -72,7 +72,7 @@ This article provides information about the changes in Firefox 116 that affect d ## Changes for add-on developers - The URL of a page visited when an extension is uninstalled, provided in {{WebExtAPIRef("runtime.setUninstallURL")}}, can now be up to 1023 characters instead of 255 ([Firefox bug 1835723](https://bugzil.la/1835723)). -- Adds {{WebExtAPIRef("action.getUserSettings")}} providing the user-specified settings for an extension's browser action ([Firefox bug 1814905](https://bugzil.la/1814905)). +- Adds {{WebExtAPIRef("action.getUserSettings")}} and {{WebExtAPIRef("browserAction.getUserSettings")}} providing the user-specified settings for an extension's browser action ([Firefox bug 1814905](https://bugzil.la/1814905)). - `autoDiscardable` is now supported in {{WebExtAPIRef("tabs.Tab")}}, {{WebExtAPIRef("tabs.onUpdated")}}, {{WebExtAPIRef("tabs.update")}}, and {{WebExtAPIRef("tabs.query")}} ([Firefox bug 1809094](https://bugzil.la/1809094)). ## Developer Tools