TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

UA-Parser.JS - Lightweight JavaScript User Agent Parser

10 点作者 huragok超过 12 年前

1 comment

k3n超过 12 年前
On a related note, something I've always wondered about is why there isn't a native host object that represents the UA? Is there anything, save for tons of live code parsing UA strings, preventing this?<p>Seriously, even this 'lightweight' parser is around 7.6kb and a couple hundred lines of code -- and I'm not trying to knock the OP's work by any stretch. It just seems crazy that we still have to muck with this manual string parsing!<p>Why can't we just have:<p><pre><code> UA = { name: "Chrome", vendor: "Google", version: [24, 0, 1312, 14], // "24.0.1312.14", renderer: { name: "WebKit", vendor: "Apple", version: [537, 17], }, javascript: { name: "V8", vendor: "Google", version: [3, 14, 5, 1], }, os: { name: "Windows 7", vendor: "Microsoft", version: ["NT", 6, 1], // "NT 6.1" }, user: { locale: "en-US", timezone: "America/Chicago", utc: -6, } };</code></pre>
评论 #4840830 未加载
评论 #4840930 未加载