addon.settings

Available in userscripts✔️
Available in popup scripts✔️
Required manifest permissionsNone

Description

Allows addons to change their behavior according to user-specified addon settings.

Examples

Reacting to settings change

addon.settings.addEventListener("change", function() {
  console.log("Settings changed!");
  if(addon.settings.get("removeIdeasBtn") === true && tipsButtonShown === false) showTipsButton();
  else if(addon.settings.get("removeIdeasBtn") === false && tipsButtonShown === true) hideTipsButton();
});

Methods

addon.settings.get

ParameterTypeRequiredDescription
settingIdStringYesSetting ID to retrieve.
Return valueString | Number | Boolean
Throws ifThe given setting ID wasn't declared in the addon manifest.

Returns the user-specified value for a provided setting ID.
The return value will depend on the setting type:

Setting typeReturn typeExample value
booleanBooleantrue
positive_integerNumber0
integerNumber-2
stringString"abc"
colorString"#aabbcc"
selectString"potentialValueId"

This method is guaranteed to return the valid type. null is never returned.

Events

change

Fires when any of the addon’s settings have changed.


Last updated at 22 April 2022 by RedGuy12 on commit 686f6b7. Improve this page.

Comments

Make sure to follow the code of conduct. You can see this comment section on GitHub Discussions, as well as editing and removing your comment.