Skip to content

Commit 71ba481

Browse files
committed
doc: GM_info.userAgent/userAgentData
1 parent cfe3724 commit 71ba481

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

content/api/gm.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,23 @@ An object that exposes information about the current userscript. It has followin
8484

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

87+
- <Field name="userAgent" type="string" comment="since VM2.20.2" />
88+
89+
A safe copy of `navigator.userAgent` from the content script of the extension, so it cannot be overriden by other extensions/userscripts, but unlike `GM_info.platform` it can be customized in devtools "device emulation" or "network conditions" for this tab.
90+
91+
- <Field name="userAgentData" type="object" comment="since VM2.20.2" />
92+
93+
A safe copy of `navigator.userAgentData` from the content script of the extension, so it cannot be overriden by other extensions/userscripts, but unlike `GM_info.platform` it can be customized in devtools "device emulation" or "network conditions" for this tab.
94+
95+
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.
96+
97+
- <Field name="brands" type="Array<{brand: string, version: string}>" />
98+
- <Field name="mobile" type="boolean" />
99+
- <Field name="platform" type="string" />
100+
- <Field name="getHighEntropyValues" type="(hints: string[]) => Promise<Object>" />
101+
102+
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.
103+
87104
- <Field name="script" type="object" />
88105

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

0 commit comments

Comments
 (0)