anki-add-hooks-userscripts
anki-add-hooks-userscripts copied to clipboard
Google Translate broken: "Add" button not appearing
Your software
- OS: Windows 10
- Browser: Chrome
- Extension: Tampermonkey
Describe the bug The add button stopped appearing not long ago without having changed anything about my set-up. I have been using Google Translate. I am running updated version of browser/extension.
To Reproduce Steps to reproduce the behavior:
- Go to 'translage.google.com'
- Open Anki Desktop
- Translate a word
- Anki "Add" button does not appear.
Expected behavior Anki "Add" button should appear
Screenshots

The console shows the following error:
This document requires 'TrustedHTML' assignment.
It seems that Google Translate made its CSP more restrictive. This is probably due to the answer's header:
content-security-policy: require-trusted-types-for 'script'
On Firefox I get similar error:
Content Security Policy: The page’s settings blocked the loading of a resource at inline (“script-src”).
For now I unfortunately do not have a solution. It is likely that it affects any userscript trying to run on Google Translate.
In addition I do not have a sufficient knowledge of CSPs to figure out whether there can be a workaround.
So wait and see... (suggestions and PR welcome!)