A browser extension that redacts text on web pages using configurable regular expressions. Matched text is replaced with solid black blocks (or custom replacement text) to mimic redacted documents.
This code was created using AI
- Configurable Regex Patterns: Add multiple regular expression patterns to match text
- Custom Replacements: Specify replacement text, or use default black blocks
- Enable/Disable Toggle: Quickly turn redaction on or off
- Per-Pattern Control: Enable or disable individual patterns
- Dynamic Content Support: Automatically redacts content added to pages dynamically
- Visual Feedback: Hover over redacted text to see the original (for debugging)
- Open Chrome/Edge and navigate to
chrome://extensions/(oredge://extensions/) - Enable "Developer mode" (toggle in top right)
- Click "Load unpacked"
- Select this directory (
redact)
- Open Firefox and navigate to
about:debugging - Click "This Firefox"
- Click "Load Temporary Add-on"
- Select the
manifest.jsonfile in this directory
On first run, the extension automatically loads default patterns from default-patterns.json. The default patterns include various name variations (e.g., "Donald Trump", "President Trump", etc.). You can customize these or add your own:
- Click the extension icon in your browser toolbar
- Click "Enable Redaction" to turn the feature on/off
- Click "+ Add Pattern" to create a new redaction rule
- Enter a regular expression pattern (JavaScript regex syntax)
- Optionally specify replacement text (leave empty for default black blocks)
- The extension will automatically reload the current page to apply changes
The extension comes with the following default patterns (all enabled by default):
- Donald J. Trump
- Donald Trump
- President Trump
- Pres. Trump
- Mr. Trump
- Trump (standalone word)
- Former President Trump
- Ex-President Trump
You can add your own patterns for other use cases:
- Credit Cards:
\d{4}[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4} - Email Addresses:
[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,} - Phone Numbers:
\d{3}[-.\s]?\d{3}[-.\s]?\d{4} - SSN:
\d{3}-\d{2}-\d{4} - IP Addresses:
\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b
manifest.json- Extension manifest (Manifest V3)content.js- Content script that performs the redactioncontent.css- Styles for redacted textpopup.html- Extension popup UIpopup.js- Popup logic and configuration managementdefault-patterns.json- Default regex patterns loaded on first runicon16.png,icon48.png,icon128.png- Extension icons (you'll need to create these)
You'll need to create three icon files:
icon16.png- 16x16 pixelsicon48.png- 48x48 pixelsicon128.png- 128x128 pixels
You can use any image editor or online tool to create simple icons. A simple black square or "R" for "Redact" would work well.
- Uses Manifest V3 (Chrome/Edge compatible)
- Stores configuration in
chrome.storage.sync(syncs across devices) - Uses MutationObserver to handle dynamically added content
- Processes text nodes while avoiding script/style tags
- Redacted text uses black background and text color for solid appearance
All processing happens locally in your browser. No data is sent to external servers. Configuration is stored in your browser's sync storage (if enabled) or local storage.
This project is dedicated to the public domain. See LICENSE file for details.