Skip to content

Commit 8499c45

Browse files
authored
fix: prevent duplicate output (#235)
1 parent 12b9fd0 commit 8499c45

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

app/scripts/content/main.js

+18-7
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,22 @@
44
var highLighter = require('../modules/content/highLighter.js');
55
var port = utils.getPort();
66

7+
function confirmScriptInjectionDone() {
8+
// Add this action to the Q
9+
// This is needed when the devtools are undocked from the current inspected window
10+
setTimeout(function () {
11+
port.postMessage({
12+
action: 'on-main-script-injection'
13+
});
14+
}, 0);
15+
}
16+
17+
var DONE_FLAG = 'MAIN_SCRIPT_INJECTION_DONE';
18+
if (window[DONE_FLAG] === true) {
19+
confirmScriptInjectionDone();
20+
return;
21+
}
22+
723
// Inject needed scripts into the inspected page
824
// ================================================================================
925

@@ -31,13 +47,8 @@
3147

3248
injectScript('vendor/ToolsAPI.js', function () {
3349
injectScript('scripts/injected/main.js', function () {
34-
// Add this action to the Q
35-
// This is needed when the devtools are undocked from the current inspected window
36-
setTimeout(function () {
37-
port.postMessage({
38-
action: 'on-main-script-injection'
39-
});
40-
}, 0);
50+
window[DONE_FLAG] = true;
51+
confirmScriptInjectionDone();
4152
});
4253
});
4354

0 commit comments

Comments
 (0)