forked from mdn/content
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding details for browserAction.getUserSettings (mdn#31975)
* Adding details for browserAction.getUserSettings * Apply suggestions from review Co-authored-by: Rob Wu <[email protected]> * Linter suggestion Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --------- Co-authored-by: Rob Wu <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
8965b36
commit 05808d3
Showing
3 changed files
with
59 additions
and
1 deletion.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
.../en-us/mozilla/add-ons/webextensions/api/browseraction/getusersettings/index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters