File tree Expand file tree Collapse file tree 3 files changed +18
-12
lines changed Expand file tree Collapse file tree 3 files changed +18
-12
lines changed Original file line number Diff line number Diff line change @@ -28,7 +28,9 @@ function detect (win) {
28
28
}
29
29
30
30
// inject the hook
31
- const script = document . createElement ( 'script' )
32
- script . textContent = ';(' + detect . toString ( ) + ')(window)'
33
- document . documentElement . appendChild ( script )
34
- script . parentNode . removeChild ( script )
31
+ if ( document instanceof HTMLDocument ) {
32
+ const script = document . createElement ( 'script' )
33
+ script . textContent = ';(' + detect . toString ( ) + ')(window)'
34
+ document . documentElement . appendChild ( script )
35
+ script . parentNode . removeChild ( script )
36
+ }
Original file line number Diff line number Diff line change @@ -59,10 +59,12 @@ initDevTools({
59
59
60
60
function injectScript ( scriptName , cb ) {
61
61
const src = `
62
- var script = document.constructor.prototype.createElement.call(document, 'script');
63
- script.src = "${ scriptName } ";
64
- document.documentElement.appendChild(script);
65
- script.parentNode.removeChild(script);
62
+ (function() {
63
+ var script = document.constructor.prototype.createElement.call(document, 'script');
64
+ script.src = "${ scriptName } ";
65
+ document.documentElement.appendChild(script);
66
+ script.parentNode.removeChild(script);
67
+ })()
66
68
`
67
69
chrome . devtools . inspectedWindow . eval ( src , function ( res , err ) {
68
70
if ( err ) {
Original file line number Diff line number Diff line change 2
2
import { installHook } from 'src/backend/hook'
3
3
4
4
// inject the hook
5
- const script = document . createElement ( 'script' )
6
- script . textContent = ';(' + installHook . toString ( ) + ')(window)'
7
- document . documentElement . appendChild ( script )
8
- script . parentNode . removeChild ( script )
5
+ 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 )
10
+ }
You can’t perform that action at this time.
0 commit comments