rowser
v0.6.0
Published
An experimental generator-based browser/os/bot detector with proxied API
Downloads
15
Maintainers
Readme
rowser
An experimental generator-based browser/os/bot detector with proxied API
Table of contents
Installation
npm install rowser --save
yarn add rowser --save
API
detect(ua: string = window.navigator.userAgent) => Object
Method detect
runs detection process
summary: Object
Property summary
saves result of the last detection
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
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
License
MIT © Alex Orekhov