ua-parser-js
ua-parser-js copied to clipboard
New User-Agent Client Hints
W3C has put out a draft for new user-agent hints: https://wicg.github.io/ua-client-hints/
Also reference: https://tools.ietf.org/html/draft-west-ua-client-hints-00
Is there a plan to support these in the upcoming months? It looks like Chrome is going to freeze User-Agent strings this year.
- Chrome 81 (mid-March 2020) - Google plans to show warnings in the Chrome console for web pages that read the UA string, so developers can adjust their website code.
- Chrome 83 (early June 2020) - Google will freeze the Chrome browser version in the UA string and unify OS versions
- Chrome 85 (mid-September 2020) - Google will unify the UA desktop OS string as a common value for desktop browsers. Google will also unify mobile OS/device strings as a similarly common value.
https://www.zdnet.com/article/google-to-phase-out-user-agent-strings-in-chrome/
User-Agent Client Hints spec define HTTP request header and JavaScript DOM API.
Latest spec and Chrome 82+(canary) remove navigation.getUserAgent()
JavaScript API and introduce navigation.userAgentData
object.
NavigatorUAData
return low entropy values synchronously,
On the one hand, NavigatorUAData
return high entropy values asynchronously.
// Low Entropy Values
console.log(navigator.userAgentData.mobile); // false
copy(navigator.userAgentData.uaList); // [{ "brand": "Google Chrome", "version": "82" }]
// High Entropy Values
navigator.userAgentData.getHighEntropyValues(["platform", "platformVersion", "architecture", "model"]).then(res => console.log(res));
/* {architecture: "Intel", model: "", platform: "Mac OS X", platformVersion: "10_15_3", uaFullVersion: ""} */
Refs:
@faisalman any plan to incorporate this into the lib?
^ Ditto
As of Feb 24 2021, this is the status of Chrome freezing the UA string
No, the UA string will not be frozen in Chrome 89. We've yet to release a firm timeline.
Hello, the Blink / Chromium team has recently released an official communication with timeline details on the reduction of the User-Agent:
I'd also be interested in this. Are there any plans to add support?
Chrome now reports
A page or script is accessing at least one of navigator.userAgent, navigator.appVersion, and navigator.platform. Starting in Chrome 101, the amount of information available in the User Agent string will be reduced.
To fix this issue, replace the usage of navigator.userAgent, navigator.appVersion, and navigator.platform with feature detection, progressive enhancement, or migrate to navigator.userAgentData.
Note that for performance reasons, only the first access to one of the properties is shown
Is there any support planned? UA strings are the same now with Chrome 95+ between Windows 10 and 11 and between MacOS 10, 11 and 12.
+1 on this
Already taken affect on Chrome 110
+1 on this 👍
+1 on this too
Starting from version 2.0
, user-agent client hints can be used as an addition to existing user-agent by explicitly calls withClientHints()
method.