Search and highlight text using regex patterns on any webpage
I've created a robust Violentmonkey/Tampermonkey userscript with these features:
Key Features:
Regex search with full regex pattern support
Yellow highlighting of all matches
Match counter showing total matches found
Case sensitive toggle option
Whole word search option
Minimizable panel (stays out of your way)
Auto-scrolls to first match
Works on dynamic sites like Reddit and NYTimes (MutationObserver tracks DOM changes)
Smart text node filtering (skips scripts, styles, and the panel itself)
How to use:
Install Violentmonkey extension
Create a new script and paste this code
Visit any website
Enter a regex pattern (e.g., \b[A-Z]{3,}\b for acronyms, \d{3}-\d{3}-\d{4} for phone numbers)
Click "Search & Highlight"
Example patterns to try:
\b\w+@\w+\.\w+\b - Email addresses
https?://[^\s]+ - URLs
\$\d+\.?\d* - Dollar amounts
\b[A-Z][a-z]+\b - Capitalized words
The script handles complex pages by using TreeWalker to efficiently find text nodes and a MutationObserver to re-apply highlights when the page changes dynamically.