Module

Module

A Toolbox feature module that can be enabled and disabled by the user.

Constructor

new Module(options, initializer)

Description:
  • Defines a module.

Source:
Parameters:
Name Type Description
options object
Properties
Name Type Attributes Default Description
name string

The human-readable name of the module

id string

The ID of the module, used for storage keys

enabledByDefault boolean <optional>
false

If true, the module will be enabled on fresh installs

alwaysEnabled boolean <optional>
false

If true, the module cannot be disabled

beta boolean <optional>
false

If true, the module will only show up in beta builds

debug boolean <optional>
false

If true, the module will only show up when debug mode is enabled

oldReddit boolean <optional>
false

If true, the module will be marked as an Old Reddit-only module in the settings interface (does not affect execution of the module's initializer)

settings Array.<SettingDefinition> <optional>
[]

Module settings

initializer function

The module's entry point, run automatically when Toolbox loads with the module is enabled

Classes

Module

Members

alwaysEnabled

Source:
Properties:
Name Type Description
alwaysEnabled boolean

If true, the module cannot be disabled

beta

Source:
Properties:
Name Type Description
beta boolean

If true, the module will only show up when beta mode is enabled

debugMode

Source:
Properties:
Name Type Description
debugMode boolean

If true, the module will only show up when debug mode is enabled

enabledByDefault

Source:
Properties:
Name Type Description
enabledByDefault boolean

If true, the module will be enabled on fresh installs

id

Source:
Properties:
Name Type Description
id string

The ID of the module, used for storage keys

initializer

Source:
Properties:
Name Type Description
initializer function

The module's entry point, run automatically when Toolbox loads with the module is enabled

name

Source:
Properties:
Name Type Description
name string

The human-readable name of the module

oldReddit

Source:
Properties:
Name Type Description
oldReddit boolean

If true, the module will be marked as an Old Reddit-only module in the settings interface (does not affect execution of the module's initializer)

settings

Source:
Properties:
Name Type Description
settings Map.<string, SettingDefinition>

Module settings

Methods

(async) get(id) → {Promise.<any>}

Description:
  • Gets the value of a setting.

Source:
Parameters:
Name Type Description
id string

The ID of the setting to get

Returns:

Resolves to the current value of the setting

Type
Promise.<any>

(async) getEnabled() → {Promise.<boolean>}

Description:
  • Check whether or not the module is enabled.

Source:
Returns:

Resolves to whether the module is enabled

Type
Promise.<boolean>

(async) init() → {Promise.<void>}

Description:
  • "Starts" the module by calling its initializer.

Source:
Returns:

Resolves when the initializer is completed

Type
Promise.<void>

set(id, value) → {Promise.<any>}

Description:
  • Sets the value of a setting.

Source:
Parameters:
Name Type Description
id string

The ID of the setting to get

value any

The new setting value

Returns:

Resolves to the new value when complete

Type
Promise.<any>

setEnabled(enabled) → {Promise.<boolean>}

Description:
  • Enables or disables the module. This does not take effect until Toolbox is reloaded.

Source:
Parameters:
Name Type Description
enabled boolean

True to enable the module, false to disable it

Throws:

when trying to disable a module that cannot be

Type
Error
Returns:

Resolves to the new enable state

Type
Promise.<boolean>