File tree Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -75,13 +75,19 @@ export function isBrowser(): boolean {
75
75
/**
76
76
* Detect browser extensions (Chrome and Firefox at least).
77
77
*/
78
- declare const chrome : { runtime ?: unknown } ;
79
- declare const browser : { runtime ?: unknown } ;
78
+ interface BrowserRuntime {
79
+ id ?: unknown ;
80
+ }
81
+ declare const chrome : { runtime ?: BrowserRuntime } ;
82
+ declare const browser : { runtime ?: BrowserRuntime } ;
80
83
export function isBrowserExtension ( ) : boolean {
81
- return (
82
- ( typeof chrome === 'object' && chrome . runtime !== undefined ) ||
83
- ( typeof browser === 'object' && browser . runtime !== undefined )
84
- ) ;
84
+ const runtime =
85
+ typeof chrome === 'object'
86
+ ? chrome . runtime
87
+ : typeof browser === 'object'
88
+ ? browser . runtime
89
+ : undefined ;
90
+ return typeof runtime === 'object' && runtime . id !== undefined ;
85
91
}
86
92
87
93
/**
You can’t perform that action at this time.
0 commit comments