Regex Search & Highlight

Search and highlight text using regex patterns on any webpage

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

作者
JimDop
日安装量
0
总安装量
0
评分
0 0 0
版本
1.0
创建于
2025-11-21
更新于
2025-11-21
大小
10.8 KB
许可证
MIT
适用于
所有网站

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.