格吉斯 - 代理人
从用户代理字符串或用户代理对象(userAgentData)中提取浏览器和操作系统信息.
文档
下载和安装
从 repo 直接下载 dist 文件或通过 npm 安装它 .
安装 npm
以下命令显示如何使用 npm 安装 egjs- agent .
$ npm install @egjs/agent
促进发展
您可以下载文件进行开发
- 最新报告: https://naver.github.io/egjs-agent/release/latest/dist/agent.js 页面存档备份,存于互联网档案馆
- 最近( 分钟) : https://naver.github.io/egjs-agent/release/latest/dist/agent.min.js 互联网档案馆的存檔,存档日期2014-12-21
- 具体版本:https://naver.github.io/egjs-agent/release/[VERSION]/dist/agent.js
- 具体版本(min):https://naver.github.io/egjs-agent/release/[VERSION]/dist/agent.min.js 页面存档备份,存于互联网档案馆
准备客户提示和用户代理删除!
Chrome原计划冻结用户Agent以改善用户隐私,目前正在作为实验功能被应用到84+.
不仅Chrome,其他浏览器总有一天会来.
在Chrome(铬)86之前,它仍然是一个实验特征.
如果您想要测试, 请启用下面的旗帜 .
chrome://flags/#enable-eximental-web-平台-features (中文(简体) ) chrome://frags/# freeze-user- agent (英语)
这一被缩减的格式将通过Chrome://flags/#reduce-user-agent在Chrome 93进行测试. chrome://frags/# 减少用户代理
拟议推出计划
Phase 4: Chrome 101 Ship reduced Chrome MINOR.BUILD.PATCH version numbers (“0.0.0”). Once rolled-out, the reduced UA string would apply to all page loads on desktop and mobile OSes that do not opt into the reverse Origin Trial.
Phase 5: Chrome 107 Begin roll-out of reduced Desktop UA string and related JS APIs (navigator.userAgent, navigator.appVersion, navigator.platform). Once rolled-out, the reduced UA string would apply to all page loads on desktop OSes that do not opt into the reverse Origin Trial.
Phase 6: Chrome 110 Begin roll-out of reduced Android Mobile (and Tablet) UA string and related JS APIs. Once rolled-out, the reduced UA string would apply to all page loads on Android that do not opt into the reverse Origin Trial.
Reduction Completion Phase 7: Chrome 113 reverse Origin Trial ends and all page loads receive the reduced UA string and related JS APIs.
将来
- 以下属性值将不会正确显示.
- 导航员.user 代理
- 导航员.appersion
- 导航.平台
- 导航员.产品Sub
- 导航员. vendor
- 你应该用
navigator.userAgentData改为navigator.userAgent。 。 。 .- 浏览器版本只显示主 .
- OS名称,OS版本,浏览器完整版本应同步获取.
- 可以同步检查的唯一OS名称是iOS和Android.
可能(你能够确切知道)
- 检查浏览器名称, 主要版本
- 请检查date=中的日期值 (帮助) Chrome 101下的完整版本
- 检查移动
- 检查操作系统名称
- 请检查date=中的日期值 (帮助) Webkit, Chromium
- 检查旧的 OS, OS 版本( Chrome 84 支持范围或更小)
- < Android 5.0 (英语)
- < 麦克OS X 10.10
- < 视窗 7
- < iOS 未知
import getAgent from "@egjs/agent";
const agent = getAgent();
// Check iOS
agent.os.name === "ios"
agent.os.majorVersion === 9
// Check Android
agent.os.name === "android"
agent.os.majorVersion === 4
parseFloat(agent.os.version) <= 4.4
// Check browser name
agent.browser.name === "safari"
// Check webkit
agent.browser.webkit
// Check chromium
agent.browser.chromium
如果您只想要使用 navigator.userAgent 的方法
import { getLegacyAgent } from "@egjs/agent";
const agent = getLegacyAgent();
// Check iOS
agent.os.name === "ios"
agent.os.majorVersion === 9
// Check Android
agent.os.name === "android"
agent.os.majorVersion === 4
parseFloat(agent.os.version) <= 4.4
// Check browser name
agent.browser.name === "safari"
// Check webkit
agent.browser.webkit
// Check chromium
agent.browser.chromium
无法( 如果同步)
- 请检查OS版本.
- 请检查浏览器的完整版本.
import getAgent from "@egjs/agent";
const agent = getAgent();
// If the full version is 10.5, it is displayed as 10.
agent.browser.version
// "unknown"
agent.os.name
// -1
agent.os.majorVersion
可能( 如果同步)
- 你可以得到准确的代理信息.
- 请检查OS版本.
- 请检查浏览器的完整版本.
import { getAccurateAgent } from "@egjs/agent";
// Use Promise
getAccurateAgent().then(agent => {
// Check OS version
agent.os.version
// Check Browser full verion
agent.browser.version
});
// Use Callback
getAccurateAgent(agent => {});
如果你敢使用同步, 你必须选择.
- 如果检查一个版本(前93.0.1234.56)低于克罗姆101来修复bug,就不应该有问题.
- 然而,如果需要检查101版本或更高版本的次要或补丁版本,则必须同步检查.
- 您可以检查 OS 名称, 但是如果想要检查 OS 版本, 请在应用还原前考虑切换到同步 .
支持的浏览器
以下为所支持的浏览器.
| Internet 浏览器 | 颜色 | 火花 | 萨法里 | iOS系统 | 机器人 |
|---|---|---|---|---|---|
| 7个+ | 最新消息 | 最新消息 | 最新消息 | 3个+ | 2.1 + 数据 |
客户提示支持
| 铬(铬、边缘、鲸鱼) | 盖克(火狐) | Webkit (萨法里语) |
|---|---|---|
| 84+ (实验) | 未知 | 未知 |
如何开始开发egjs代理?
对于有意开发egjs-agent的人,请遵循以下指示.
发展环境
1. 清除储存库
克隆 egjs 代理寄存器并安装依赖模块.
# Clone the repository.
$ git clone https://github.com/naver/egjs-agent.git
2. 安装依赖关系
npm 被支持.
# Install the dependency modules.
$ npm install
3. 建设
使用 npm 脚本构建 eg. agent
# Run rollup
$ npm start
# Build
$ npm run build
# Generate jsdoc
$ npm run jsdoc
完整的构建完成后将创建两个文件夹 .
- 数字 文件夹:包括 探员.js 财务报告和审定财务报表 探员.min.js 文档.
- 医生 文件夹:包括 API 文档。 文件的主页是: 文件/索引.html。 。 。 .
线性
为了保持同样的代码风格,我们采用了 ESLint 语录 保持我们的代码质量. 设置您的编辑器以检查或运行到命令下方的 Linting .
$ npm run lint
测试
一旦您创建了分支并完成了开发, 您就必须进行测试运行 npm run test 命令,然后将代码推到远程仓库.
$ npm run test
运行中 npm run test 命令将开始 欢乐。 。 。 .
错误报告
如果你找到窃听器,请用 问题 页面在 GitHub 上.
许可证
egjs-agent 将在 麻省理工学院许可证。 。 。 .
Copyright (c) 2015 NAVER Corp.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.