File tree 3 files changed +27
-8
lines changed
3 files changed +27
-8
lines changed Original file line number Diff line number Diff line change 1
1
import { installToast } from 'src/backend/toast'
2
+ import { isFirefox } from 'src/devtools/env'
2
3
3
4
window . addEventListener ( 'message' , e => {
4
5
if ( e . source === window && e . data . vueDetected ) {
@@ -36,8 +37,16 @@ if (document instanceof HTMLDocument) {
36
37
}
37
38
38
39
function installScript ( fn ) {
39
- const script = document . createElement ( 'script' )
40
- script . textContent = ';(' + fn . toString ( ) + ')(window)'
41
- document . documentElement . appendChild ( script )
42
- script . parentNode . removeChild ( script )
40
+ const source = ';(' + fn . toString ( ) + ')(window)'
41
+
42
+ if ( isFirefox ) {
43
+ /* eslint-disable no-eval */
44
+ window . eval ( source ) // in Firefox, this evaluates on the content window
45
+ /* eslint-enable no-eval */
46
+ } else {
47
+ const script = document . createElement ( 'script' )
48
+ script . textContent = source
49
+ document . documentElement . appendChild ( script )
50
+ script . parentNode . removeChild ( script )
51
+ }
43
52
}
Original file line number Diff line number Diff line change 1
1
// This script is injected into every page.
2
2
import { installHook } from 'src/backend/hook'
3
+ import { isFirefox } from 'src/devtools/env'
3
4
4
5
// inject the hook
5
6
if ( document instanceof HTMLDocument ) {
6
- const script = document . createElement ( 'script' )
7
- script . textContent = ';(' + installHook . toString ( ) + ')(window)'
8
- document . documentElement . appendChild ( script )
9
- script . parentNode . removeChild ( script )
7
+ const source = ';(' + installHook . toString ( ) + ')(window)'
8
+
9
+ if ( isFirefox ) {
10
+ /* eslint-disable no-eval */
11
+ window . eval ( source ) // in Firefox, this evaluates on the content window
12
+ /* eslint-enable no-eval */
13
+ } else {
14
+ const script = document . createElement ( 'script' )
15
+ script . textContent = source
16
+ document . documentElement . appendChild ( script )
17
+ script . parentNode . removeChild ( script )
18
+ }
10
19
}
Original file line number Diff line number Diff line change 1
1
export const isChrome = typeof chrome !== 'undefined' && ! ! chrome . devtools
2
+ export const isFirefox = navigator . userAgent . startsWith ( 'Mozilla' )
2
3
export const isWindows = navigator . platform . indexOf ( 'Win' ) === 0
3
4
export const isMac = navigator . platform === 'MacIntel'
4
5
export const isLinux = navigator . platform . indexOf ( 'Linux' ) === 0
You can’t perform that action at this time.
0 commit comments