-
Notifications
You must be signed in to change notification settings - Fork 457
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
Manifest V3 and Content-Security-Policy in GMail prevent loading extension script via addScript #798
Comments
The initial culprit that the approach similar to extensionInjector.js are no longer supported. Gmail started sending Content-Security-Policy headers which disallows loading subsequent scripts. But the initial content script are injected okay. |
So resolution is the following. I.e. this will not work anymore: https://github.com/josteink/gmailjs-node-boilerplate/blob/dda13306bb24083504185bc20db6cce55b4a71dd/src/extensionInjector.js#L3 Workaround: load extension script from service worker, i.e. using scripting capabilities.
And extension injector must send message to inject, i.e.
|
These errors happen because if you load compiled script (gmail.js + my extension) directly via content script declared in manifest, it gets loaded in ISOLATED world without access to DOM, XHR, fetch. Only loading script using |
That's very impressive digging @huksley. Thanks for the assistance! If you could prepare a PR which updates the boilerplate with your findings, I would be extremely grateful! 😊 |
I faced same problem, but i use gmail-js with vite and csxjs vite plugine. this request have fix for this problem crxjs/chrome-extension-tools@f4eb4d4 main problem was in manifest.json and may be this issue will usefull crxjs/chrome-extension-tools#918 |
I've tested with three accounts:
I cannot reproduce CSP issues or loading issues at all in any of those configurations. Can you provide some leads/insights into what accounts you guys have when you can reproduce this issue? For reference, this is the CSP headers I'm currently getting:
|
Any account in new Chrome 130 |
what a can of worms(((
@josteink try setting use_dynamic_url: true
I don't even know where I took this, I believe some official docs recommended it?! |
I've spent half the day trying:
For reference in my extension I have:
And everything works fine on my end! So can someone tell me what I'm missing? Why would I want to enable From the surface of things, to me it sounds like this might be more of a gmail+extension general issue, than gmailjs issue? Or am I wrong? |
Well, AFAIK this problem happens if some one used use_dynamic_url: true https://issues.chromium.org/issues/354748637 Btw, one thing I noticed, that the way I am loading the extension now, sometimes, if you open new tab and type mail.google.com, the extension does not load. if you reload a page it load successfully. Some maybe this issue is not applicable to Gmail.js but this use of |
Ok. So What scenarios does it enable that you wouldn't be able to do otherwise? 🤷 |
Looks like new changes Gmail broke many functionality in gmail-js.
For example
this.gmail.observe.before("send_message", () => handler())
stopped working.I can see the following messages in the console:
The text was updated successfully, but these errors were encountered: