addon.settings

Available in userscripts ✔️
Available in popup scripts ✔️
Required manifest permissions None

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

Parameter Type Required Description
settingId String Yes Setting ID to retrieve.
Return value String | Number | Boolean
Throws if The 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 type Return type Example value
boolean Boolean true
positive_integer Number 0
integer Number -2
string String "abc"
color String "#aabbcc"
select String "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.