Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
parser.getEngine().version
// OS
result.os.name
result.os.version
parser.getOS().name
parser.getOS().version
// CPU
result.cpu.architecture
parser.getCPU().architecture
// Extensions
var uaString = 'ownbrowser/1.3';
var ownBrowser = [[/(ownbrowser)\/([\w\.]+)/i], [UAParser.BROWSER.NAME, UAParser.BROWSER.VERSION]];
var parser = new UAParser(uaString, { browser: ownBrowser });
}
function test_parser() {
var ua = 'Mozilla/5.0 (Windows NT 6.2) AppleWebKit/536.6 (KHTML, like Gecko) Chrome/20.0.1090.0 Safari/536.6';
var parser = new UAParser(ua);
var result = parser.getResult();
parser.getUA()
parser.setUA("foo")
result.ua
// browser
result.browser.name
result.browser.version
parser.getBrowser().name
parser.getBrowser().version
// device
result.device.model
result.device.type
parser.getEngine().version
// OS
result.os.name
result.os.version
parser.getOS().name
parser.getOS().version
// CPU
result.cpu.architecture
parser.getCPU().architecture
// Extensions
var uaString = 'ownbrowser/1.3';
var ownBrowser = [[/(ownbrowser)\/([\w\.]+)/i], [UAParser.BROWSER.NAME, UAParser.BROWSER.VERSION]];
var parser = new UAParser(uaString, { browser: ownBrowser });
}
///
var UAParser = require('ua-parser-js');
var parser = new UAParser.UAParser();
class P0FService implements IInAppDriver {
match(dev:IDevice, delta:IDriverDetla, cb:Callback) {
//console.log("------------\n P0f match Called", dev.bus.data);
cb(undefined, {});
}
attach(dev:IDevice, delta:IDriverDetla, matchResult:any, cb:PCallback) {
console.log("P0f ATTACH Called");
cb(undefined, {valid: true});
}
change(dev:IDevice, delta:IDriverDetla, cb:PCallback) {
var runtimekey = 'App_' + global.runtime_id + ':P0F';
var devAssump = dev.assumptions[runtimekey];
| "Firefox" // desktop and mobile
| "Safari" | "Mobile Safari" // desktop and mobile
// supported, but not promoted (eg, mentioned in browser-not-supported warning)
| "Chrome WebView" // android-browser
| "Edge" // desktop and mobile (they're the same);
type BrowserName =
| "Amaya" | "Android Browser" | "Arora" | "Avant" | "Baidu" | "Blazer" | "Bolt" | "Camino" | "Chimera" | "Chrome"
| "Chromium" | "Comodo Dragon" | "Conkeror" | "Dillo" | "Dolphin" | "Doris" | "Edge" | "Epiphany" | "Fennec"
| "Firebird" | "Firefox" | "Flock" | "GoBrowser" | "iCab" | "ICE Browser" | "IceApe" | "IceCat" | "IceDragon"
| "Iceweasel" | "IE" | "IE Mobile" | "Iron" | "Jasmine" | "K-Meleon" | "Konqueror" | "Kindle" | "Links"
| "Lunascape" | "Lynx" | "Maemo" | "Maxthon" | "Midori" | "Minimo" | "MIUI Browser" | "Safari" | "Mobile Safari"
| "Mosaic" | "Mozilla" | "Netfront" | "Netscape" | "NetSurf" | "Nokia" | "OmniWeb" | "Opera" | "Opera Mini" | "Opera Mobi" | "Opera Tablet"
| "PhantomJS" | "Phoenix" | "Polaris" | "QQBrowser" | "RockMelt" | "Silk" | "Skyfire" | "SeaMonkey" | "SlimBrowser"
| "Swiftfox" | "Tizen" | "UCBrowser" | "Vivaldi" | "w3m" | "WeChat" | "Yandex";
let parser = new UAParser();
export function GetBrowser(): {name: BrowserName, version: string} {
return parser.getBrowser();
}
/*export function GetBrowserName(): BrowserName {
return parser.getBrowser().name;
}
export function GetBrowserVersion(): string {
return parser.getBrowser().version;
}*/
export function browserCapabilities(userAgent: string): Set {
const ua = new UAParser(userAgent);
const capabilities = new Set();
let browserName = ua.getBrowser().name || '';
if (browserName === 'Chrome' && ua.getOS().name === 'iOS') {
// Chrome on iOS is really Safari.
browserName = 'Mobile Safari';
}
const predicates = browserPredicates[browserName] || {};
for (const capability of Object.keys(predicates) as BrowserCapability[]) {
if (predicates[capability](ua)) {
capabilities.add(capability);
}
}
return capabilities;
}
const isRunningInIE = () => {
const browser = new UAParser().getBrowser().name
return browser && browser.indexOf('IE') !== -1
}
},
link: {
color: colors.fullWhite
},
purple: {
background: `linear-gradient(22.5deg, rgba(103, 58, 183, .75), ${colors.deepPurple500})`
},
blue: {
background: `linear-gradient(22.5deg, rgba(33, 150, 243, .75), ${colors.blue500})`
},
green: {
background: `linear-gradient(22.5deg, rgba(76, 175, 80, .75), ${colors.green500})`
}
}
const userAgent = new UAParser()
const browser = userAgent.getBrowser().name
const os = userAgent.getOS().name
const Warn = () => {
return (
<div>
<div style="{[styles.cell,">
<title title="Radiate">
<div style={styles.copy}>
Radiate is a responsive dashboard written in React - built for all screen sizes
</div>
</div>
<div style={[styles.cell, styles.blue]}>
<Title title='Enabling CSS Grid Layout' />
<div style={styles.copy}></title></div></div>
static isRunningInIE() {
if (isRunningInIE === null) {
const browser = new UAParser().getBrowser().name
isRunningInIE = !!browser && browser.indexOf('IE') !== -1
}
return isRunningInIE
}
export function browserCapabilities(userAgent: string): Set {
const ua = new UAParser(userAgent);
const capabilities = new Set();
const predicates = browserPredicates[ua.getBrowser().name] || {};
for (const capability of Object.keys(predicates) as BrowserCapability[]) {
if (predicates[capability](ua)) {
capabilities.add(capability);
}
};
return capabilities;
}