File tree Expand file tree Collapse file tree 2 files changed +15
-13
lines changed Expand file tree Collapse file tree 2 files changed +15
-13
lines changed Original file line number Diff line number Diff line change @@ -55,7 +55,7 @@ function attachScript(tabId, changed) {
55
55
56
56
toolsPorts . get ( tabId ) . postMessage ( { type : 'init' } )
57
57
chrome . tabs . executeScript ( tabId , {
58
- code : `const profilerEnabled = ${ profilerEnabledList . includes ( tabId ) } ` ,
58
+ code : `window. profilerEnabled = ${ profilerEnabledList . includes ( tabId ) } ` ,
59
59
runAt : 'document_start'
60
60
} )
61
61
chrome . tabs . executeScript ( tabId , {
@@ -69,7 +69,7 @@ function setup(tabId, port) {
69
69
port . onDisconnect . addListener ( ( ) => {
70
70
toolsPorts . delete ( tabId )
71
71
pagePorts . delete ( tabId )
72
- const i = profilerEnabledList . indexOf ( msg . tabId )
72
+ const i = profilerEnabledList . indexOf ( tabId )
73
73
if ( i != - 1 ) profilerEnabledList . slice ( i , 1 )
74
74
chrome . tabs . onUpdated . removeListener ( attachScript )
75
75
} )
Original file line number Diff line number Diff line change @@ -36,18 +36,20 @@ export default [{
36
36
file : 'dest/privilegedContent.js' ,
37
37
name : 'SvelteDevtools' ,
38
38
format : 'iife' ,
39
- banner : `const tag = document.createElement('script')
40
- tag.text = \`` ,
39
+ banner : `if (!window.tag) {
40
+ window.tag = document.createElement('script')
41
+ window.tag.text = \`` ,
41
42
footer : `\`
42
- if (profilerEnabled) tag.text = tag.text.replace('let profilerEnabled = false;', '\$&\\nstartProfiler();')
43
- document.children[0].append(tag)
44
- const port = chrome.runtime.connect()
45
- port.onMessage.addListener(window.postMessage.bind(window))
46
- window.addEventListener(
47
- 'message',
48
- e => e.source == window && port.postMessage(e.data),
49
- false
50
- )`
43
+ if (window.profilerEnabled) window.tag.text = window.tag.text.replace('let profilerEnabled = false;', '\$&\\nstartProfiler();')
44
+ document.children[0].append(window.tag)
45
+ const port = chrome.runtime.connect()
46
+ port.onMessage.addListener(window.postMessage.bind(window))
47
+ window.addEventListener(
48
+ 'message',
49
+ e => e.source == window && port.postMessage(e.data),
50
+ false
51
+ )
52
+ }`
51
53
} ,
52
54
plugins : [ resolve ( ) ]
53
55
} , {
You can’t perform that action at this time.
0 commit comments