Skip to content

Commit 4f29180

Browse files
committed
Inject page script from a separate module
1 parent a84e5bc commit 4f29180

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

src/browser/extension/inject/contentScript.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,6 @@ if (window.devToolsExtensionID) { // Send external messages
2222
};
2323
} else {
2424
sendMessage = sendToBg;
25-
26-
let s = document.createElement('script');
27-
s.src = chrome.extension.getURL('js/page.bundle.js');
28-
s.onload = function() {
29-
this.parentNode.removeChild(this);
30-
};
31-
(document.head || document.documentElement).appendChild(s);
3225
}
3326

3427
// Resend messages from the page to the background script
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
let s = document.createElement('script');
2+
s.src = chrome.extension.getURL('js/page.bundle.js');
3+
s.onload = function() {
4+
this.parentNode.removeChild(this);
5+
};
6+
(document.head || document.documentElement).appendChild(s);

src/browser/extension/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
{
2727
"matches": ["<all_urls>"],
2828
"exclude_globs": [ "https://www.google*" ],
29-
"js": ["js/content.bundle.js"],
29+
"js": ["js/content.bundle.js", "js/pagewrap.bundle.js"],
3030
"run_at": "document_start"
3131
}
3232
],

webpack/base.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const baseConfig = (params) => ({
1212
devtools: [ `${extpath}devtools/index` ],
1313
content: [ `${extpath}inject/contentScript` ],
1414
page: [ `${extpath}inject/pageScript` ],
15+
pagewrap: [ `${extpath}inject/pageScriptWrap` ],
1516
inject: [ `${extpath}inject/index` ],
1617
...params.inputExtra
1718
},

0 commit comments

Comments
 (0)