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

break glass in case of emergency #921

Closed
wants to merge 10 commits into from

Conversation

marcustyphoon
Copy link
Collaborator

@marcustyphoon marcustyphoon commented Dec 18, 2022

Description

There may be a better way to do this, but it does work.

This moves all of the injected function bodies into another content script and injects that content script into the page context using the world flag in Chromium's dynamic content script feature (current Firefox does not appear to have this). The sandboxed content script containing all of XKit Rewritten's actual code communicates with the unsandboxed one via DOM CustomEvents (see #920) in both directions, requesting an injected call and receiving a response.

I wasn't sure how to pass the target element (if any) to the injected functions, since document.currentScript doesn't work here; at the moment I just appended it to the argument list, which is kind of awkward.

Oh, this also bumps the manifest_version key in the manifest file. Not sure what that does.

hypothetical todo: ensure that the unsandboxed content script has finished loading before proceeding in main.js

Testing steps

@AprilSylph
Copy link
Owner

we can still inject scripts from content scripts as normal, the injected scripts just need to be their own file (and referenced by web accessible URL). something something content security policy

@AprilSylph
Copy link
Owner

@marcustyphoon
Copy link
Collaborator Author

marcustyphoon commented Dec 18, 2022

I saw that method mentioned in another thread, yeah! Seems viable. I'm not sure if it's doable while keeping instant processing (didn't try) and I couldn't think of a way not to duplicate the boilerplate "send back the result" code in every file, but I didn't play with it at all yet.

Edit: Oh, actually, that would work as a way to inject the single unsandboxed handler function in this method, too, rather than using the dynamic content script thing. That would probably work in the firefox mv3 prerelease.

@marcustyphoon
Copy link
Collaborator Author

@marcustyphoon
Copy link
Collaborator Author

Closing currently-inactive PRs for cleanup.

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.

None yet

2 participants