Skip to content

Commit 788036c

Browse files
committed
Moved backend injection logic to content script
1 parent c93038f commit 788036c

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

packages/react-devtools-extensions/src/inject.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
export default function inject(scriptName: string, done: ? Function) {
44
const source = `
55
(function () {
6-
window.postMessage({ source: 'react-devtools-inject-backend', type: "FROM_PAGE", text: "Hello from the webpage!" }, "*");
6+
window.postMessage({ source: 'react-devtools-inject-script', scriptName: "${scriptName}" }, "*");
77
})()
88
`;
99

packages/react-devtools-extensions/src/injectGlobalHook.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ window.addEventListener('message', function(evt) {
3737
reactBuildType: evt.data.reactBuildType,
3838
};
3939
chrome.runtime.sendMessage(lastDetectionResult);
40-
} else if (evt.data.source === 'react-devtools-inject-backend') {
40+
} else if (evt.data.source === 'react-devtools-inject-backend' && evt.data.scriptName) {
4141
//Inject backend
4242
var script = document.constructor.prototype.createElement.call(document, 'script');
43-
script.src = chrome.runtime.getURL('build/backend.js');
43+
script.src = evt.data.scriptName;
4444
script.charset = "utf-8";
4545
document.documentElement.appendChild(script);
4646
script.parentNode.removeChild(script);
@@ -97,4 +97,4 @@ if (sessionStorageGetItem(SESSION_STORAGE_RELOAD_AND_PROFILE_KEY) === 'true') {
9797
// devtools are installed (and skip its suggestion to install the devtools).
9898
injectCode(
9999
';(' + installHook.toString() + '(window))' + saveNativeValues + detectReact,
100-
);
100+
);

0 commit comments

Comments
 (0)