forked from darkreader/darkreader
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplatform.ts
More file actions
62 lines (52 loc) · 1.48 KB
/
Copy pathplatform.ts
File metadata and controls
62 lines (52 loc) · 1.48 KB
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
export function isFirefox() {
return navigator.userAgent.includes('Firefox');
}
export function isVivaldi() {
return navigator.userAgent.toLowerCase().includes('vivaldi');
}
export function isYaBrowser() {
return navigator.userAgent.toLowerCase().includes('yabrowser');
}
export function isOpera() {
const agent = navigator.userAgent.toLowerCase();
return agent.includes('opr') || agent.includes('opera');
}
export function isEdge() {
return navigator.userAgent.includes('Edg');
}
export function isWindows() {
return navigator.platform.toLowerCase().startsWith('win');
}
export function isMacOS() {
return navigator.platform.toLowerCase().startsWith('mac');
}
export function isMobile() {
const agent = navigator.userAgent.toLowerCase();
return agent.includes('mobile');
}
export function getChromeVersion() {
const agent = navigator.userAgent.toLowerCase();
const m = agent.match(/chrom[e|ium]\/([^ ]+)/);
if (m && m[1]) {
return m[1];
}
return null;
}
export function compareChromeVersions($a: string, $b: string) {
const a = $a.split('.').map((x) => parseInt(x));
const b = $b.split('.').map((x) => parseInt(x));
for (let i = 0; i < a.length; i++) {
if (a[i] !== b[i]) {
return a[i] < b[i] ? -1 : 1;
}
}
return 0;
}
export function isDeepSelectorSupported() {
try {
document.querySelector('x /deep/ x');
return true;
} catch (err) {
return false;
}
}