Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect new device brands and Detect devices for exist brands #214

Merged
merged 7 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
716 changes: 361 additions & 355 deletions README.md

Large diffs are not rendered by default.

17 changes: 14 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -576,12 +576,19 @@ class DeviceDetector {

/**
* All unknown devices under running Java ME
* are more likely a features phones
* are more likely features phones
*/
if (deviceType === '' && osName === 'Java ME') {
deviceType = DEVICE_TYPE.FEATURE_PHONE;
}

/**
* All devices running KaiOS are more likely features phones
*/
if ('KaiOS' === osName) {
deviceType = DEVICE_TYPE.FEATURE_PHONE;
}

/**
* According to http://msdn.microsoft.com/en-us/library/ie/hh920767(v=vs.85).aspx
* Internet Explorer 10 introduces the "Touch" UA string token. If this token is present at the end of the
Expand Down Expand Up @@ -626,9 +633,13 @@ class DeviceDetector {
deviceType = DEVICE_TYPE.TV;
}
/**
* All devices that contain "Andr0id" in string are assumed to be a tv
* All devices that contain Andr0id in string are assumed to be a tv
*/
if (helper.hasAndroidTVFragment(userAgent)) {
const hasDeviceTvType = [
DEVICE_TYPE.TV,
DEVICE_TYPE.PERIPHERAL
].indexOf(deviceType) === -1 && helper.hasAndroidTVFragment(userAgent)
if (hasDeviceTvType) {
deviceType = DEVICE_TYPE.TV;
}
/**
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "node-device-detector",
"version": "2.1.6",
"version": "2.1.7",
"description": "Nodejs device detector (port matomo-org/device-detector)",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 2 additions & 0 deletions parser/client/browser-short.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ module.exports = {
'AL': 'Aloha Browser',
'AH': 'Aloha Browser Lite',
'A8': 'ALVA',
'9A': 'AltiBrowser',
'AM': 'Amaya',
'A3': 'Amaze Browser',
'A5': 'Amerigo',
Expand Down Expand Up @@ -345,6 +346,7 @@ module.exports = {
'LX': 'Lynx',
'L2': 'Lynket Browser',
'MD': 'Mandarin',
'MP': 'Maple',
'M5': 'MarsLab Web Browser',
'M7': 'MaxBrowser',
'M1': 'mCent',
Expand Down
22 changes: 21 additions & 1 deletion parser/device/brand-short.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,16 @@ module.exports = {
'ALS': 'All Star',
'AA': 'AllCall',
'3A': 'AllDocube',
'ALL': 'allente',
'A2': 'Allview',
'ALI': 'ALLINmobile',
'A7': 'Allwinner',
'ALP': 'alpsmart',
'A1': 'Altech UEC',
'66': 'Altice',
'ALM': 'Altimo',
'A5': 'altron',
'ALB': 'Altibox',
'ALT': 'Altus',
'KN': 'Amazon',
'AMZ': 'Amazon Basics',
Expand Down Expand Up @@ -195,6 +198,7 @@ module.exports = {
'BLK': 'Black Box',
'BF': 'Black Fox',
'BPC': 'Blackpcs',
'BLP': 'Blackphone',
'BLT': 'Blackton',
'B2': 'Blackview',
'2Y': 'b2m',
Expand Down Expand Up @@ -241,6 +245,7 @@ module.exports = {
'C9': 'CAGI',
'CAD': 'CADENA',
'CT': 'Capitel',
'GRD': 'G-Guard',
'G3': 'CG Mobile',
'37': 'CGV',
'CP': 'Captiva',
Expand Down Expand Up @@ -292,6 +297,7 @@ module.exports = {
'CY': 'Coby Kyros',
'XC': 'Cobalt',
'C6': 'Comio',
'COM': 'CommScope',
'CL': 'Compal',
'CQ': 'Compaq',
'C7': 'ComTrade Tesla',
Expand Down Expand Up @@ -561,6 +567,7 @@ module.exports = {
'44': 'Four Mobile',
'F0': 'Fonos',
'F2': 'FORME',
'FRM': 'Formovie',
'F5': 'Formuler',
'FR': 'Forstar',
'RF': 'Fortis',
Expand Down Expand Up @@ -603,6 +610,7 @@ module.exports = {
'GD': 'Gemini',
'GN': 'General Mobile',
'2G': 'Genesis',
'GEP': 'Geo Phone',
'G2': 'GEOFOX',
'GE': 'Geotel',
'Q4': 'Geotex',
Expand Down Expand Up @@ -654,6 +662,7 @@ module.exports = {
'GR1': 'GroBerwert',
'GF': 'Gretel',
'82': 'Gresso',
'GRB': 'Grünberg',
'GU': 'Grundig',
'GV': 'Gtel',
'CUO': 'Guophone',
Expand Down Expand Up @@ -707,6 +716,7 @@ module.exports = {
'HMD': 'HMD',
'8W': 'HKPro',
'HOF': 'HOFER',
'HOC': 'hoco',
'H1': 'Hoffmann',
'HOM': 'Homatics',
'H0': 'Hometech',
Expand Down Expand Up @@ -760,6 +770,7 @@ module.exports = {
'IC': 'iDroid',
'IDI': 'iDino',
'6Z': 'iData',
'IDC': 'IDC',
'IG': 'iGet',
'IHL': 'iHome Life',
'IH': 'iHunt',
Expand Down Expand Up @@ -982,6 +993,7 @@ module.exports = {
'LU': 'Lumus',
'LUM': 'Lumitel',
'L9': 'Luna',
'LUO': 'LUO',
'LR': 'Luxor',
'LY': 'LYF',
'LL': 'Leader Phone',
Expand Down Expand Up @@ -1104,6 +1116,7 @@ module.exports = {
'72': 'M-Tech',
'9H': 'M-Horse',
'MKP': 'M-KOPA',
'MLB': 'multibox',
'1R': 'Multilaser',
'MPS': 'MultiPOS',
'1M': 'MYFON',
Expand Down Expand Up @@ -1214,7 +1227,7 @@ module.exports = {
'OQ': 'Meta',
'O1': 'Odys',
'ODP': 'Odotpad',
'O9': 'Ok',
'O9': 'ok.',
'OKA': 'Okapi',
'OA': 'Okapia',
'OKI': 'Oking',
Expand Down Expand Up @@ -1380,6 +1393,7 @@ module.exports = {
'WJ': 'Qware',
'QWT': 'QWATT',
'R2': 'R-TV',
'R3D': 'R3Di',
'RA': 'Ramos',
'0R': 'Raspberry',
'R9': 'Ravoz',
Expand All @@ -1396,6 +1410,7 @@ module.exports = {
'RE': 'Realme',
'RE1': 'Redbean',
'R8': 'RED',
'RDX': 'RED-X',
'REW': 'Redway',
'6F': 'Redfox',
'RE2': 'RedLine',
Expand Down Expand Up @@ -1590,10 +1605,12 @@ module.exports = {
'5Y': 'Sunny',
'W8': 'SUNWIND',
'SBX': 'SuperBOX',
'SBM': 'Supermax',
'SBR': 'Sber',
'SGE': 'Super General',
'SU': 'SuperSonic',
'79': 'SuperTab',
'STV': 'SuperTV',
'S5': 'Supra',
'SUP': 'Supraim',
'ZS': 'Suzuki',
Expand Down Expand Up @@ -1723,6 +1740,7 @@ module.exports = {
'TUC': 'TUCSON',
'2U': 'Türk Telekom',
'TV': 'TVC',
'TVP': 'TV+',
'TW': 'TWM',
'Z1': 'TWZ',
'6T': 'Twoe',
Expand Down Expand Up @@ -1751,6 +1769,7 @@ module.exports = {
'UGR': 'United Group',
'UO': 'Unnecto',
'UNN': 'Unnion Technologies',
'UNP': 'UnoPhone',
'UU': 'Unonu',
'UN': 'Unowhy',
'UY': 'UNNO',
Expand Down Expand Up @@ -1885,6 +1904,7 @@ module.exports = {
'W2': 'Wigor',
'WI': 'Wiko',
'WF': 'Wileyfox',
'WLR': 'WildRed',
'WS': 'Winds',
'WN': 'Wink',
'9W': 'Winmax',
Expand Down
6 changes: 3 additions & 3 deletions parser/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,18 +238,18 @@ function hasPuffinTabletFragment(userAgent) {
*/
function hasAndroidTVFragment(userAgent) {
return matchUserAgent(
'Andr0id|(?:Android(?: UHD)?|Google) TV|[(]lite[)] TV|BRAVIA|[(]TV;| TV$',
'Andr0id|(?:Android(?: UHD)?|(?<!Xming )Google) TV|\\(lite\\) TV|BRAVIA| TV$',
userAgent
) !== null;
}

/**
* All devices running Tizen TV or SmartTV are assumed to be a tv
* @param {string} userAgent
* @returns {boolean}
* @return {boolean}
*/
function hasTVFragment(userAgent) {
return matchUserAgent('SmartTV|Tizen.+ TV .+$', userAgent) !== null;
return matchUserAgent('SmartTV|Tizen.+ TV .+$|\\(TV;', userAgent) !== null;
}

/**
Expand Down
Loading
Loading