GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — remove ability to inject arbitrary scripts · react/react@8a6cd3c

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • packages/react-devtools-extensions/src
    • inject.js
    • injectGlobalHook.js
    • main.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

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

Copy file name to clipboardExpand all lines: packages/react-devtools-extensions/src/inject.js
+7-2Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,13 @@
22

33
export default function inject(scriptName: string, done: ?Function) {
44
const source = `
5+
// the prototype stuff is in case document.createElement has been modified
56
(function () {
6-
window.postMessage({ source: 'react-devtools-inject-script', scriptName: "${scriptName}" }, "*");
7+
var script = document.constructor.prototype.createElement.call(document, 'script');
8+
script.src = "${scriptName}";
9+
script.charset = "utf-8";
10+
document.documentElement.appendChild(script);
11+
script.parentNode.removeChild(script);
712
})()
813
`;
914

@@ -16,4 +21,4 @@ export default function inject(scriptName: string, done: ?Function) {
1621
done();
1722
}
1823
});
19-
}
24+
}
Collapse file

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

Copy file name to clipboardExpand all lines: packages/react-devtools-extensions/src/injectGlobalHook.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ window.addEventListener('message', function(evt) {
3131
reactBuildType: evt.data.reactBuildType,
3232
};
3333
chrome.runtime.sendMessage(lastDetectionResult);
34-
} else if (evt.data.source === 'react-devtools-inject-script' && evt.data.scriptName) {
34+
} else if (evt.data.source === 'react-devtools-inject-backend') {
3535
//Inject the specified script
3636
var script = document.constructor.prototype.createElement.call(document, 'script');
37-
script.src = evt.data.scriptName;
37+
script.src = chrome.runtime.getURL('build/backend.js');
3838
script.charset = "utf-8";
3939
document.documentElement.appendChild(script);
4040
script.parentNode.removeChild(script);
Collapse file

‎packages/react-devtools-extensions/src/main.js‎

Copy file name to clipboardExpand all lines: packages/react-devtools-extensions/src/main.js
+12-1Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,18 @@ function createPanelIfReactLoaded() {
135135

136136
// Initialize the backend only once the Store has been initialized.
137137
// Otherwise the Store may miss important initial tree op codes.
138-
inject(chrome.runtime.getURL('build/backend.js'));
138+
chrome.devtools.inspectedWindow.eval(
139+
`window.postMessage({ source: 'react-devtools-inject-backend' });`,
140+
function(response, error) {
141+
if (error) {
142+
console.log(error);
143+
}
144+
145+
if (typeof done === 'function') {
146+
done();
147+
}
148+
}
149+
);
139150

140151
const viewElementSourceFunction = createViewElementSource(
141152
bridge,

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.