Skip to content

Repository files navigation

🛡️ FocusGuard

A Chrome extension that enforces distraction-free work sessions with commitment-contract mechanics, a soft exit with reflection, and a simple weekly focus summary. Built solo, shippable in 6–8 weeks.


✨ Features

  • Session Modes — Choose between Deep Work 🧠, Study 📚, or Custom ⚙️
  • Commitment Contract — Once a session starts, the blocklist is locked and cannot be edited
  • Dynamic Blocking — Automatically blocks distracting sites when a session starts and unblocks when it ends
  • Soft Exit with Reflection — Exiting early triggers a 10-second reflection screen asking what pulled you away
  • Session Stats — Track today's focus time, weekly sessions, 7-day consistency score, and recent session history
  • First-Run Onboarding — 3-step setup in under 60 seconds
  • No frameworks — Built with vanilla HTML, CSS, and JS using Manifest V3

🖥️ Tech Stack

Technology Purpose
Manifest V3 Chrome Extension framework
HTML / CSS / JS UI and logic
declarativeNetRequest Site blocking engine
chrome.storage.local Persisting session state and stats
chrome.alarms Session timer and service worker keep-alive
Service Worker Background session management

📁 Project Structure

focusguard-v1/
├── manifest.json
├── background/
│   └── service-worker.js       # Session controller, blocking engine
├── popup/
│   ├── popup.html              # Extension popup UI
│   ├── popup.css
│   └── popup.js
├── blocked/
│   ├── blocked.html            # Page shown when a site is blocked
│   ├── blocked.js
│   ├── reflection.html         # Soft exit reflection screen
│   ├── reflection.css
│   └── reflection.js
├── options/
│   ├── options.html            # Blocklist management page
│   └── options.js
├── onboarding/
│   ├── onboarding.html         # First-run onboarding flow
│   ├── onboarding.css
│   └── onboarding.js
├── stats/
│   ├── stats.html              # Focus stats screen
│   ├── stats.css
│   └── stats.js
└── rules/
    └── blocklist.json          # declarativeNetRequest rules

🚀 Installation (Developer Mode)

Since FocusGuard is not yet on the Chrome Web Store, you can load it manually:

  1. Clone the repository:

    git clone https://github.com/Richard-1904/FocusGuard.git
  2. Open Chrome and navigate to:

    chrome://extensions
    
  3. Enable Developer Mode using the toggle in the top right corner.

  4. Click Load unpacked and select the FocusGuard folder.

  5. The FocusGuard icon will appear in your Chrome toolbar. Click it to get started!


🧭 How to Use

Starting a Session

  1. Click the 🛡️ FocusGuard icon in your toolbar
  2. Select a mode (Deep Work, Study, or Custom)
  3. Choose a duration (25, 50, 90 mins or custom)
  4. Optionally add Today's Work Sites — these will be whitelisted for the session
  5. Click Start Session

During a Session

  • Blocked sites will redirect to the FocusGuard blocked page showing your remaining time
  • The blocklist cannot be edited while a session is active
  • Click Exit Session on the blocked page or popup to end early

Exiting Early

  • A 10-second reflection screen will appear asking "What pulled you away?"
  • Choose a preset reason or type your own
  • Click Stay in Session to go back, or wait for the countdown to end the session

Managing Your Blocklist

  • Click the FocusGuard icon → Options (or right-click the icon → Options)
  • Add or remove domains (one per line)
  • Changes can only be made outside of active sessions

Viewing Stats

  • Click 📊 View Stats in the popup
  • See today's focus time, weekly sessions, 7-day consistency, and recent session history
  • Each session shows whether it was completed fully or exited early with the reason

⚙️ Default Blocklist

FocusGuard comes pre-configured to block these sites during sessions:

  • youtube.com
  • x.com
  • instagram.com
  • reddit.com

You can customise this list at any time outside of active sessions via the Options page.


🔒 Privacy

All data stays entirely on your device. FocusGuard uses chrome.storage.local exclusively — no accounts, no cloud sync, no data collection of any kind.


🤝 Contributing

Contributions are welcome! Feel free to open an issue or submit a pull request.

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/your-feature
  3. Commit your changes: git commit -m "Add your feature"
  4. Push to the branch: git push origin feature/your-feature
  5. Open a Pull Request

📄 License

MIT License — feel free to use, modify, and distribute.


Built with focus, for focus. 🛡️

About

A Chrome extension that enforces distraction-free work sessions with commitment-contract mechanics and soft exit reflection.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages