DefinitelyTyped

Index

Variables

Interfaces

Functions

Variables

GM_info: { script: { description: string; excludes: string[]; includes: string[]; matches: string[]; name: string; namespace: string; resources: Object; "run-at": string; unwrap: boolean; version: string; }; scriptMetaStr: string; scriptWillUpdate: boolean; version: string; }

Meta data about the running user script.

see

{@link http://wiki.greasespot.net/GM_info}

public GM_info.script: { description: string; excludes: string[]; includes: string[]; matches: string[]; name: string; namespace: string; resources: Object; "run-at": string; unwrap: boolean; version: string; }

public GM_info.scriptMetaStr: string

public GM_info.scriptWillUpdate: boolean

public GM_info.version: string

public script.description: string

public script.excludes: Array<string>

public script.includes: Array<string>

public script.matches: Array<string>

public script.name: string

public script.namespace: string

public script.resources: Object

public script.run-at: string

public script.unwrap: boolean

public script.version: string

unsafeWindow: Window

Window object of the content page where the user script is running on.

see

{@link http://wiki.greasespot.net/UnsafeWindow}

Functions

GM_addStyle(css: string)

Adds CSS to the content page.

see

{@link http://wiki.greasespot.net/GM_addStyle}

Parameters

  • css: string

    a CSS string. It can have multiple style definitions.

GM_deleteValue(name: string)

Deletes an existing name / value pair from the script storage.

see

{@link http://wiki.greasespot.net/GM_deleteValue}

Parameters

  • name: string

    a name of the pair to delete.

GM_getResourceText(resourceName: string): string

Gets a content of a resouce defined by {@link http://wiki.greasespot.net/Metadata_Block#.40resource|@resource}.

see

{@link http://wiki.greasespot.net/GM_getResourceText}

Parameters

  • resourceName: string

    a name of the resource to get.

Returns

string

the content of the resource.

GM_getResourceURL(resourceName: string): string

Gets a URL of a resource defined by {@link http://wiki.greasespot.net/Metadata_Block#.40resource|@resource}.

see

{@link http://wiki.greasespot.net/GM_getResourceURL}

Parameters

  • resourceName: string

    a name of the resource.

Returns

string

a URL that returns the content of the resource.

GM_getValue(name: string, defaultValue?: any): any

Retrieves a value from the script storage.

see

{@link http://wiki.greasespot.net/GM_getValue}

Parameters

  • name: string

    a name to retrieve.

  • defaultValue?: any optional

    a value to be returned when the name does not exist.

Returns

any

a retrieved value, or passed default value, or undefined.

GM_getValue(name: string, defaultValue?: string): string

Parameters

  • name: string
  • defaultValue?: string optional

Returns

string

GM_getValue(name: string, defaultValue?: number): number

Parameters

  • name: string
  • defaultValue?: number optional

Returns

number

GM_getValue(name: string, defaultValue?: boolean): boolean

Parameters

  • name: string
  • defaultValue?: boolean optional

Returns

boolean

GM_listValues(): Array<string>

Retrieves an array of names stored in the script storage.

see

{@link http://wiki.greasespot.net/GM_listValues}

Returns

Array<string>

an array of names in the storage.

GM_log(message: any)

Writes a message as a log to the console with the script identifier.

see

{@link http://wiki.greasespot.net/GM_log}

Parameters

  • message: any

    a message to be written.

GM_openInTab(url: string): Window

Opens a URL in a new tab.

see

{@link http://wiki.greasespot.net/GM_openInTab}

Parameters

  • url: string

    a URL to open.

Returns

Window

window object of the opened tab.

GM_registerMenuCommand(caption: string, commandFunc: Function, accessKey?: string)

Registers an item as a submenu of User Script Commands.

see

{@link http://wiki.greasespot.net/GM_registerMenuCommand}

Parameters

  • caption: string

    a caption of the menu item.

  • commandFunc: Function

    a function to be invoked when the item has been selected.

  • accessKey?: string optional

    a single character that can be used to select the item by keyboard. It should be a letter in the caption.

GM_setClipboard(text: string)

Sets a text to the clipboard of the opeating system.

see

{@link http://wiki.greasespot.net/GM_setClipboard}

Parameters

  • text: string

    a text to be set to the clipboard.

GM_setValue(name: string, value: string)

Stores a name / value pair to the script storage.

see

{@link http://wiki.greasespot.net/GM_setValue}

Parameters

  • name: string

    a name of the pair.

  • value: string

    a value to be stored.

GM_setValue(name: string, value: boolean)

Parameters

  • name: string
  • value: boolean

GM_setValue(name: string, value: number)

Parameters

  • name: string
  • value: number

GM_xmlhttpRequest(options: GMXMLHttpRequestOptions): GMXMLHttpRequestResult

Sends a HTTP request to a URL.

see

{@link http://wiki.greasespot.net/GM_setClipboard}

Parameters

Returns

GMXMLHttpRequestResult

an object which can abort the request. If the request is sent in the synchronous mode, it also contains the response information.