Utilize navigator.userAgentData as a fallback #588

This commit is contained in:
Faisal Salman 2023-01-25 01:05:50 +07:00
parent 5d4ca2b4c2
commit 1a521b867f

View File

@ -775,6 +775,7 @@
} }
var _ua = ua || ((typeof window !== UNDEF_TYPE && window.navigator && window.navigator.userAgent) ? window.navigator.userAgent : EMPTY); var _ua = ua || ((typeof window !== UNDEF_TYPE && window.navigator && window.navigator.userAgent) ? window.navigator.userAgent : EMPTY);
var _uach = (typeof window !== UNDEF_TYPE && window.navigator && window.navigator.userAgentData) ? window.navigator.userAgentData : undefined;
var _rgxmap = extensions ? extend(regexes, extensions) : regexes; var _rgxmap = extensions ? extend(regexes, extensions) : regexes;
this.getBrowser = function () { this.getBrowser = function () {
@ -797,6 +798,9 @@
_device[MODEL] = undefined; _device[MODEL] = undefined;
_device[TYPE] = undefined; _device[TYPE] = undefined;
rgxMapper.call(_device, _ua, _rgxmap.device); rgxMapper.call(_device, _ua, _rgxmap.device);
if (!_device[TYPE] && _uach && _uach.mobile) {
_device[TYPE] = MOBILE;
}
return _device; return _device;
}; };
this.getEngine = function () { this.getEngine = function () {
@ -811,6 +815,9 @@
_os[NAME] = undefined; _os[NAME] = undefined;
_os[VERSION] = undefined; _os[VERSION] = undefined;
rgxMapper.call(_os, _ua, _rgxmap.os); rgxMapper.call(_os, _ua, _rgxmap.os);
if (!_os[NAME] && _uach && _uach.platform != 'Unknown') {
_os[NAME] = _uach.platform.replace(/chrome/i, 'Chromium').replace(/mac/i, 'Mac ');
}
return _os; return _os;
}; };
this.getResult = function () { this.getResult = function () {