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 objectvMinRecords
containing only plugin-related data. The function then merges thevMinRecords
object with the provided backup object using thedeepmerge
library, resulting in a new storage objectnew_storage
that 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 url
string 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 meta
plugin Object with data from ==UserScript== header.
url
string 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 meta
plugin 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 url
string 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 plugin
plugin Plugin object.
Returns:
string | null -
getUniqId(prefixopt) → {string}
-
Generates a unique random string with prefix.
Parameters:
Name Type Attributes Default Description prefix
string <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 meta
plugin Object with data from ==UserScript== header.
Returns:
null | string | Array.<string> -
isSet(value) → {boolean}
-
Checks if any value is set.
Parameters:
Name Type Description value
any 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 params
BackupParams 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 code
string 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 input
string The original string to be converted into a file name.
maxLength
number The maximum length of the file name (default is 255 characters).
Returns:
string -- The processed string.
-
testInclude()
-
Test glob rules like
@include
and@exclude
. -
testMatch()
-
Test match rules like
@match
and@exclude_match
. -
async wait(seconds) → {Promise.<void>}
-
Sets a timer with a specified number of seconds to wait.
Parameters:
Name Type Description seconds
number Returns:
Promise.<void>
Type Definitions
-
BackupParams
-
Parameters for retrieving backup data.
Properties:
Name Type Description settings
boolean Whether to import/export IITC settings.
data
boolean Whether to import/export plugins' data.
external
boolean Whether to import/export external plugins.
-
plugin
-
URLs of repositories with IITC and plugins for different release branches
Properties:
Name Type Attributes Description uid
string Unique identifier (UID) of plugin. Created by lib-iitc-manager.
id
string name
string author
string category
string version
string description
string namespace
string status
string code
string user
boolean override
boolean match
Array.<string> include
Array.<string> exclude-match
Array.<string> exclude
Array.<string> require
Array.<string> grant
Array.<string> addedAt
number <optional>
Unix timestamp of when the external plugin was first added. Only for external plugins.
statusChangedAt
number <optional>
Unix timestamp of when the plugin's status (on/off) was last changed.
updatedAt
number <optional>
Unix timestamp of when the plugin's code was last updated.