-
Notifications
You must be signed in to change notification settings - Fork 438
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
CSPs, @require and webpack #871
Comments
Local file requires are injected the same way all other requires are, but they are not cached and loaded every time which might lead to slightly different injection speed. See #721. Maybe this is the issue? Can you please name a page where this is happening? |
Twitter, for example. I use webpack as my build tool, and I checked the generated code too - it doesn't have any The file schema being the reason is just my best guess. #721 might have something to do with it, but I doubt it - I saw some other discussions on the topic (e.g. #296, #776 ) and I did come across the suggestion to Doesn't TM modify the CSP anyway? I saw the option to "Add Tampermonkey to the site's content security policy (CSP) if there is one" |
Update: And after a whole day of wondering what the heck is going on, now it is mysteriously working. I have absolutely no idea why. OTOH if it comes back, there are extensions to strip CSPs. I can just use that while developing, then manually copy over the finished script to TM, without having a require. |
Update 2: I investigated some more today, and the only logical explanation I can arrive at is that I botched something around the build process, even though I could have sworn I did it properly (I hadn't yet written the command that causes this when it first happened, wtf?). See, when webpack is watching files in development mode it builds scripts that use As far as how to get around the issue during development - some sites (like twitter) make it extremely tricky. Or should I say chrome makes it extremely tricky because the extension APIs don't interact well with service workers. It seems for example See this: https://bugs.chromium.org/p/chromium/issues/detail?id=766433&q=webrequest%20service%20worker&can=2 For now a workaround must be used to allow extensions to manage CSPs: I'll edit the title to signify its a webpack problem, then close the issue. |
Expected Behavior
Userscripts should work regardless of CSP.
Actual Behavior
I've encountered a situation where my userscript refuses to run because of a site's content security policy.
After some investigation I think I have successfully tracked down the problem.
See, I use @require as a method of developing scripts locally, using all nifty modern tools - vscode, webpack, etc.
From what I can tell,
@require
s with thefile:///
schema use eval. And many sites CSPs disallow 'unsafe-eval'
. And you get a problem.(I tried requiring jquery from the web and it worked, leading me to believe this is a problem with file urls only. Why tho?)
I know there's other CSP discussions, but I'm pretty sure this is a new problem.
Specifications
The text was updated successfully, but these errors were encountered: