Skip to content

Commit 71766cd

Browse files
committed
simplify
1 parent 0f198c0 commit 71766cd

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

src/lib/browser-detect.js

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,22 @@
33
*/
44

55
/**
6-
* Check if running in Chrome (not Chromium-based browsers like Edge)
6+
* Check if running in Chrome.
77
* Google Tasks backend only works in Chrome due to chrome.identity API requirements
88
*/
99
export function isChrome() {
10-
if (typeof chrome === 'undefined') {
11-
return false
12-
}
13-
14-
// Check for Chrome-specific APIs
15-
const hasChromeIdentity = chrome.identity && typeof chrome.identity.getAuthToken === 'function'
16-
17-
// Chrome has a specific runtime structure
18-
const isChromeRuntime = chrome.runtime && chrome.runtime.id !== undefined
19-
20-
return hasChromeIdentity && isChromeRuntime
10+
return (
11+
typeof chrome !== 'undefined' &&
12+
chrome.identity?.getAuthToken !== undefined &&
13+
chrome.runtime?.id !== undefined
14+
)
2115
}
2216

2317
/**
2418
* Check if running in Firefox
2519
*/
2620
export function isFirefox() {
27-
return typeof browser !== 'undefined' && browser.runtime && browser.runtime.id !== undefined
21+
return typeof browser !== 'undefined' && browser.runtime?.id !== undefined
2822
}
2923

3024
/**

0 commit comments

Comments
 (0)