Skip to content

ugurcl/privacy-cleaner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Privacy Cleaner

A Chrome extension to clean browsing history, cookies, and site data for specific domains. Set up automatic cleanup rules, whitelist trusted sites, and take control of your browsing privacy.

Chrome Manifest License

Features

Domain-Based Cleanup

  • Search any domain to see its history entries and cookies count
  • Clean history, cookies, localStorage, sessionStorage, IndexedDB, and cache per domain
  • Time range filter: last hour, today, last 7 days, last 30 days, or all time
  • Smart domain normalization: automatically strips http://, www., ports, and paths from input

Complete History Deletion

  • Paginated search ensures every history entry is found, even for high-traffic sites like YouTube
  • Searches across all subdomain variants: domain.com, www.domain.com, m.domain.com
  • Deduplicates results to prevent double-counting
  • Batch deletion in chunks of 500 for reliable large-scale cleanup
  • Removes entries from Chrome's address bar autocomplete (omnibox)

Full Cookie Coverage

  • Finds cookies across 6 domain variants: domain.com, .domain.com, www.domain.com, .www.domain.com, m.domain.com, .m.domain.com
  • Handles dot-prefixed cookie domains correctly (e.g. .youtube.com)
  • Batch deletion in chunks of 200 with per-cookie error handling
  • Supports both secure (HTTPS) and non-secure (HTTP) cookie URLs

Site Storage Cleanup

  • Clears localStorage, sessionStorage, IndexedDB, cache, cacheStorage, and service workers
  • Targets 5 origin variants: https://, http://, www., m. combinations
  • Injects into open tabs matching the domain for live localStorage/sessionStorage clearing

Automatic Cleanup Rules

  • Create rules for specific domains with custom triggers:
    • Manual - clean on demand
    • On browser startup - clean when Chrome opens
    • Periodic - clean at intervals (configurable: 30min to 24h)
    • On tab close - clean when the specific domain's tab is closed
  • Choose what to clean per rule: history, cookies, cache, storage
  • Smart tab close detection: tracks tab URLs and only triggers rules matching the closed tab's domain

Whitelist

  • Protect important sites from being cleaned
  • Whitelisted domains are skipped by all rules and quick clean
  • Subdomain-aware: whitelisting example.com also protects sub.example.com

Quick Clean

  • One-click cleanup runs all configured rules
  • Keyboard shortcut: Ctrl+Shift+L

Statistics

  • Track total items cleaned
  • Breakdown by type: history entries, cookies, storage clears
  • Last cleanup timestamp

Settings Management

  • Export/import all settings as JSON (rules, whitelist, settings, stats)
  • Default cleanup options configuration
  • Configurable periodic interval

Security

  • XSS protection: all user-supplied domain names are HTML-escaped before rendering
  • Input sanitization: domain inputs are normalized and validated
  • Buttons are disabled during operations to prevent duplicate requests
  • Graceful error handling for service worker communication failures

Installation

  1. Download or clone this repository
  2. Open Chrome and go to chrome://extensions/
  3. Enable Developer mode (top right toggle)
  4. Click Load unpacked
  5. Select the privacy-cleaner folder

Usage

Popup (Quick Access)

Click the extension icon in the toolbar:

  1. Type a domain name (e.g. youtube.com, facebook.com)
  2. Input is auto-normalized: https://www.youtube.com/watch?v=123 becomes youtube.com
  3. See how many history entries and cookies exist
  4. Click individual buttons or Clean All to remove data
  5. Use Quick Clean to run all configured rules at once

Options Page (Settings)

Right-click the extension icon > Options, or click the gear icon in the popup:

  • Cleanup Rules - add/edit/delete/run automated cleanup rules
  • Whitelist - manage protected domains
  • Settings - configure defaults and periodic interval
  • Statistics - view cleanup history and totals

Permissions

Permission Usage
history Search and delete browsing history by domain
cookies List and remove cookies by domain
browsingData Clear localStorage, cache, IndexedDB, service workers per origin
storage Store extension settings, rules, and stats
scripting Clear page localStorage/sessionStorage in open tabs
tabs Track tab URLs for tab-close triggers, find open tabs for storage clearing
alarms Schedule periodic cleanup tasks

Project Structure

privacy-cleaner/
├── manifest.json          # Extension manifest (MV3)
├── service-worker.js      # Background: events, alarms, tab tracking, message handling
├── content-script.js      # Page context: clear localStorage/sessionStorage
├── popup/
│   ├── popup.html         # Popup UI
│   ├── popup.css          # Popup styles (dark theme)
│   └── popup.js           # Popup logic
├── options/
│   ├── options.html       # Full settings page
│   ├── options.css        # Settings styles
│   └── options.js         # Settings logic (rules, whitelist, import/export)
├── lib/
│   ├── cleaner.js         # Core cleanup (paginated search, batch delete, multi-variant)
│   └── storage.js         # chrome.storage wrapper (rules, whitelist, settings, stats)
└── images/
    ├── icon-16.png
    ├── icon-48.png
    └── icon-128.png

How It Works

History Deletion

Chrome's history.search API returns max 10,000 results per call. For sites with extensive browsing history, Privacy Cleaner paginates through all results by adjusting the endTime parameter until every entry is found. It searches multiple prefixes (domain, www.domain, m.domain) and deduplicates before deleting in batches.

Cookie Matching

Cookies can be stored under various domain formats (with/without leading dot, with/without www). Privacy Cleaner queries all 6 possible variants to ensure complete cookie removal, and constructs the correct URL (http/https based on secure flag) for deletion.

Tab Close Triggers

The service worker maintains a Map of tab IDs to hostnames. When a tab closes, only rules matching that specific tab's domain are executed, preventing unnecessary cleanup of unrelated domains.

Keyboard Shortcuts

Shortcut Action
Ctrl+Shift+L Quick clean (run all rules)

Tech Stack

Component Technology
Platform Chrome Extension (Manifest V3)
Language Vanilla JavaScript (ES Modules)
Storage chrome.storage.local
Background Service Worker
UI Dark theme, system-ui font

License

MIT

About

Chrome extension (MV3) to clean browsing history, cookies, and site data for specific domains with automatic cleanup rules

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors