-
Notifications
You must be signed in to change notification settings - Fork 7
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
Issue with executing userscripts inside documents that require TrustedTypes #1779
Comments
Can it be reproduced with Chrome? |
I unfortunatelly have only Slimjet installed,no other browsers are present here. Trying to keep it tight and clean on my end 😉 P.S. Just in case mask your User Agent with the latest Mozilla one when try to reproduce it. |
Issue is reproduced with AG and with Tampermokey in Chrome. Can't be reproduced in Firefox. Maybe some security updates in latest chromium could cause the problem and require a workaround on AG side ? |
The script actually needs to have "TrustedScript assignment",either implemented from the @AdguardTeam or developer(based on my research). I believe that we don't even have to wait for the app update as this is in one of the AG extensions/userscripts. |
We did some research on this issue. It is indeed caused by the fact that an iframe on that page requires trusted types. The question was why there's no error with Tampermonkey while there's an error with AdGuard or Violentmonkey. The answer is that Tampermonkey removes The question is whether we need to do anything about that or this kind of issues should be resolved by userscripts authors. Should we actually go the same way as Tampermonkey and modify CSP? To be honest, I am reluctant about that and would better avoid doing anything, especially if the only problem is just one userscript where this can be solved rather easily. Userscripts authors can resolve this using code like that: var s = document.createElement('script');
if (getScriptCspNonce()) {
s.setAttribute('nonce', scriptCspNonce);
}
const createPolicy = () => {
const defaultPolicy = {
createScript: (input) => {
return input;
},
};
if (window.trustedTypes && window.trustedTypes.createPolicy) {
return window.trustedTypes.createPolicy('somePolicy', defaultPolicy);
}
return defaultPolicy;
};
const somePolicy = createPolicy();
const scriptContent = somePolicy.createScript('console.log(\'test\')');
s.textContent = scriptContent; |
PING @Rob--W ☝️ |
The developer of the user script of the Mouseover Popup Image Viewer a few days ago made it so that his script began to work, for example, in the comments of Disqus. https://github.com/tophf/mpiv/commits/master |
The developer of the userscript MPIV @tophf mentioned above is also one of the developers of the Violentmonkey. |
See the linked issue: https://github.com/Rob--W/dont-track-me-google/issues/53
The text was updated successfully, but these errors were encountered: