all files / common/ user-agent.js

95.83% Statements 46/48
93.62% Branches 44/47
100% Functions 7/7
95.83% Lines 46/48
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72   9923× 9923×   60241× 3220×   57021× 1805×   55216× 541×   54675× 47625×   7050× 1427×   5623× 1868×   3755×   3520× 3520× 623× 623× 1869× 1869×     1869×         3520× 3293×   227× 55×   172× 20×   152×   150×   3511× 131×   3380×   3247× 3247×        
define(["require", "exports"], function (require, exports) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var CustomUserAgentData = (function () {
        function CustomUserAgentData(userAgent, testing) {
            this.userAgent = userAgent;
            this.isTesting = testing;
        }
        CustomUserAgentData.prototype.getPlatform = function () {
            if (!this.isTesting && window.navigator.userAgentData) {
                return window.navigator.userAgentData.platform;
            }
            if (/windows/i.test(this.userAgent)) {
                return 'Windows';
            }
            if (/macintosh|mac os/i.test(this.userAgent) && !(/iphone|ipad|ipod/i.test(this.userAgent))) {
                return 'macOS';
            }
            if (/linux/i.test(this.userAgent) && !(/android/i.test(this.userAgent))) {
                return 'Linux';
            }
            if (/iphone|ipad|ipod/i.test(this.userAgent)) {
                return 'iOS';
            }
            if (/android/i.test(this.userAgent)) {
                return 'Android';
            }
            return 'Unknown';
        };
        CustomUserAgentData.prototype.getBrowser = function () {
            var brands = [];
            if (!this.isTesting && window.navigator.userAgentData) {
                brands = window.navigator.userAgentData.brands;
                for (var _i = 0, brands_1 = brands; _i < brands_1.length; _i++) {
                    var brand = brands_1[_i];
                    Iif (brand.brand === 'Google Chrome') {
                        return 'Chrome';
                    }
                    else Iif (brand.brand === 'Microsoft Edge') {
                        return 'Edge';
                    }
                }
            }
            if (/chrome|chromium|crios/i.test(this.userAgent) && !/edg/i.test(this.userAgent)) {
                return 'Chrome';
            }
            if (/firefox|fxios/i.test(this.userAgent) && !/edg/i.test(this.userAgent)) {
                return 'Firefox';
            }
            if (/safari/i.test(this.userAgent) && !/chrome|chromium|crios/i.test(this.userAgent)) {
                return 'Safari';
            }
            if (/edg/i.test(this.userAgent)) {
                return 'Edge';
            }
            return 'Unknown';
        };
        CustomUserAgentData.prototype.isMobileDevice = function () {
            if (!this.isTesting && window.navigator.userAgentData) {
                return window.navigator.userAgentData.mobile;
            }
            return /(iphone|ipod|ipad|android|blackberry|bb|playbook|windows phone|webos|opera mini|mobile)/i.test(this.userAgent);
        };
        CustomUserAgentData.prototype.isSafari = function () {
            var platform = this.getPlatform();
            return this.getBrowser() === 'Safari' && (platform === 'macOS' || platform === 'iOS');
        };
        return CustomUserAgentData;
    }());
    exports.CustomUserAgentData = CustomUserAgentData;
});