Skip to content

Commit 68bc313

Browse files
committed
Remove the injected script after being executed
Fix #63.
1 parent a7efbc0 commit 68bc313

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

src/browser/extension/inject/pageScriptWrap.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
let s = document.createElement('script');
2+
s.type = 'text/javascript';
23

34
if (process.env.NODE_ENV === 'production') {
45
const script = require('raw!tmp/page.bundle.js');
56
s.appendChild(document.createTextNode(script));
7+
(document.head || document.documentElement).appendChild(s);
8+
s.parentNode.removeChild(s);
69
} else {
710
s.src = chrome.extension.getURL('js/page.bundle.js');
11+
s.onload = function() {
12+
this.parentNode.removeChild(this);
13+
};
14+
(document.head || document.documentElement).appendChild(s);
815
}
9-
10-
s.type = 'text/javascript';
11-
s.onload = function() {
12-
this.parentNode.removeChild(this);
13-
};
14-
(document.head || document.documentElement).appendChild(s);

src/browser/extension/options/syncOptions.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,8 @@ const injectOptions = newOptions => {
4646
let s = document.createElement('script');
4747
s.type = 'text/javascript';
4848
s.appendChild(document.createTextNode('window.devToolsOptions=' + JSON.stringify(options)));
49-
s.onload = function() {
50-
this.parentNode.removeChild(this);
51-
};
5249
(document.head || document.documentElement).appendChild(s);
50+
s.parentNode.removeChild(s);
5351
};
5452

5553
export const getOptionsFromBg = () => {

0 commit comments

Comments
 (0)