Skip to content

Commit

Permalink
Rearrange the recently added smarttv detection
Browse files Browse the repository at this point in the history
  • Loading branch information
faisalman committed Jan 26, 2023
1 parent bf4fb91 commit 0cbeb7a
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 68 deletions.
36 changes: 18 additions & 18 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,19 +80,19 @@ The methods are self explanatory, here's a small overview on all the available m
# Possible 'browser.name':
2345Explorer, 360 Browser, Amaya, Android Browser, Arora, Avant, Avast, AVG,
BIDUBrowser, Baidu, Basilisk, Blazer, Bolt, Brave, Bowser, Camino, Chimera,
Chrome Headless, Chrome WebView, Chrome, Chromium, Comodo Dragon, Dillo,
Chrome Headless, Chrome WebView, Chrome, Chromium, Cobalt, Comodo Dragon, Dillo,
Dolphin, Doris, DuckDuckGo, Edge, Electron, Epiphany, Facebook, Falkon, Fennec,
Firebird, Firefox [Focus/Reality], Flock, Flow, GSA, GoBrowser, Huawei Browser,
ICE Browser, IE, IEMobile, IceApe, IceCat, IceDragon, Iceweasel, Instagram,
Iridium, Iron, Jasmine, K-Meleon, Kindle, Klar, Konqueror, LBBROWSER, Line,
LinkedIn, Links, Lunascape, Lynx, MIUI Browser, Maemo Browser, Maemo, Maxthon,
MetaSr Midori, Minimo, Mobile Safari, Mosaic, Mozilla, NetFront, NetSurf, Netfront,
Netscape, NokiaBrowser, Obigo, Oculus Browser, OmniWeb, Opera Coast,
Opera [Mini/Mobi/Tablet], PaleMoon, PhantomJS, Phoenix, Polaris, Puffin, QQ,
QQBrowser, QQBrowserLite, Quark, QupZilla, RockMelt, Safari, Sailfish Browser,
Samsung Browser, SeaMonkey, Silk, Skyfire, Sleipnir, Slim, SlimBrowser, Swiftfox,
Tesla, Tizen Browser, UCBrowser, UP.Browser, Vivaldi, Waterfox, WeChat, Weibo,
Yandex, baidu, iCab, w3m, Whale Browser...
Iridium, Iron, Jasmine, Kakao[Story/Talk], K-Meleon, Kindle, Klar, Konqueror,
LBBROWSER, Line, LinkedIn, Links, Lunascape, Lynx, MIUI Browser, Maemo Browser,
Maemo, Maxthon, MetaSr Midori, Minimo, Mobile Safari, Mosaic, Mozilla, NetFront,
NetSurf, Netfront, Netscape, NokiaBrowser, Obigo, Oculus Browser, OmniWeb,
Opera Coast, Opera [Mini/Mobi/Tablet], PaleMoon, PhantomJS, Phoenix, Polaris,
Puffin, QQ, QQBrowser, QQBrowserLite, Quark, QupZilla, RockMelt, Safari,
Sailfish Browser, Samsung Browser, SeaMonkey, Silk, Skyfire, Sleipnir, Slim,
SlimBrowser, Swiftfox, Tesla, Tizen Browser, UCBrowser, UP.Browser, Viera,
Vivaldi, Waterfox, WeChat, Weibo, Yandex, baidu, iCab, w3m, Whale Browser...

# 'browser.version' determined dynamically
```
Expand All @@ -113,10 +113,10 @@ console, mobile, tablet, smarttv, wearable, embedded

# Possible 'device.vendor':
Acer, Alcatel, Amazon, Apple, Archos, ASUS, AT&T, BenQ, BlackBerry, Dell,
Essential, Fairphone, GeeksPhone, Google, HP, HTC, Huawei, Jolla, Lenovo, LG,
Meizu, Microsoft, Motorola, Nexian, Nintendo, Nokia, Nvidia, OnePlus, OPPO, Ouya,
Palm, Panasonic, Pebble, Polytron, Realme, RIM, Roku, Samsung, Sharp, Siemens,
Sony[Ericsson], Sprint, Tesla, Vivo, Vodafone, Xbox, Xiaomi, Zebra, ZTE, ...
Essential, Facebook, Fairphone, GeeksPhone, Google, HP, HTC, Huawei, Jolla,
Lenovo, LG, Meizu, Microsoft, Motorola, Nexian, Nintendo, Nokia, Nvidia, OnePlus,
OPPO, Ouya, Palm, Panasonic, Pebble, Polytron, Realme, RIM, Roku, Samsung, Sharp,
Siemens, Sony[Ericsson], Sprint, Tesla, Vivo, Vodafone, Xbox, Xiaomi, Zebra, ZTE, ...

# 'device.model' determined dynamically
```
Expand All @@ -141,10 +141,10 @@ AIX, Amiga OS, Android[-x86], Arch, Bada, BeOS, BlackBerry, CentOS, Chromium OS,
Contiki, Fedora, Firefox OS, FreeBSD, Debian, Deepin, DragonFly, elementary OS,
Fuchsia, Gentoo, GhostBSD, GNU, Haiku, HarmonyOS, HP-UX, Hurd, iOS, Joli, KaiOS,
Linpus, Linspire,Linux, Mac OS, Maemo, Mageia, Mandriva, Manjaro, MeeGo, Minix,
Mint, Morph OS, NetBSD, Nintendo, OpenBSD, OpenVMS, OS/2, Palm, PC-BSD, PCLinuxOS,
Plan9, PlayStation, QNX, Raspbian, RedHat, RIM Tablet OS, RISC OS, Sabayon,
Sailfish, Series40, Slackware, Solaris, SUSE, Symbian, Tizen, Ubuntu, Unix,
VectorLinux, WebOS, Windows [Phone/Mobile], Zenwalk, ...
Mint, Morph OS, NetBSD, NetRange, NetTV, Nintendo, OpenBSD, OpenVMS, OS/2, Palm,
PC-BSD, PCLinuxOS, Plan9, PlayStation, QNX, Raspbian, RedHat, RIM Tablet OS,
RISC OS, Sabayon, Sailfish, Series40, Slackware, Solaris, SUSE, Symbian, Tizen,
Ubuntu, Unix, VectorLinux, Viera, WebOS, Windows [Phone/Mobile], Zenwalk, ...

# 'os.version' determined dynamically
```
Expand Down
83 changes: 37 additions & 46 deletions src/ua-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,7 @@
LG = 'LG',
MICROSOFT = 'Microsoft',
MOTOROLA = 'Motorola',
NETRANGE= 'Netrange',
NETTV = 'NetTV',
OPERA = 'Opera',
PANASONIC = 'Panasonic',
SAMSUNG = 'Samsung',
SHARP = 'Sharp',
SONY = 'Sony',
Expand Down Expand Up @@ -302,8 +299,6 @@

/ wv\).+(chrome)\/([\w\.]+)/i // Chrome WebView
], [[NAME, CHROME+' WebView'], VERSION], [
/Panasonic;(VIERA)/i // Panasonic Viera
], [[NAME, VIERA]], [

/droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i // Android Browser
], [VERSION, [NAME, 'Android '+BROWSER]], [
Expand Down Expand Up @@ -338,7 +333,8 @@
// Other
/(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|sleipnir|obigo|mosaic|(?:go|ice|up)[\. ]?browser)[-\/ ]?v?([\w\.]+)/i,
// Polaris/Lynx/Dillo/iCab/Doris/Amaya/w3m/NetSurf/Sleipnir/Obigo/Mosaic/Go/ICE/UP.Browser
/(links) \(([\w\.]+)/i // Links
/(links) \(([\w\.]+)/i, // Links
/panasonic;(viera)/i // Panasonic Viera
], [NAME, VERSION], [

/(cobalt)\/([\w\.]+)/i // Cobalt
Expand Down Expand Up @@ -379,37 +375,6 @@

device : [[

///////////////////
// SMARTTVS
///////////////////

/smart-tv.+(samsung)/i // Samsung
], [VENDOR, [TYPE, SMARTTV]], [
/hbbtv.+maple;(\d+)/i
], [[MODEL, /^/, 'SmartTV'], [VENDOR, SAMSUNG], [TYPE, SMARTTV]], [
/(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i // LG SmartTV
], [[VENDOR, LG], [TYPE, SMARTTV]], [
/(apple) ?tv/i // Apple TV
], [VENDOR, [MODEL, APPLE+' TV'], [TYPE, SMARTTV]], [
/crkey/i // Google Chromecast
], [[MODEL, CHROME+'cast'], [VENDOR, GOOGLE], [TYPE, SMARTTV]], [
/droid.+aft(\w)( bui|\))/i // Fire TV
], [MODEL, [VENDOR, AMAZON], [TYPE, SMARTTV]], [
/\(dtv[\);].+(aquos)/i,
/(aquos-tv[\w ]+)\)/i // Sharp
], [MODEL, [VENDOR, SHARP], [TYPE, SMARTTV]],[
/(bravia[\w ]+)( bui|\))/i // Sony
], [MODEL, [VENDOR, SONY], [TYPE, SMARTTV]], [
/(mitv-\w{5}) bui/i // Xiaomi
], [MODEL, [VENDOR, XIAOMI], [TYPE, SMARTTV]], [
/Hbbtv.*(technisat) (.*);/i // TechniSAT
], [VENDOR, MODEL, [TYPE, SMARTTV]], [
/\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i, // Roku
/hbbtv\/\d+\.\d+\.\d+ +\([\w\+ ]*; *([\w\d][^;]*);([^;]*)/i // HbbTV devices
], [[VENDOR, trim], [MODEL, trim], [TYPE, SMARTTV]], [
/\b(android tv|smart[- ]?tv|opera tv|tv; rv:)\b/i // SmartTV from Unidentified Vendors
], [[TYPE, SMARTTV]], [

//////////////////////////
// MOBILES & TABLETS
/////////////////////////
Expand Down Expand Up @@ -539,7 +504,7 @@

// ZTE
/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,
/(alcatel|geeksphone|nexian|panasonic|sony(?!-bra))[-_ ]?([-\w]*)/i // Alcatel/GeeksPhone/Nexian/Panasonic/Sony
/(alcatel|geeksphone|nexian|panasonic(?!(?:;|\.))|sony(?!-bra))[-_ ]?([-\w]*)/i // Alcatel/GeeksPhone/Nexian/Panasonic/Sony
], [VENDOR, [MODEL, /_/g, ' '], [TYPE, MOBILE]], [

// Acer
Expand Down Expand Up @@ -631,6 +596,37 @@
/droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i
], [MODEL, [VENDOR, ZEBRA], [TYPE, MOBILE]], [

///////////////////
// SMARTTVS
///////////////////

/smart-tv.+(samsung)/i // Samsung
], [VENDOR, [TYPE, SMARTTV]], [
/hbbtv.+maple;(\d+)/i
], [[MODEL, /^/, 'SmartTV'], [VENDOR, SAMSUNG], [TYPE, SMARTTV]], [
/(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i // LG SmartTV
], [[VENDOR, LG], [TYPE, SMARTTV]], [
/(apple) ?tv/i // Apple TV
], [VENDOR, [MODEL, APPLE+' TV'], [TYPE, SMARTTV]], [
/crkey/i // Google Chromecast
], [[MODEL, CHROME+'cast'], [VENDOR, GOOGLE], [TYPE, SMARTTV]], [
/droid.+aft(\w)( bui|\))/i // Fire TV
], [MODEL, [VENDOR, AMAZON], [TYPE, SMARTTV]], [
/\(dtv[\);].+(aquos)/i,
/(aquos-tv[\w ]+)\)/i // Sharp
], [MODEL, [VENDOR, SHARP], [TYPE, SMARTTV]],[
/(bravia[\w ]+)( bui|\))/i // Sony
], [MODEL, [VENDOR, SONY], [TYPE, SMARTTV]], [
/(mitv-\w{5}) bui/i // Xiaomi
], [MODEL, [VENDOR, XIAOMI], [TYPE, SMARTTV]], [
/Hbbtv.*(technisat) (.*);/i // TechniSAT
], [VENDOR, MODEL, [TYPE, SMARTTV]], [
/\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i, // Roku
/hbbtv\/\d+\.\d+\.\d+ +\([\w\+ ]*; *([\w\d][^;]*);([^;]*)/i // HbbTV devices
], [[VENDOR, trim], [MODEL, trim], [TYPE, SMARTTV]], [
/\b(android tv|smart[- ]?tv|opera tv|tv; rv:)\b/i // SmartTV from Unidentified Vendors
], [[TYPE, SMARTTV]], [

///////////////////
// CONSOLES
///////////////////
Expand Down Expand Up @@ -745,19 +741,14 @@
], [[NAME, 'Chromium OS'], VERSION],[

// Smart TVs
/Panasonic;VIERA/i // Panasonic Viera
], [[NAME, VIERA]], [
/NETRANGEMMH/i // Netrange
], [[NAME, NETRANGE]], [
/nettv\/(\d\.\d.\d)/i // NetTV
], [VERSION, [NAME, NETTV]], [

/panasonic;(viera)/i, // Panasonic Viera
/(netrange)mmh/i, // Netrange
/(nettv)\/(\d+\.[\w\.]+)/i, // NetTV

// Console
/(nintendo|playstation) ([wids345portablevuch]+)/i, // Nintendo/Playstation
/(xbox); +xbox ([^\);]+)/i, // Microsoft Xbox (360, One, X, S, Series X, Series S)


// Other
/\b(joli|palm)\b ?(?:os)?\/?([\w\.]*)/i, // Joli/Palm
/(mint)[\/\(\) ]?(\w*)/i, // Mint
Expand Down
2 changes: 1 addition & 1 deletion test/browser-test.json
Original file line number Diff line number Diff line change
Expand Up @@ -1283,7 +1283,7 @@
"ua" : "HbbTV/1.2.1 (;Panasonic;VIERA 2015;3.014;a001-003 4000-0000;)",
"expect" :
{
"name" : "Viera",
"name" : "VIERA",
"version" : "undefined",
"major" : "undefined"
}
Expand Down
9 changes: 9 additions & 0 deletions test/device-test.json
Original file line number Diff line number Diff line change
Expand Up @@ -1476,6 +1476,15 @@
"type": "mobile"
}
},
{
"desc": "Panasonic T31",
"ua": "Mozilla/5.0 (Linux; Android 4.2.2; Panasonic T31 Build/JDQ39) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.170 Mobile Safari/537.36 ",
"expect": {
"vendor": "Panasonic",
"model": "T31",
"type": "mobile"
}
},
{
"desc": "Panasonic TX-32CSW514 SmartTV",
"ua": "HbbTV/1.2.1 (;Panasonic;VIERA 2015;3.014;a001-003 4000-0000;)",
Expand Down
6 changes: 3 additions & 3 deletions test/os-test.json
Original file line number Diff line number Diff line change
Expand Up @@ -1057,7 +1057,7 @@
"ua" : "HbbTV/1.2.1 (;Panasonic;VIERA 2015;3.014;a001-003 4000-0000;)",
"expect" :
{
"name" : "Viera",
"name" : "VIERA",
"version" : "undefined"
}
},
Expand All @@ -1066,7 +1066,7 @@
"ua" : "Mozilla/5.0 (Linux; U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36 OPR/46.0.2207.0 LOEWE-SL410/5.2.0.0 HbbTV/1.4.1 (; LOEWE; SL410; LOH/5.2.0.0;;) FVC/3.0 (LOEWE; SL410;) CE-HTML/1.0 Config (L:deu,CC:DEU) NETRANGEMMH",
"expect" :
{
"name" : "Netrange",
"name" : "NETRANGE",
"version" : "undefined"
}
},
Expand All @@ -1075,7 +1075,7 @@
"ua" : "Opera/9.80 (Linux mips ; U; HbbTV/1.1.1 (; Philips; ; ; ; ) CE-HTML/1.0 NETTV/3.2.1; en) Presto/2.6.33 Version/10.70",
"expect" :
{
"name" : "NetTV",
"name" : "NETTV",
"version" : "3.2.1"
}
},
Expand Down

0 comments on commit 0cbeb7a

Please sign in to comment.