Security News
New Proposed CISA Mandate Would Require Critical Infrastructure to Report Ransom Payments Within 24 Hours
CISA has proposed a set of new rules that would require critical infrastructure to report cyber incidents and ransom payments.
detect.js
Advanced tools
JS Library to detect browser, os and device based on the UserAgent String, forked by John Carmichael for ease of use.
Weekly downloads
Readme
Note: Detect.js is a JavaScript library to detect platforms, versions, manufacturers and types based on the navigator.userAgent
string. This code is based on, and modified from, the original work of Tobie Langel's UA-Parser: https://github.com/tobie/ua-parser. UA-Parser is subsequently a port of BrowserScope's user agent string parser.
As initially touted, the biggest contribution to this code is the work of Steve Souders and the list of regex tests.
name
family
version
major
minor
patch
manufacturer
and type
as wellCreating a custom build of the regex profiles will help reduce file size and is strongly recommended. The default detect.js
and detect.min.js
files include all regex profiles and is therefor much larger then, I'm sure, your needs.
build/config.js
with you're preferred oss, devices and browsersnode build/build.js --input=build/detect.js --output=build/detect.custom.js
build/detect.custom.js
<script src="detect.js"></script>
/*
iPhone 4 Example User Agent:
Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A293 Safari/6531.22.7
*/
var ua = detect.parse(navigator.userAgent);
ua.browser.family // "Mobile Safari"
ua.browser.name // "Mobile Safari 4.0.5"
ua.browser.version // "4.0.5"
ua.browser.major // 4
ua.browser.minor // 0
ua.browser.patch // 5
ua.device.family // "iPhone"
ua.device.name // "iPhone"
ua.device.version // ""
ua.device.major // null
ua.device.minor // null
ua.device.patch // null
ua.device.type // "Mobile"
ua.device.manufacturer // "Apple"
ua.os.family // "iOS"
ua.os.name // "iOS 4"
ua.os.version // "4"
ua.os.major // 4
ua.os.minor // 0
ua.os.patch // null
var detect = require('detect');
var ua = detect.parse(navigator.userAgent);
...
npm install
.hooks/install.sh
.detect.js
and detect.min.js
) with npm start
.Thanks to Adriano Caheté and Julian
build/regexes.js
is Copyright 2009 Google Inc. and available under the Apache License, Version 2.0.FAQs
JS Library to detect browser, os and device based on the UserAgent String, forked by John Carmichael for ease of use.
The npm package detect.js receives a total of 1,616 weekly downloads. As such, detect.js popularity was classified as popular.
We found that detect.js demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISA has proposed a set of new rules that would require critical infrastructure to report cyber incidents and ransom payments.
Security News
Redis is no longer OSS, breaking its explicit commitment to remain under the BSD 3-Clause License forever. This has angered contributors who are now working to fork the software.
Product
Socket AI now enables 'AI detected potential malware' alerts by default, ensuring users benefit from AI-powered state-of-the-art malware detection without needing to opt-in.