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.