Members
-
constant exportExternalPlugins
-
Exports external IITC core and plugins from the provided storage object.
This function takes a storage object and extracts external IITC core and plugins based on predefined keys. It creates a new object containing the external plugins organized by their channels and filenames, and returns it.
-
constant exportIitcSettings
-
Exports specific IITC settings from the provided storage object.
This function takes a storage object and extracts specific IITC settings based on predefined keys. It creates a new object containing only the specified IITC settings and returns it.
-
constant exportPluginsSettings
-
Exports specific plugin settings from the provided storage object.
This function takes a storage object and extracts plugin settings that have keys starting with the prefix 'VMin'. It creates a new object containing only the plugin settings and returns it.
-
async, constant importExternalPlugins
-
Imports external plugins from the provided backup object.
The function iterates through each channel in the backup object, sets the current channel using
self.setChannel(), and then extracts the plugin information (metadata and code) for each plugin in the channel. The plugin information is added to the 'scripts' array, which is then passed toself.addUserScripts()to add the external plugins. After processing all channels, the function sets the default channel usingself.setChannel()if it was changed during the import process. -
async, constant importIitcSettings
-
Imports IITC settings from the provided backup object.
-
async, constant importPluginsSettings
-
Imports plugin settings from the provided backup object.
The function first retrieves all data from the storage object using
self.storage.get(null)and filters out the records with keys starting with 'VMin' to create a new objectvMinRecordscontaining only plugin-related data. The function then merges thevMinRecordsobject with the provided backup object using thedeepmergelibrary, resulting in a new storage objectnew_storagethat contains updated plugin settings. Finally, the updated storage object is set into the 'self' object usingself.storage.set().
Methods
-
async ajaxGet(url, variantopt) → {Promise.<(string|object|null)>}
-
This is a wrapper over the fetch() API method with pre-built parameters.
Parameters:
Name Type Attributes Default Description urlstring URL of the resource you want to fetch.
variant"parseJSON" | "Last-Modified" | null <optional>
null Type of request: "parseJSON" - Load the resource and parse it as a JSON response. "Last-Modified" - Requests the last modification date of a file. null - Get resource as text.
Returns:
Promise.<(string|object|null)> -
check_matching(meta, url) → {boolean}
-
Checks the URL for match/include plugin.
Parameters:
Name Type Description metaplugin Object with data from ==UserScript== header.
urlstring Page URL.
Returns:
boolean -
check_meta_match_pattern(meta, domainopt) → {boolean}
-
A simple check for a match Ingress sites. Far from implementing all the features of userscripts @match/@include, but sufficient for our needs.
Parameters:
Name Type Attributes Default Description metaplugin Object with data from ==UserScript== header.
domain"<all>" | "intel.ingress.com" | "missions.ingress.com" <optional>
"<all>" domain - One or all domains related to Ingress.
Returns:
boolean -
check_url_match_pattern(url, domainopt) → {boolean}
-
Checks if the accepted URL matches one or all domains related to Ingress.
Parameters:
Name Type Attributes Default Description urlstring URL address.
domain"<all>" | "intel.ingress.com" | "missions.ingress.com" <optional>
"<all>" domain - One or all domains related to Ingress.
Returns:
boolean -
clearWait() → {void}
-
Stops the timer created in wait
Returns:
void -
getUID(plugin) → {string|null}
-
Returns the unique identifier (UID) of plugin, composed of available plugin fields.
Parameters:
Name Type Description pluginplugin Plugin object.
Returns:
string | null -
getUniqId(prefixopt) → {string}
-
Generates a unique random string with prefix.
Parameters:
Name Type Attributes Default Description prefixstring <optional>
"VM" prefix - Prefix string.
Returns:
string -
humanize_match(meta) → {null|string|Array.<string>}
-
Returns information about the domains for which the script will be enabled. Returns null if @match and @include are not specified Returns <all_urls> if the script will be run for all domains. Additional URL Scheme and Path filters are not taken into account. Otherwise, it returns a list of strings with domains.
Parameters:
Name Type Description metaplugin Object with data from ==UserScript== header.
Returns:
null | string | Array.<string> -
isSet(value) → {boolean}
-
Checks if any value is set.
Parameters:
Name Type Description valueany Any value.
Returns:
boolean -
paramsProcessing(params) → {Object}
-
Processes the input parameters for backup data retrieval.
This function takes an input object containing parameters for backup data retrieval and returns a new object with processed parameters. If the input parameters are not an object, an empty object is used as the default value. The function combines the input parameters with default parameters to ensure all required properties are present.
Parameters:
Name Type Description paramsBackupParams The parameters for setting the backup data.
Returns:
Object -The processed parameters object.
-
parseMeta(code) → {Object.<string, string>|null}
-
Parses code of UserScript and returns an object with data from ==UserScript== header.
Parameters:
Name Type Description codestring UserScript plugin with ==UserScript== header.
Returns:
Object.<string, string> | null -
sanitizeFileName(input, maxLength) → {string}
-
Processes a string by removing invalid characters for the file system and limiting its length.
Parameters:
Name Type Description inputstring The original string to be converted into a file name.
maxLengthnumber The maximum length of the file name (default is 255 characters).
Returns:
string -- The processed string.
-
testInclude()
-
Test glob rules like
@includeand@exclude. -
testMatch()
-
Test match rules like
@matchand@exclude_match. -
async wait(seconds) → {Promise.<void>}
-
Sets a timer with a specified number of seconds to wait.
Parameters:
Name Type Description secondsnumber Returns:
Promise.<void>
Type Definitions
-
BackupParams
-
Parameters for retrieving backup data.
Properties:
Name Type Description settingsboolean Whether to import/export IITC settings.
databoolean Whether to import/export plugins' data.
externalboolean Whether to import/export external plugins.
-
plugin
-
URLs of repositories with IITC and plugins for different release branches
Properties:
Name Type Attributes Description uidstring Unique identifier (UID) of plugin. Created by lib-iitc-manager.
idstring namestring authorstring categorystring versionstring descriptionstring namespacestring statusstring codestring userboolean overrideboolean matchArray.<string> includeArray.<string> exclude-matchArray.<string> excludeArray.<string> requireArray.<string> grantArray.<string> addedAtnumber <optional>
Unix timestamp of when the external plugin was first added. Only for external plugins.
statusChangedAtnumber <optional>
Unix timestamp of when the plugin's status (on/off) was last changed.
updatedAtnumber <optional>
Unix timestamp of when the plugin's code was last updated.