Skip to content

Commit

Permalink
doc: use TypeDetail to render from types
Browse files Browse the repository at this point in the history
  • Loading branch information
gera2ld committed Jan 13, 2025
1 parent 7fe7227 commit 1260c92
Showing 1 changed file with 1 addition and 86 deletions.
87 changes: 1 addition & 86 deletions content/pages/api/gm.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -33,92 +33,7 @@ It is useful when [`@grant`](/api/metadata-block/#grant) is declared with anythi

### GM_info

An object that exposes information about the current userscript. It has following properties:

- <Field name="uuid" type="string" />

A unique ID of the script.

- <Field name="scriptMetaStr" type="string" />

The meta block of the script.

- <Field name="scriptWillUpdate" type="boolean" />

Whether the script will be updated automatically.

- <Field name="scriptHandler" type="string" />

The name of userscript manager, which should be the string `Violentmonkey`.

- <Field name="version" type="string" />

Version of Violentmonkey.

- <Field name="isIncognito" type="boolean" comment="since VM2.15.4" />

True when this is an incognito profile (Chrome) or private mode (Firefox).

- <Field name="platform" type="object" comment="since VM2.12.4" />

Unlike `navigator.userAgent`, which can be overridden by other extensions/userscripts or by devtools in device-emulation mode, `GM_info.platform` is more reliable as the data is obtained in the background page of Violentmonkey using a specialized extension API (browser.runtime.getPlatformInfo and getBrowserInfo).

- <Field name="arch" type="string" />

One of "arm", "mips", "mips64", "x86-32", "x86-64".

- <Field name="browserName" type="string" />

"chrome", "firefox" or whatever was returned by the API.

- <Field name="browserVersion" type="string" />

- <Field name="fullVersionList" type="{brand: string, version: string}[]" comment="since VM2.27.0" />

A safe copy from `navigator.userAgentData.getHighEntropyValues()` (Chromium 90+).

- <Field name="mobile" type="boolean" comment="since VM2.27.0" />

A safe copy from `navigator.userAgentData` (Chromium 90+).

- <Field name="os" type="string" />

One of "android", "cros", "linux", "mac", "openbsd", "win".

- <Field name="userAgent" type="string" comment="since VM2.20.2" />

A safe copy of `navigator.userAgent` from the content script of the extension, so it cannot be overridden by other extensions/userscripts, but unlike `GM_info.platform` it can be customized in devtools "device emulation" or "network conditions" for this tab.

- <Field name="userAgentData" type="object" comment="since VM2.20.2" />

A safe copy of `navigator.userAgentData` from the content script of the extension, so it cannot be overridden by other extensions/userscripts, but unlike `GM_info.platform` it can be customized in devtools "device emulation" or "network conditions" for this tab.

Only present if the browser actually implements it ([currently](https://caniuse.com/mdn-api_navigator_useragentdata) Chromium-based 90+), because there's no reliable/official polyfill.

- <Field name="brands" type="Array<{brand: string, version: string}>" />
- <Field name="mobile" type="boolean" />
- <Field name="platform" type="string" />
- <Field name="getHighEntropyValues" type="(hints: string[]) => Promise<Object>" />

Violentmonkey implements the [official API](https://developer.mozilla.org/en-US/docs/Web/API/NavigatorUAData), including [getHighEntropyValues](https://developer.mozilla.org/en-US/docs/Web/API/NavigatorUAData/getHighEntropyValues) function to obtain the extra info asynchronously.

- <Field name="script" type="object" />

Contains structured fields from the [Metadata Block](../metadata-block/):

- <Field name="description" type="string" />
- <Field name="excludes" type="string[]" />
- <Field name="includes" type="string[]" />
- <Field name="matches" type="string[]" />
- <Field name="name" type="string" />
- <Field name="namespace" type="string" />
- <Field name="resources" type="Array<{name, url}>" />
- <Field name="runAt" type="string" />
- <Field name="version" type="string" />

- <Field name="injectInto" type="string" comment="since VM2.10.0" />

The injection mode of current script. See [`@inject-into`](/api/metadata-block/#inject-into) for more information.
<TypeDetail name="GM_info" />

### GM_getValue

Expand Down

0 comments on commit 1260c92

Please sign in to comment.