Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change script injection approach to use a temporary <script tag #1164

Merged
merged 2 commits into from
Dec 18, 2023

Conversation

phryneas
Copy link
Member

This would potentially fix #1162, #937 and #839

It's just a temporary fix though, as for Chrome we'll have to switch to manifest v3 soon, but it will be less of a problem there since that allows to inject content scripts into ExecutionWorld.MAIN.

@phryneas phryneas requested a review from a team as a code owner December 14, 2023 13:37
document.getElementsByTagName("head")[0] ||
document.documentElement;
head.insertBefore(script, head.lastChild);
script.textContent = code;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By retrieving the text and using textContent, we can synchronously insert and remove the injected script tag with no change of any hydration being confused by it.

@alessbell
Copy link
Member

Just wondering @phryneas: have you tried building the devtools locally with this fix and testing with sites where we see this issue? No problem if not, I can run the repro in a bit myself.

@phryneas
Copy link
Member Author

phryneas commented Dec 14, 2023

@alessbell I've built them using yarn run firefox and yarn run chrome, and in both cases atlassian.com did load up and window.__APOLLO_DEVTOOLS_GLOBAL_HOOK__ was correctly initialized.
I also tried Firefox & Chrome on a page that uses Apollo Client and could interact with the DevTools.

@alessbell
Copy link
Member

SGTM @phryneas, let's add a changeset and 🚀

@phryneas phryneas merged commit f57d124 into main Dec 18, 2023
5 checks passed
@phryneas phryneas deleted the pr/injectSyncScript branch December 18, 2023 17:25
@github-actions github-actions bot mentioned this pull request Dec 18, 2023
alessbell added a commit that referenced this pull request Dec 20, 2023
alessbell added a commit that referenced this pull request Dec 20, 2023
#1169)

* Revert "change script injection approach to use a temporary `<script` tag (#1164)"

This reverts commit f57d124.

* chore: add changeset
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Extension prevents websites (tested on atlassian.com) from loading styles
2 participants