All Projects → ariya → uainfer

ariya / uainfer

Licence: MIT license
Infer the user agent from its User Agent string

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to uainfer

useragent-generator
Easily generate correct user-agent strings for popular browsers
Stars: ✭ 62 (+195.24%)
Mutual labels:  user-agent, useragent
Bowser
a browser detector
Stars: ✭ 5,006 (+23738.1%)
Mutual labels:  user-agent-parser, useragent
user-agent
User-Agent parser for Clojure
Stars: ✭ 24 (+14.29%)
Mutual labels:  user-agent, user-agent-parser
bots-zoo
No description or website provided.
Stars: ✭ 59 (+180.95%)
Mutual labels:  user-agent, useragent
react-ua
📱React User Agent Component, Hook, and HOC. SSR-ready, full UT, using new React Context and Hooks API
Stars: ✭ 18 (-14.29%)
Mutual labels:  user-agent, user-agent-parser
React Device Detect
Detect device, and render view according to detected device type.
Stars: ✭ 1,145 (+5352.38%)
Mutual labels:  user-agent, useragent
Ng Device Detector
Angular module to detect OS / Browser / Device
Stars: ✭ 243 (+1057.14%)
Mutual labels:  user-agent, useragent
Browser.php
A PHP Class to detect a user's Browser. This encapsulation provides a breakdown of the browser and the version of the browser using the browser's user-agent string. This is not a guaranteed solution but provides an overall accurate way to detect what browser a user is using.
Stars: ✭ 546 (+2500%)
Mutual labels:  user-agent, useragent
User agent
HTTP User Agent parser for the Go programming language.
Stars: ✭ 578 (+2652.38%)
Mutual labels:  user-agent, useragent
Ua Parser Js
UAParser.js - Detect Browser, Engine, OS, CPU, and Device type/model from User-Agent data. Supports browser & node.js environment.
Stars: ✭ 6,421 (+30476.19%)
Mutual labels:  user-agent, user-agent-parser
browserslist-generator
A library that makes generating and validating Browserslists a breeze!
Stars: ✭ 77 (+266.67%)
Mutual labels:  user-agent, useragent
react-useragent
Higher order component to add user agent information to your react components
Stars: ✭ 13 (-38.1%)
Mutual labels:  useragent
php-useragent
A User-agent analyze project which written by PHP.
Stars: ✭ 83 (+295.24%)
Mutual labels:  user-agent
List Of User Agents
List of major web + mobile browser user agent strings. +1 Bonus script to scrape :)
Stars: ✭ 247 (+1076.19%)
Mutual labels:  user-agent
cloudflare-block-bad-bot-ruleset
🚦 Block malicious crawlers with Cloudflare Firewall Rules
Stars: ✭ 178 (+747.62%)
Mutual labels:  user-agent
ember-useragent
An Ember addon for Fastboot-enabled UserAgent parsing via UAParser.js.
Stars: ✭ 34 (+61.9%)
Mutual labels:  useragent
User agent
Generator of User-Agent header
Stars: ✭ 227 (+980.95%)
Mutual labels:  user-agent
pumba
Fetch, store and access user agent strings for different browsers
Stars: ✭ 12 (-42.86%)
Mutual labels:  user-agent
device detector
Crystal shard for device detection by User-Agent string
Stars: ✭ 21 (+0%)
Mutual labels:  user-agent-parser
Vytal
Browser extension to spoof timezone, geolocation, locale and user agent.
Stars: ✭ 1,449 (+6800%)
Mutual labels:  user-agent

uainfer

npm version npm bundle size (minified) GitHub license Tests

This is a simple JavaScript library to infer the user agent from its claimed User-Agent string. The objective of uainfer to provide a human-friendly answer to the inquiry "What browser am I using?".

In the context of a web browser, the most common way to obtain the User-Agent string is from the value of navigator.userAgent. In the context of an HTTP server, it can be retrieved from the User-Agent header field in the HTTP request.

Example usage with Node.js REPL (or try it on RunKit):

> uainfer = require('uainfer');
> claim = 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.2';
> ua = uainfer.analyze(claim);
> ua.toString()
'Internet Explorer 7 on Windows XP'

(To use this library in a front-end application, see this JSFiddle demo)

For browsers utilizing Chrome/Blink engine (Samsung Browser, Opera, Vivaldi, etc), the result can contain the corresponding equivalent version of Chrome:

> console.log(ua)
UserAgent {
  browser:
   { name: 'Vivaldi',
     version: 1.96,
     fullVersion: '1.96.1147.52',
     chromeFamily: { version: 65, fullVersion: '65.0.3325.183' } },
  os: { name: 'Windows', version: '10' } }

Non-goals:

  • Recognize every single web browsers and obscure user agents out there.
  • Deduce other information such as CPU type, device, form factor, etc.

Design choices:

  • For a better maintenance, avoid regular expressions.
  • Always expand its small but fairly extensive test suite.
  • Keep it tidy and lightweight npm bundle size (minified)

This library is created and maintained by @AriyaHidayat.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].