Requires the GM.deleteValue
grant or falls back to localStorage.
Deletes a value from a values object.
This is only useful if you're using TypeScript or your editor has typing support.
If that doesn't describe your use case, then use GM.deleteValue
instead
A values object, such as the one returned from getValues
The value to delete
An optional unique identifier for the config. Prefixes all keys with the ID
(eg. foo
-> myconfig.foo
for id myconfig
). This won't change the names of the keys
on the returned object
A Promise that resolves with a new object without the deleted type, or rejects with nothing if the deletion failed
Generate a UserScript metadata comment from an object. Falsey values will be excluded from the banner, so checking if a value is undefined before passing is not necessary.
Properties to add to metadata
The amount of spaces between the @
and the value, including the prop name.
Should be at least 1 greater than the longest prop name
What to put at the start of the banner. Defaults to '// ==UserScript=='
What to put at the end of the banner. Defaults to '// ==/UserScript=='
A block of comments to be put at the top of a UserScript including all of the properties passed
Requires the GM.getValue
and GM.listValues
grants or falls back to using localStorage.
Returns a values object containing every saved value for the UserScript
A Promise that resolves to the defined values or rejects with nothing.
Requires the GM.getValue
grant or falls back to using localStorage.
Retrieves values from GreaseMonkey based on the generic type provided
The default values if they are undefined. Each option will be set to a key from this if it does not exist
An optional unique identifier for the config. Prefixes all keys with the ID
(eg. foo
-> myconfig.foo
for id myconfig
). This won't change the names of the keys
on the returned object
Whether or not to store the default value from the defaults argument
with GM.setValue
if it doesn't exist. Requires the GM.setValue
grant
A Promise that resolves to an object with all of the values
Requires the GM.getValue
grant or falls back to using localStorage.
Get a Proxy that wraps GM.getValue
for better typing.
Useful when a value may be modified by multiple different sources,
meaning the value will need to be retrieved from GM every time.
This should not be used if values are only being modified by one source
A values object, such as the one returned from getValues
An optional unique identifier for the config. Prefixes all keys with the ID
(eg. foo
-> myconfig.foo
for id myconfig
). This won't change the names of the keys
on the returned object
A Proxy using the keys of values
that wraps GM.getValue
Requires the GM.setValue
grant or falls back to using localStorage.
Get a Proxy that automatically updates values.
There should generally only be one Proxy per option (eg. one proxy that controls option1
and option2
and a different one that controls option3
and option4
).
This is because the returned Proxy doesn't update the value on get, only on set.
If multiple Proxies on the same values are being used to set, then a get Proxy
(valuesGetProxy
) to get values might be a good idea
A values object, such as the one from getValues
An optional unique identifier for the config. Prefixes all keys with the ID
(eg. foo
-> myconfig.foo
for id myconfig
). This won't change the names of the keys
on the returned object
Called with the Promise returned by GM.setValue
A Proxy from values
that updates the GM value on set
Make a request with GM.xmlHttpRequest using Promises. Requires the GM.xmlHttpRequest grant
The XHR info
A Promise that resolves with the Greasemonkey Response object
Generated using TypeDoc
Used by functions to check if grants are present