Manager()

This class contains methods for managing IITC and plugins.

new Manager()

Methods

async addUserScripts(scripts) → {Promise.<Object.<string, plugin>>}

Allows adding third-party UserScript plugins to IITC. Returns the dictionary of installed or updated plugins.

Parameters:
Name Type Description
scripts Array.<Object>

Array of UserScripts.

Properties
Name Type Description
meta plugin

Parsed "meta" object of UserScript.

code string

UserScript code.

Returns:
Promise.<Object.<string, plugin>>

async checkUpdates(forceopt) → {Promise.<void>}

Runs periodic checks and installs updates for IITC, internal and external plugins.

Parameters:
Name Type Attributes Default Description
force boolean <optional>
false

Forced to run the update right now.

Returns:
Promise.<void>

async getBackupData(params) → {Promise.<object>}

Asynchronously retrieves backup data based on the specified parameters.

Parameters:
Name Type Description
params BackupParams

The parameters for the backup data retrieval.

Returns:
Promise.<object> -

A promise that resolves to the backup data.

async getEnabledPlugins() → {Promise.<Object>}

Returns an object of all enabled plugins, including IITC core, with plugin UID as the key and plugin data as the value.

Returns:
Promise.<Object> -

A promise that resolves to an object containing enabled plugins and IITC core data.

async getIITCCore(storageopt, channelopt) → {Promise.<(plugin|null)>}

Returns IITC core script.

Parameters:
Name Type Attributes Description
storage Object | undefined <optional>

Storage object with keys channel_iitc_core and channel_iitc_core_user. If not specified, the data is queried from the storage.

channel "release" | "beta" | "custom" | undefined <optional>

Current channel. If not specified, the current channel is used.

Returns:
Promise.<(plugin|null)>

async getPluginInfo(uid) → {Promise.<(plugin|null)>}

Returns information about requested plugin by UID.

Parameters:
Name Type Description
uid string

Plugin UID.

Returns:
Promise.<(plugin|null)>

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

Invokes the injection of IITC core script and plugins to the page. IITC core is injected first to ensure it initializes before any plugins. This is crucial because the initialization of IITC takes some time, and during this time, plugins can be added to window.bootPlugins without being started immediately. Injecting IITC first also prevents plugins from throwing errors when attempting to access IITC, leaflet, or other dependencies during their initialization.

Returns:
Promise.<void>

async managePlugin(uid, action) → {Promise.<void>}

Controls the plugin. Allows you to enable, disable and remove the plugin.

Parameters:
Name Type Description
uid string

Unique identifier of the plugin.

action "on" | "off" | "delete"

Type of action with the plugin.

Returns:
Promise.<void>

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

Running the IITC and plugins manager. Migrates data storage as needed, then loads or updates UserScripts from the repositories.

Returns:
Promise.<void>

async setBackupData(params, backup_data) → {Promise.<void>}

Asynchronously sets backup data based on the specified parameters.

This function takes the provided parameters and backup data object and sets the data accordingly. The input parameters are processed using the 'paramsProcessing' function from the 'backup' module. Depending on the parameters, the function imports IITC settings, plugin data, and external plugins into the 'this' object using appropriate functions from the 'backup' module.

Parameters:
Name Type Description
params BackupParams

The parameters for setting the backup data.

backup_data object

The backup data object containing the data to be set.

Returns:
Promise.<void> -

A promise that resolves when the backup data is set.

async setChannel(channel) → {Promise.<void>}

Changes the update channel and calls for an update.

Parameters:
Name Type Description
channel "release" | "beta" | "custom"

Update channel for IITC and plugins.

Returns:
Promise.<void>

async setCustomChannelUrl(url) → {Promise.<void>}

Changes the URL of the repository with IITC and plugins for the custom channel.

Parameters:
Name Type Description
url string

URL of the repository.

Returns:
Promise.<void>

async setUpdateCheckInterval(interval, channelopt) → {Promise.<void>}

Changes the update check interval. If the interval for the current channel changes, a forced update check is started to apply the new interval.

Parameters:
Name Type Attributes Description
interval number

Update check interval in seconds.

channel "release" | "beta" | "custom" | undefined <optional>

Update channel for IITC and plugins. If not specified, the current channel is used.

Returns:
Promise.<void>