Skip to content

Commit

Permalink
doc: GM_getValues, GM_setValues, GM_deleteValues
Browse files Browse the repository at this point in the history
  • Loading branch information
tophf committed Jun 19, 2024
1 parent 1455e1a commit 7cce4fd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ declare type VMScriptRunAt = 'document-start' | 'document-body' | 'document-end'
/** Injection mode of a script. */
declare type VMScriptInjectInto = 'auto' | 'page' | 'content';

declare type GenericObject = Record<string, unknown>;

declare interface VMScriptGMInfoPlatform {
arch: 'arm' | 'arm64' | 'x86-32' | 'x86-64' | 'mips' | 'mips64';
/** @alias browserBrand
Expand Down Expand Up @@ -93,10 +95,14 @@ declare function GM_log(...args: any): void;

/** Retrieves a value for current script from storage. */
declare function GM_getValue<T>(name: string, defaultValue?: T): T;
declare function GM_getValues(names: string[]): GenericObject;
declare function GM_getValues(namesWithDefaults: GenericObject): GenericObject;
/** Sets a key / value pair for current script to storage. */
declare function GM_setValue<T>(name: string, value: T): void;
declare function GM_setValues(values: GenericObject): void;
/** Deletes an existing key / value pair for current script from storage. */
declare function GM_deleteValue(name: string): void;
declare function GM_deleteValues(names: string[]): void;
/** Returns an array of keys of all available values within this script. */
declare function GM_listValues(): string[];

Expand Down Expand Up @@ -438,12 +444,17 @@ declare interface VMScriptGMObjectVMExtensions {
addElement: typeof GM_addElement;
addStyle: typeof GM_addStyle;
addValueChangeListener: typeof GM_addValueChangeListener;
deleteValues: (names: string[]) => Promise<void>;
download:
((options: VMScriptGMDownloadOptions) => (Promise<Blob> | void)) |
((url: string, name: string) => (Promise<Blob> | void));
getResourceText: typeof GM_getResourceText;
getValues:
((names: string[]) => Promise<GenericObject>) |
((namesWithDefaults: GenericObject) => Promise<GenericObject>);
log: typeof GM_log;
removeValueChangeListener: typeof GM_removeValueChangeListener;
setValues: (values: GenericObject) => Promise<void>;
unregisterMenuCommand: typeof GM_unregisterMenuCommand;
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@violentmonkey/types",
"version": "0.1.7",
"version": "0.1.8",
"description": "Type declaration for GM functions in Violentmonkey",
"author": "Gerald <[email protected]>",
"main": "index.js",
Expand Down

0 comments on commit 7cce4fd

Please sign in to comment.