npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

useragent.js

v0.5.7

Published

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

Downloads

338

Readme

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

  • Nodejs >= 0.12
  • Windows Script Host (ASP / WScript / CScript)
  • Edge / Chrome / Firefox / Safari / Internet Explorer >= 8

IE<8

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

Usage

Nodejs

const userAgent = require("useragent.js");
const 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}, ${ua.browser.version})`);
console.log(`TEST OS: ${ua.os.full} (${ua.os.name}, ${ua.os.version})`);
console.log(`TEST DEVICE: ${ua.device.full}`);

Webpack / browserify

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

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;
})();

Requirejs

Click here

Classical ASP

Click here

Test

$ npm test

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

Images

Download icons from php-useragent.