Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

useragent.js

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

useragent.js

A simple project that allows you to display details about a computer's operating system or web browser with a user-agent.

  • 0.5.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
103
increased by47.14%
Maintainers
1
Weekly downloads
 
Created
Source

useragent.js

npm Coverage Status Build Status David deps npm GitHub release

A User-agent analyze project. Demo: http://project.zsxsoft.com/useragent.js/withimage.html

##Compatibility Node.JS / (Windows) Classical ASP / (Windows) WScript / (Windows) CScript / Internet Explorer *+ / Google Chrome / Mozilla Firefox / Apple Safari

###IE<8 Please import a Polyfill of Object.keys before import this. See here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys)

##Installion $ npm install useragent.js

##Compress

If you want to use it in the browser directly, please run grunt to compress it.

##Test

$ npm test

##Run ####In Node

var userAgent = require("useragent.js");
var ua = userAgent.analyze("Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2251.0 Safari/537.36");
console.log("TEST UA: " + ua.ua);
console.log("TEST BROWSER:" + ua.browser.full + " (" + ua.browser.name + " VERSION = " + ua.browser.version + " )");
console.log("TEST OS:" + ua.os.full + " (" + ua.os.name + " VERSION = " + ua.os.version + " )");
console.log("TEST DEVICE:" + ua.device.full);

####In Webpack / browserify

import Useragent from 'useragent.js';
console.log(Useragent);

####In Browser Click here

(function () {
		var ua = USERAGENT.analyze(navigator.userAgent);
		document.getElementById("useragent").innerHTML = ua.ua;
		document.getElementById("browser").innerHTML = ua.browser.full + " (" + ua.browser.name + " VERSION = "  + ua.browser.version + " )";
		document.getElementById("os").innerHTML = ua.os.full + " (" + ua.os.name + " VERSION = "  + ua.os.version + " )";
		document.getElementById("device").innerHTML = ua.device.full;
})();

####In RequireJS Click here

####In SeaJS Click here

####In Classical ASP Click here

Result

{ ua: 'Mozilla/5.0 (iPad; CPU OS 7_1_2 like Mac OS X) AppleWebKit/537.51.2 (KHTML, like Gecko) Mobile/11D257 IPadQQ/4.1.1.14',
  os:
   { ua: 'Mozilla/5.0 (iPad; CPU OS 7_1_2 like Mac OS X) AppleWebKit/537.51.2 (KHTML, like Gecko) Mobile/11D257 IPadQQ/4.1.1.14',
     name: 'iOS',
     version: '7.1.2',
     full: 'iOS 7.1.2',
     windows: false,
     linux: false,
     x64: false,
     dir: 'os',
     image: 'mac-3' },
  device:
   { ua: 'Mozilla/5.0 (iPad; CPU OS 7_1_2 like Mac OS X) AppleWebKit/537.51.2 (KHTML, like Gecko) Mobile/11D257 IPadQQ/4.1.1.14',
     name: 'Apple iPad',
     image: 'ipad',
     brand: 'Apple',
     model: 'iPad',
     dir: 'device',
     full: 'Apple iPad' },
  browser:
   { ua: 'Mozilla/5.0 (iPad; CPU OS 7_1_2 like Mac OS X) AppleWebKit/537.51.2 (KHTML, like Gecko) Mobile/11D257 IPadQQ/4.1.1.14',
     name: 'QQ',
     version: '4.1.1.14',
     full: 'QQ 4.1.1.14',
     image: 'qq',
     dir: 'browser' },
  platform: 
  /*
    Copied from device or os.
    .platform = .device, 
        but if device.name === "" then .platform = .os
   */
   { ua: 'Mozilla/5.0 (iPad; CPU OS 7_1_2 like Mac OS X) AppleWebKit/537.51.2 (KHTML, like Gecko) Mobile/11D257 IPadQQ/4.1.1.14',
     name: 'Apple iPad',
     image: 'ipad',
     brand: 'Apple',
     model: 'iPad',
     dir: 'device',
     full: 'Apple iPad' } }

Supported Browsers/Platforms

Click here to see full list.

Tested Browsers: Amazon Silk / Android Webkit / Avant Browser / Comodo Dragon / curl / Firefox / Google Chrome / Internet Explorer / Microsoft Edge / Links / Lynx / Maxthon / MxNitro / Opera / QQBrowser / Safari SRWare Iron / Teleca Q7 / UC Browser / Vivaldi / W3M / wget / Yandex.Browser and so on..

OS: Android / Arch Linux / CentOS / Chrome OS / Debain / Fedora / FreeBSD / OSX / Red Hat / openSUSE / SymbianOS / Unix / Palm webOS / Windows 3.1 - 10 / Ubuntu / Linux and so on..

Devices: Xiaomi / BlackBerry / Nexus / HTC / Huawei / Kindle / Lenovo / LG / Motorola / Nokia / OnePlus / PlayStation / Samsung / Sony Xperia / ZTE / Ubuntu / Windows Phone / Apple Family and so on.

License

The MIT License

The images can be gotten from php-useragent.

Keywords

FAQs

Package last updated on 17 Oct 2016

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc