chrome userScript world proof of concept #2149
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I kind of doubt the extension stores would count this as kosher, but.
This is an incomplete but working proof of concept for running the entirety of New XKit in Chrome's MV3 "userScript" world, which is kind of like ISOLATED except you're allowed to run strings (not currently used) and set CSP. Firefox will get this feature eventually.
This version uses
script-src 'self' 'unsafe-inline' 'unsafe-eval'
as the CSP value, which is of course not particularly secure; in this form what the PR does is effectively whitelisting the privileged extension APIs our insecurely-executed-out-of-storage code can access. We basically only needstorage.local
.There's no technical reason one can't remove
'unsafe-inline'
(using XKit Rewritten's MV3 injection method; I have this implemented in test builds already) or even potentially'unsafe-eval'
(by grabbing the enabled script bodies from storage in the background script and injecting them as part of thebrowser.userScripts.update
call; this sounds rather annoying to refactor). Doing both of those would be fairly interesting.But doing the rest of this work and bugfixing the large number of ways to break things using mismatched stored script versions would be waiting on a Firefox implementation and gambling on the extension stores considering this a valid use of the new userScript API, just in order to preserve the XKit Editor functionality in an extension that's, to a first-order approximation, broken. Simply following the MV3 guidelines and removing the editor is a simpler way to let this codebase live on.