Skip to content
/ rowser Public

🔍 [WIP on 1.0.0] An experimental browser/os/rendering engine/bot detector with proxied API

License

Notifications You must be signed in to change notification settings

everget/rowser

Repository files navigation

rowser

An experimental browser/os/rendering engine/bot detector with proxied API

Build Status Build status codecov Coverage Status CodeFactor npm version npm David Known Vulnerabilities FOSSA Status

Table of contents

  1. Installation
  2. API
  3. Usage
  4. Possible flags
  5. License

Installation

npm install rowser --save
yarn add rowser --save

Back to top

API

detect(ua: string = window.navigator.userAgent) => Object

Method detect runs detection process

summary: Object

Property summary saves result of the last detection

Back to top

Usage

By default, rowser gets window.navigator.userAgent as its ua parameter. So in browser environment you can simply do:

rowser.detect();

Also you can use custom useragent string:

const someMobilaUA = 'Mozilla/5.0 (iPhone; CPU iPhone OS 7_0_4 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Mobile/11B554a';

rowser.detect(someMobilaUA);

After that, rowser.detect(ua) returns PlainObject as result:

rowser.detect(someMobilaUA);
// =>
//  {
//    device: "iPhone",
//    engine: "WebKit",
//    engineversion: "537.51",
//    ios: true,
//    name: "Safari",
//    osname: "iOS",
//    osversion: "7.0.4",
//    safari: true,
//    version: "",
//    webkit: true
//  }

NOTE: if you call rowser.detect('') you will get an empty object:

rowser.detect('');
// => {}

After detection rowser saves result in its property called summary:

rowser.summary
// =>
//  {
//    device: "iPhone",
//    engine: "WebKit",
//    engineversion: "537.51",
//    ios: true,
//    name: "Safari",
//    osname: "iOS",
//    osversion: "7.0.4",
//    safari: true,
//    version: "",
//    webkit: true
//  }

NOTE: When detection is done rowser's proxied API will allow you to get result's directly:

rowser.device
// => 'iPhone'

rowser.ios
// => true

rowser.osversion
// => '7.0.4'

Additionally for boolean props, you can add is-prefixes to props names:

rowser.isWebkit
// => true

rowser.iswebkit
// => true

rowser.isWeBkIt
// => true

rowser.isWEBKIT
// => true

rowser.isSafari
// => true

rowser.issafari
// => true

rowser.isSaFArI
// => true

rowser.isSAFARI
// => true

NOTE: is-prefixed props are case insensetive

Back to top

Possible flags

Browsers

Browser Summary flag
Android Browser androidbrowser
BlackBerry Browser blackberrybrowser, bbbrowser
Chromium chromium
Google Chrome chrome
Google Search App gsa, googlesearchapp
Dolphin Browser dolphin
Dorothy Browser dorothy
Epiphany epiphany
Mozilla Firefox firefox
Mozilla Firefox Focus firefox, firefoxfocus
Microsoft Internet Explorer msie
K-Meleon kmeleon
Maxthon maxthon
Microsoft Edge msedge
OmniWeb omniweb
Opera opera
Opera Coast opera, operacoast
Opera Mini opera, operamini
Opera Mobile opera, operamobile
Opera Neon opera, operaneon
Pale Moon palemoon
PhantomJS phantomjs
Puffin puffin
QupZilla qupzilla
Rambler Browser ramblerbrowser, nichrome
Apple Safari safari
Sailfish Browser sailfishbrowser
Samsung Internet samsungbrowser, samsunginternet
SeaMonkey seamonkey
Amazon Silk silk
Skyfire skyfire
Sleipnir sleipnir
SlimerJS slimerjs
Tesla Car Browser teslacarbrowser, qtcarbrowser
Tizen Browser tizenbrowser
UC Browser ucbrowser
Vivaldi vivaldi
webOS Browser webosbrowser
Yandex Browser yandexbrowser

Rendering engines

Rendering engine Summary flag
Blink blink
EdgeHTML edgehtml
Gecko gecko
Goanna goanna
Presto presto
Trident trident
WebKit webkit

Operating systems

Operating system Summary flag
Android android
(SOON) Android TV androidtv
(SOON) Bada bada
BlackBerry OS blackberry
Chrome OS chromeos
(SOON) Firefox OS firefoxos, fxos
iOS ios
Linux linux
macOS macos
NetCast netcast
Sailfish sailfish
Tizen tizen
webOS webos
Windows windows
Windows Phone windowsphone

Bots

Bots/Crawlers/Spiders Summary flag
Alexa Crawlers alexacrawler
Baidu Spiders baiduspider
Bing Crawlers bingbot
DuckDuckBot duckduckbot
Exabot exabot
Facebook Bot facebookbot
Google Crawlers googlebot
LinkedIn Bot linkedinbot
Majestic-12 Crawler mj12bot
Pinterest Bot pinterestbot
SlackBot slackbot
Sogou Spiders sogouspider
StackRambler stackrambler
TelegramBot telegrambot
Twitter Bot twitterbot
WhatsApp Bot whatsappbot
Yahoo! Slurp yahooslurp
Yandex Crawlers yandexbot

Back to top

License

MIT © Alex Orekhov

FOSSA Status

Back to top