Stop Leaking API Keys & Customer Data in Looms & AI Prompts: Building a 100% Local PII Scrubber and Demo Mode in Vanilla JS
DEV Community

Stop Leaking API Keys & Customer Data in Looms & AI Prompts: Building a 100% Local PII Scrubber and Demo Mode in Vanilla JS

Every developer has had the same minor heart attack: you share your screen on Zoom, record a Loom walkthrough, or paste a production JSON stack trace into Claude/ChatGPT - and two seconds later notice a real customer email, revenue total, or sk_live_ key sitting right there on screen.

Existing screen-blur extensions mostly fall into two camps: manual click-only blur tools that smear your whole UI into ugly smudges, or cloud/subscription tools that charge monthly fees just to hide text. So I built two free zero-upload web tools plus a lightweight Manifest V3 Chrome/Edge extension (DemoCloak) powered by the exact same 100% client-side vanilla JS detection engine.

Here are the four engineering problems that actually mattered when building it cleanly:

1. Avoiding False Positives (Luhn Cards & Date-Safe Phone Matching)

Naive regex redactors ruin dashboards because a 16-digit order ID looks like a credit card, and 2026-11-25 looks like a phone number. For card detection, every candidate match runs through a lightweight Luhn checksum before we touch the DOM:

export function isValidLuhn(digitsOnly) {
  const digits = String(digitsOnly || '').replace(/\D/g, '');
  if (digits.length < 13 || digits.length > 19) return false;
  if (/^(\d)\1+$/.test(digits)) return false;
  let sum = 0;
  let dbl = false;
  for (let i = digits.length - 1; i >= 0; i -= 1) {
    let d = digits.charCodeAt(i) - 48;
    if (dbl) {
      d *= 2;
      if (d > 9) d -= 9;
    }
    sum += d;
    dbl = !dbl;
  }
  return sum % 10 === 0;
}

We also enforce strict priority precedence: developer tokens (sk_live_, ghp_, AKIA, AIza, xoxb-, JWTs, Bearer ...) match before generic emails or numbers, and custom user keywords/regex take top priority.

2. Deterministic Fake-Data Swapping ("Demo Mode")

Blurred boxes work for quick meetings, but they look awful in product demos, docs, and landing page screenshots. Instead of random gibberish, we hash each matched string with 32-bit FNV-1a so identical customer emails or revenue totals map deterministically to the same realistic placeholder everywhere on the page - preserving currency symbols ($, €, £, ¥), European vs. US decimal commas, and rough order of magnitude:

  • $48,920.50 → $62,480.00
  • c**@realclient.io → al*******@acme.example
  • sk_live_... → sk_live_demo_••••9f2a

Every wrapped <span> keeps its original string in memory (data-dc-orig) so clicking Restore All unwraps every node cleanly back to the exact original DOM.

3. Keeping SPAs Smooth (TreeWalker + rAF Batching + MutationObserver)

Live dashboards (Stripe, Gmail, AWS, CRMs) inject rows dynamically as you scroll. To prevent jank on large DOM trees:

  • Text nodes are walked via document.createTreeWalker (skipping <script>, <style>, <textarea>, and contenteditable) and mutated in 35-node requestAnimationFrame batches.
  • A debounced MutationObserver automatically scans newly inserted subtrees so sensitive rows stay hidden as you paginate.
  • Overlays (hover outlines, scroll-anchored blur boxes, and the Alt+Shift+B full-tab Panic Veil) live inside a Shadow DOM host so target page styles never leak in or out.

4. Least-Privilege Manifest V3 Permissions

Many privacy extensions ironically ask for <all_urls> on install. DemoCloak requests zero broad host permissions upfront - only activeTab, scripting, storage, and tabs. Per-domain auto-apply rules use optional_host_permissions and only ask Chrome for the single specific origin you click Auto-Apply on Site for.

Try the Free Local Tools (No Install, Zero Uploads)

If you just want to test the engine directly in your browser right now:

  • AI Prompt, JSON & Log PII Scrubber (with Reversible Local Re-hydration): https://apps.orzi.me/tools/prompt-sanitizer/

    Paste logs, .env snippets, or JSON payloads → mask into [EMAIL_1] / [SECRET_1] or realistic fake data → paste ChatGPT/Claude's reply back and restore your real values locally in 1 click.

  • Private Screenshot Blur, Pixelate & EXIF Stripper: https://apps.orzi.me/tools/screenshot-redact/

    Paste (Ctrl+V / ⌘V) or drop any screenshot, draw blur/pixelate/blackout boxes locally, and export a clean EXIF-stripped PNG.

  • DemoCloak Chrome & Edge Extension: https://apps.orzi.me/democloak/

    Free forever for unlimited Click-to-Blur, Draw Blur Boxes, Panic Veil (Alt+Shift+B), clean PNG capture, and 3 daily Auto-Shield/Demo scans (optional $19 one-time lifetime Pro license - no subscription). Currently under review on Chrome Web Store & Microsoft Edge Add-ons, with the unpacked release ready to try now.

If you spot any tricky secret formats, currency formats, or SPA edge cases where the scrubber misses a pattern, drop a comment below and I'll add test cases for them!

Read on DEV Community ↗ ← Back to News

Comments

No comments yet. Start the discussion.