settings.js
API
The settings.js
API works in conjunction with settings.html
and settings.json
to deliver a customizable experience to the user.
Using Node.js Modules in settings.js
From within the settings.js
script you can require
any Node.js module that is a dependency in Somiibo.
Visit somiibo://developer and go to the "Using Node.js Modules" tab to see the currently supported modules.
settings.html
Skeleton File
The settings
library is the first argument passed to the exported function, so as seen here, the variable settings
is used to access the settings.js
API.
Want to see a full example?
You can download a fully working Module Package from our examples repo on GitHub.API
Discover the settings.js
API
Methods
Flow controls the initialization and looping of the module.
somiibo.getAll()
returns
<Object> The current settings as an object
Get the user's current settings as an object where each key is the setting name and the value is the setting value.
somiibo.getUser()
returns
<Object> The current user as an object with the following keysauth
<Object>uid
<string> The user's UID, a unique identifier for each userplan
<Object>id
<string> The plan id which can be eitherbasic
orpremium
roles
<Object>betaTester
<boolean>true
if the user is a beta testerdeveloper
<boolean>true
if the user is a developeradmin
<boolean>true
if the user is an administrator
Get the user's current settings as an object where each key is the setting name and the value is the setting value.
somiibo.getTab()
returns
<Object> The current tab as an object with the following keysproxy
<boolean> Whether or not the tab has a proxysession
<string> The ID of the current SessionuserAgent
<string> The user agent of the tab
Get information about the current tab such as its proxy
, session
ID, and the userAgent
Events
event: 'change'
event
<Event> The generic eventname
<string> The name of the changed settingvalue
<any> The value of the changed settingtarget
<ElementHandle> The element that the edit occurred on
Emitted when the module.js script encounters a fatal change. The default behavior is to stop the module and display an change to the user but this can be prevented with event.preventDefault()
. Usually (but not always), navigation changes can be recovered from and calling event.preventDefault()
is advised.
event: 'submit'
event
<Event> The generic eventdata
<Object> The settings as an object
Emitted when the settings are saved by the user. Any changes made to the data
object will overwrite the user's settings.
The default behavior of the submit
event is to continue with the save but you can prevent this behavior by returning a custom object like so: