Highlights quoted text with customizable colors, styles, and features
A lightweight script that highlight quoted sentences. It operates entirely client-side, scanning the DOM after page load and continuing to watch for dynamically added content.
⭐ What it does. If it's not perfect, then point it out and it'll be updated.TreeWalker to find quoted strings matching the configured regex pattern<span> elements with the class quote-highlightMutationObserver to catch quotes added by lazy-loading, infinite scroll, SPAs (Single Page Applications), or AJAX contentThe script offers granular control over appearance:
| Setting | Default | Purpose |
|---|---|---|
textColor |
#EA9D9C (soft red/pink) |
Color of the quoted text |
backgroundColor |
rgba(234, 157, 156, 0.12) |
Subtle background tint |
borderRadius |
0px |
Corner rounding on highlights |
padding |
0 2px |
Horizontal breathing room |
underline |
false |
Toggle between background highlight or underline style |
fontWeight |
(commented out) | Optional bold emphasis |
Hover state applies a brightness(1.08) filter for subtle interactivity.
<script>, <style>, <code>, <pre>, <textarea>, <input>, <video>, and other specified elementsquote-highlight classGM_addStyle (Userscript API) to inject highlight styles directly| Feature | Benefit |
|---|---|
| Universal compatibility | Works on any site—news other than excluded, forums, documentation, social media |
| SPA & dynamic content support | MutationObserver catches React/Vue/Angular injected content automatically |
| Non-destructive DOM manipulation | Uses DocumentFragment for efficient batch replacements; preserves surrounding text nodes intact |
| Developer/debug API | Exposes window.QuoteHighlighter with rescan(), disconnect(), and config access for console debugging |
| Zero dependencies | Pure vanilla JS, no libraries required |
| Configurable regex | Easy to swap quoteRegex for different quote styles or regional variants |
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ DOM Load or │────▶│ TreeWalker │────▶│ Regex Match │
│ Mutation Event │ │ (text node scan) │ │ (quote pattern) │
└─────────────────┘ └──────────────────┘ └────────┬────────┘
│
┌───────────────────────────┘
▼
┌──────────────────┐
│ DocumentFragment │
│ (span + text) │
└────────┬─────────┘
│
▼
┌──────────────────┐
│ replaceChild() │
│ (DOM injection) │
└──────────────────┘
/(?<!\w)(["“”““'‘`"])(.*?)(["””””'’`.])(?!\w)/g
[] where the other quotes are.