Interface VMScriptGMInfoObject

interface VMScriptGMInfoObject {
    injectInto: VMScriptInjectInto;
    isIncognito: boolean;
    platform: VMScriptGMInfoPlatform;
    script: VMScriptGMInfoScriptMeta;
    scriptHandler: string;
    scriptMetaStr: string;
    scriptWillUpdate: boolean;
    userAgent: string;
    userAgentData?: {
        brands: { brand: string; version: string }[];
        mobile: boolean;
        platform: string;
        getHighEntropyValues(hints: string[]): Promise<UADataValues>;
    };
    uuid: string;
    version: string;
}

Properties

injectInto: VMScriptInjectInto

The injection mode of current script. See @inject-into for more information.

isIncognito: boolean

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

VM2.15.4

Unlike navigator.userAgent, which can be overriden 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).

Contains structured fields from the Metadata Block.

scriptHandler: string

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

scriptMetaStr: string

The meta block of the script.

scriptWillUpdate: boolean

Whether the script will be updated automatically.

userAgent: string

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.

VM2.20.2

userAgentData?: {
    brands: { brand: string; version: string }[];
    mobile: boolean;
    platform: string;
    getHighEntropyValues(hints: string[]): Promise<UADataValues>;
}

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 Chromium-based 90+), because there's no reliable/official polyfill.

Violentmonkey implements the official API, including getHighEntropyValues function to obtain the extra info asynchronously.

VM2.20.2

uuid: string

A unique ID of the script.

version: string

Version of Violentmonkey.