userscript

Description

Wrappers for dealing with variations in userscript managers.

Depends on:

Details

18

Classes


new LoggerConfigSaver( key )

Methods


<static> licenseData() → {NexusHoratio.userscript~LicenseData}

Description

Per some old GM docs, this extracts @license information from the userscript header.

Returns

Extracted information.

Throws

If cannot be extracted.

Details

<static> environmentData() → {Array.<string>}

Description

Gathers information about the current runtime.

This is mostly useful for logging and when providing feedback.

Returns

Raw text about the current environment.

Details

<static> getValue( key, defaultValue ) → {Promise.<object>}

Description

Fetches value from userscript storage, if granted permission.

Purposefully no errors if permissions are not granted.

// Enable in the ==UserScript== header with:
			// @grant GM.getValue
			
Parameters
Name Type Description
key string

The name of the value to load.

defaultValue object

Value if not stored OR not enabled.

Returns

The value fetched or defaultValue.

Details

<static> setValue( key, value ) → {Promise.<object>}

Description

Sets a value in userscript storage, if granted permission.

Purposefully no errors if permissions are not granted.

// Enable in the ==UserScript== header with:
			// @grant GM.setValue
			
Parameters
Name Type Description
key string

The name to use in the storage.

value object

The value to set.

Returns

Always resolves to null; mostly used to ensure the write is complete.

Details

<async, static> setAutoManageLoggerConfigs( state [, key ] )

Description

Control persistent saving of Logger configuration in userscript storage.

Call once near the top of the userscript to enable.

Requires several userscript grants for full capabilities.

// Enable in the ==UserScript== header with:
			// @grant GM.getValue
			// @grant GM.setValue
			// @grant GM.addValueChangeListener
			// @grant GM.removeValueChangeListener
			
Parameters
Name Type Attributes Default Description
state boolean

Enables/disables the feature.

key string <optional>
'Logger'

The key to use in userscript storage.

Type Definitions


LicenseData

Properties
Name Type Description
name string

License name.

id string

SPDX id (fka name).

url string

URL pointing to the license.

Details
object

<p>Replace use of the <code>name</code> property with <code>id</code>.</p>