forked from facebook/react
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.js
More file actions
30 lines (25 loc) · 906 Bytes
/
utils.js
File metadata and controls
30 lines (25 loc) · 906 Bytes
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
/* global chrome */
const IS_CHROME = navigator.userAgent.indexOf('Firefox') < 0;
export type BrowserName = 'Chrome' | 'Firefox';
export function getBrowserName(): BrowserName {
return IS_CHROME ? 'Chrome' : 'Firefox';
}
export type BrowserTheme = 'dark' | 'light';
export function getBrowserTheme(): BrowserTheme {
if (IS_CHROME) {
// chrome.devtools.panels added in Chrome 18.
// chrome.devtools.panels.themeName added in Chrome 54.
return chrome.devtools.panels.themeName === 'dark' ? 'dark' : 'light';
} else {
// chrome.devtools.panels.themeName added in Firefox 55.
// https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/devtools.panels/themeName
if (chrome.devtools && chrome.devtools.panels) {
switch (chrome.devtools.panels.themeName) {
case 'dark':
return 'dark';
default:
return 'light';
}
}
}
}