File tree 3 files changed +26
-8
lines changed
3 files changed +26
-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,15 @@ 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-next-line no-eval
44
+ window . eval ( source ) // in Firefox, this evaluates on the content window
45
+ } else {
46
+ const script = document . createElement ( 'script' )
47
+ script . textContent = source
48
+ document . documentElement . appendChild ( script )
49
+ script . parentNode . removeChild ( script )
50
+ }
43
51
}
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-next-line no-eval
11
+ window . eval ( source ) // in Firefox, this evaluates on the content window
12
+ } else {
13
+ const script = document . createElement ( 'script' )
14
+ script . textContent = source
15
+ document . documentElement . appendChild ( script )
16
+ script . parentNode . removeChild ( script )
17
+ }
10
18
}
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 . indexOf ( 'Firefox' ) > - 1
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
@@ -16,6 +17,7 @@ export function initEnv (Vue) {
16
17
17
18
Object . defineProperties ( Vue . prototype , {
18
19
'$isChrome' : { get : ( ) => isChrome } ,
20
+ '$isFirefox' : { get : ( ) => isFirefox } ,
19
21
'$isWindows' : { get : ( ) => isWindows } ,
20
22
'$isMac' : { get : ( ) => isMac } ,
21
23
'$isLinux' : { get : ( ) => isLinux } ,
You can’t perform that action at this time.
0 commit comments