This is a Tampermonkey userscript that translates web content into German while preserving the integrity of Single Page Applications (SPA) like React, Vue, and Angular
- Preserves HTML: Walks the DOM tree and only touches raw text.
- React-Safe: Does not trigger "checksum" errors or break event listeners.
- Infinite Scroll Support: Automatically detects and translates new content while scrolling.
- Toggleable: Switch between original and translated text instantly with a hotkey.
- Fast Execution: Parallel requests to the Google Translate API for quick results.
- Caching: Remembers translated phrases to save bandwidth and speed up repeat views.
- Smart Filtering: Automatically ignores code blocks, scripts, styles, and input fields.
- Cleanup: Restores the original text when toggled off.
- Install the Tampermonkey browser extension.
- Click Create a new script.
- Paste the contents of
translate.user.js. - Save (
Ctrl+S).
- Install: Copy the script into Tampermonkey.
- Activate: Press
ALT+Don any website to toggle the translation. - Monitor: Check the browser console (F12) to see how many elements are being processed.
- API: Uses the Google Translate
gtxendpoint. - Observer: Uses
MutationObserverwith a 700ms debounce to handle dynamic content loading. - Traversal: Uses
document.createTreeWalkerto isolateNode.TEXT_NODEelements, ensuring no HTML tags are overwritten.