@samitouri / QOS-React-2 / commits / 85c7211014

Moved injection logic to content script

Stephanie Ding committed Sep 10, 2019 at 17:45 UTC 85c7211014a1364fef8d0c3da512ddf63fb408e8
2 files changed +3 -3
packages/react-devtools-extensions/src/inject.js
+1 -1
@@ -1,6 +1,6 @@
1 /* global chrome */
2
3 -export default function inject(scriptName: string, done: ? Function) {
3 +export default function inject(scriptName: string, done: ?Function) {
4 const source = `
5 (function () {
6 window.postMessage({ source: 'react-devtools-inject-script', scriptName: "${scriptName}" }, "*");
packages/react-devtools-extensions/src/injectGlobalHook.js
+2 -2
@@ -37,8 +37,8 @@ window.addEventListener('message', function(evt) {
37 reactBuildType: evt.data.reactBuildType,
38 };
39 chrome.runtime.sendMessage(lastDetectionResult);
40 - } else if (evt.data.source === 'react-devtools-inject-backend' && evt.data.scriptName) {
41 - //Inject backend
40 + } else if (evt.data.source === 'react-devtools-inject-script' && evt.data.scriptName) {
41 + //Inject the specified script
42 var script = document.constructor.prototype.createElement.call(document, 'script');
43 script.src = evt.data.scriptName;
44 script.charset = "utf-8";