Browser extension that teaches vocabulary while you browse
A Chrome extension that swaps words on any page into Spanish, French or German and shows the original on hover, built so it never breaks layout, forms or code.
The problem
A client wanted a Chrome extension for passive language learning: swap some words on pages you already read into the language you are learning, and show the original on hover. A script that touches every page on the web is risky, so it must never break layout, forms, passwords, links or code blocks.
How I built it
I built the working core first, as a proof of concept, so he could see it running instead of reading a pitch. The engine walks only the text nodes of a page, wraps each swap in a reversible span that stores the original, and skips inputs, passwords, links, code and editable regions by checking up to 40 ancestors. Three intensity levels control how many words are swapped and how hard the vocabulary is, and an options page imports extra words in the source, replacement, level shape an admin spreadsheet import would produce. I wrote a five-phase roadmap for the rest: accounts, multi-country subscriptions through Paddle, an admin dashboard with Excel import, and a store release.
What got hard
- Pages that keep loading content after the first paint, such as infinite scroll and single-page apps, would be missed or reprocessed.
A debounced MutationObserver handles new content, and the work is chunked through requestIdleCallback with a generation counter that cancels any pass a newer one has superseded, so long pages stay responsive.
- Large word imports can fail without any error when an extension stores them in synced storage, which has a small per-item quota.
Settings stay in synced storage and word lists go in local storage, and a pathological import fails safe because the matching expression is built inside a try block that returns nothing instead of throwing.
- Showing the client the skip rules working, since a demo on a normal page proves little about the things that must not change.
I added a self-contained test page with a form, a password field, a link and a code block that must stay untouched, plus a button that injects new text to show dynamic content being handled.
The result
A working Manifest V3 core of about 450 lines of JavaScript with no dependencies and no build step, 44 starter words per language, a popup (on or off, language, intensity, live swap count), the demo page and the roadmap. I sent the client a screen recording of it running and of the source.
The ← and → keys turn the page too.