mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Moved backend injection logic to content script
This commit is contained in:
+1
-1
@@ -3,7 +3,7 @@
|
||||
export default function inject(scriptName: string, done: ? Function) {
|
||||
const source = `
|
||||
(function () {
|
||||
window.postMessage({ source: 'react-devtools-inject-backend', type: "FROM_PAGE", text: "Hello from the webpage!" }, "*");
|
||||
window.postMessage({ source: 'react-devtools-inject-script', scriptName: "${scriptName}" }, "*");
|
||||
})()
|
||||
`;
|
||||
|
||||
|
||||
@@ -37,10 +37,10 @@ window.addEventListener('message', function(evt) {
|
||||
reactBuildType: evt.data.reactBuildType,
|
||||
};
|
||||
chrome.runtime.sendMessage(lastDetectionResult);
|
||||
} else if (evt.data.source === 'react-devtools-inject-backend') {
|
||||
} else if (evt.data.source === 'react-devtools-inject-backend' && evt.data.scriptName) {
|
||||
//Inject backend
|
||||
var script = document.constructor.prototype.createElement.call(document, 'script');
|
||||
script.src = chrome.runtime.getURL('build/backend.js');
|
||||
script.src = evt.data.scriptName;
|
||||
script.charset = "utf-8";
|
||||
document.documentElement.appendChild(script);
|
||||
script.parentNode.removeChild(script);
|
||||
@@ -97,4 +97,4 @@ if (sessionStorageGetItem(SESSION_STORAGE_RELOAD_AND_PROFILE_KEY) === 'true') {
|
||||
// devtools are installed (and skip its suggestion to install the devtools).
|
||||
injectCode(
|
||||
';(' + installHook.toString() + '(window))' + saveNativeValues + detectReact,
|
||||
);
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user