mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Moved injection logic to content script
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
||||
/* global chrome */
|
||||
|
||||
export default function inject(scriptName: string, done: ? Function) {
|
||||
export default function inject(scriptName: string, done: ?Function) {
|
||||
const source = `
|
||||
(function () {
|
||||
window.postMessage({ source: 'react-devtools-inject-script', scriptName: "${scriptName}" }, "*");
|
||||
|
||||
@@ -37,8 +37,8 @@ window.addEventListener('message', function(evt) {
|
||||
reactBuildType: evt.data.reactBuildType,
|
||||
};
|
||||
chrome.runtime.sendMessage(lastDetectionResult);
|
||||
} else if (evt.data.source === 'react-devtools-inject-backend' && evt.data.scriptName) {
|
||||
//Inject backend
|
||||
} else if (evt.data.source === 'react-devtools-inject-script' && evt.data.scriptName) {
|
||||
//Inject the specified script
|
||||
var script = document.constructor.prototype.createElement.call(document, 'script');
|
||||
script.src = evt.data.scriptName;
|
||||
script.charset = "utf-8";
|
||||
|
||||
Reference in New Issue
Block a user