Skip to content
forked from fkei/sua.js

Simple user agent detection library. - Node.js or Browser supported

License

Notifications You must be signed in to change notification settings

cathcheeno/sua.js

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sua

Simple user agent detection library. (Node.js or Browser supported)

Install (NPM or Bower)

$ npm install sua.js
or
$ bower install sua.js

Feature

Support Browser

  • ua.Android 2.1
  • ua.Android 2.2
  • ua.Android 2.3
  • ua.Android 3.x
  • ua.Android 4.x
  • ua.Android 5.0
  • ua.Android 5.1
  • ua.iphone (IOS4)
  • ua.iphone (IOS5)
  • ua.iphone (IOS6)
  • ua.iphone (IOS7)
  • ua.iphone (IOS8)
  • ua.iphone (IOS9)
  • ua.iphone (IOS4-ipad)
  • ua.iphone (IOS5-ipad)
  • ua.iphone (IOS6-ipad)
  • ua.iphone (IOS7-ipad)
  • ua.iphone (IOS8-ipad)
  • ua.iphone (IOS9-ipad)
  • ua.iphone5 (hardware)
  • ua.blackberry
  • ua.webos
  • ua.touchpad
  • ua.kindle
  • ua.silk
  • ua.bb10
  • ua.rimtabletos
  • ua.playbook
  • ua.ds
  • ua.psp
  • ua.psvita
  • ua.windowsphone
  • ua.safari
  • ua.xbox
  • ua.ie11
  • ua.ie10
  • ua.ie9
  • ua.android.firefox
  • ua.webview.twitter

Build

$ make build # output: sua.min.js

test

Browser : $ ./spec/index.html

Terminal : $ make test

Use

<script src="sua.js" />

<script>
  // window.sua.setup();
  window.sua.setup('Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A403 Safari/8536.25');

  console.log(sua.browser.version);

  JSON.stringify(sua.os, null, "    ");
  > "{
  >   "iphone": true,
  >   "ios": true,
  >   "version": "6.0",
  >   "tablet": false,
  >   "phone": true
  > }"

  JSON.stringify(sua.iphone, null, "    ")
  > "[
  >   "iPhone OS 6_0",
  >   "iPhone OS",
  >   "6_0"
  > ]"
</script>

file size

sua.js (size: 10721 byte) optimize none
sua.min.js (size: 3559 byte) optimize uglify2

LICENSE

@see : LICENSE

About

Simple user agent detection library. - Node.js or Browser supported

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 96.3%
  • Shell 2.1%
  • HTML 1.2%
  • Makefile 0.4%