AidanWelch / AidanWelch/ProgressiveImmersion
Text entered into editable areas becomes translated.
- Lingua principale
- JavaScript
- Stelle
- 14
- Fork
- 5
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
In online email clients, form fields, and social media sites, typed text can sometimes be translated before submission. For example, I typed an email in Gmail, and several words were translated into the language I had set to learn. Those non-English words were then sent in that email. I checked this with a second device to make sure.
The same issue has arisen on social media sites like LinkedIn, where translated text has been saved when editing fields.
A possible fix would be to skip text whenever its element, or any parent element, is an editable area or textbox. Checking this before scanning would prevent translation and word collection inside drafts, while still allowing normal page text to translate. This would prevent new changes, rather than restore text already translated.
In `src/content_scripts/main.js`, a small helper could go immediately after `checkShouldTranslateNode`:
```js
function isInEditableArea ( element ) {
return element !== null && (
element.isContentEditable ||
element.matches( 'input, textarea, [role~="textbox"]' ) ||
isInEditableArea( element.parentElement )
);
}
```
Then extend the existing skip condition inside the `IntersectionObserver` callback, just before `entry.target.progressiveImmersionAnalyzed = true`:
```js
if (
!entry.isIntersecting ||
entry.target.progressiveImmersionAnalyzed ||
document.designMode === 'on' ||
isInEditableArea( entry.target )
) {
continue;
}
```
This would skip editor contents before translation or word collection, covering both the initial page scan and newly added content. It prevents new changes rather than restoring text already translated.
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Valutazione
Questa issue non è ancora stata valutata.