Skip to content

sconklin/redact

Repository files navigation

Text Redactor Browser Extension

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

Features

  • 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)

Installation

Chrome/Edge (Chromium-based)

  1. Open Chrome/Edge and navigate to chrome://extensions/ (or edge://extensions/)
  2. Enable "Developer mode" (toggle in top right)
  3. Click "Load unpacked"
  4. Select this directory (redact)

Firefox

  1. Open Firefox and navigate to about:debugging
  2. Click "This Firefox"
  3. Click "Load Temporary Add-on"
  4. Select the manifest.json file in this directory

Usage

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:

  1. Click the extension icon in your browser toolbar
  2. Click "Enable Redaction" to turn the feature on/off
  3. Click "+ Add Pattern" to create a new redaction rule
  4. Enter a regular expression pattern (JavaScript regex syntax)
  5. Optionally specify replacement text (leave empty for default black blocks)
  6. The extension will automatically reload the current page to apply changes

Default Patterns

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

Example Custom Patterns

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

Files

  • manifest.json - Extension manifest (Manifest V3)
  • content.js - Content script that performs the redaction
  • content.css - Styles for redacted text
  • popup.html - Extension popup UI
  • popup.js - Popup logic and configuration management
  • default-patterns.json - Default regex patterns loaded on first run
  • icon16.png, icon48.png, icon128.png - Extension icons (you'll need to create these)

Icon Requirements

You'll need to create three icon files:

  • icon16.png - 16x16 pixels
  • icon48.png - 48x48 pixels
  • icon128.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.

Technical Details

  • 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

Privacy

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.

License

This project is dedicated to the public domain. See LICENSE file for details.

About

redact strings in the web browser

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published