AidanWelch / AidanWelch/ProgressiveImmersion
Text entered into editable areas becomes translated.
- Langage dominant
- JavaScript
- Étoiles
- 14
- Forks
- 5
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
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.
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Évaluation
Cette issue n'a pas encore été évaluée.