I built a browser extension that does text replacement across all websites -- specifically replacing "Trump" with rotating humorous nicknames. The interesting technical bits: - TreeWalker for DOM traversal (skips scripts, inputs, contenteditable, iframes) - MutationObserver with debouncing for SPAs and dynamically loaded content - Fisher-Yates shuffle bag for even nickname distribution (no repeats until all are used) - Case preservation via regex (TRUMP -> MANGO MUSSOLINI, Trump -> Mango Mussolini) - CSS-only animations with prefers-reduced-motion support - Zero dependencies, plain JS, Manifest V3 The architecture is generic enough to fork for any text replacement use case. All the replacement logic lives in a single file. No external requests, no analytics, no data leaves the browser. Settings sync via Chrome Storage / browser.storage. Available for Chrome, Firefox, and Safari. Free. Feedback on the implementation welcome -- the code is straightforward and I'd rather someone tell me my MutationObserver setup is wrong than find out the hard way. |