Skip to content

SpaceCypher/munshin

Repository files navigation

Munshin

Munshin Logo
Your browser, but focused. Flow State by Design.

Munshin is a privacy-first Chrome extension that transforms your browser into a distraction-free sanctuary. Instead of relying on harsh blocklists or punishing restrictions, Munshin uses gentle friction, warm aesthetics, and mindful intentionality to help you rebuild your attention span.

During a "deep work" session, Munshin temporarily hides your distracting tabs and intercepts attempts to visit non-work websites, asking you to pause and reconsider your action.

🖼️ See it in Action

Click to view interface screenshots
The Popup Interface The Interceptor
Extension Popup UI Interceptor Warning Screen
Active Session Timer Session Complete Notification
Active Session Timer Session Complete Alert
Session History Settings Menu
History Menu Settings Menu

✨ Key Features

  • Tab Hiding (Not Closing): Select the tabs you need for work. Munshin safely stows away everything else until your session ends.
  • The Interceptor: If you try to open a new tab to a distracting site during a session, Munshin intercepts the request and presents a mindful pause screen.
  • Dynamic Blocklists: Add or remove your own distracting domains via the Settings menu. No more hardcoded limits.
  • Warm Glassy Aesthetics: Designed to feel like a "quiet, warm room" rather than a productivity tool.
  • Session Recovery: Browser crashed? Munshin remembers your stowed tabs and lets you restore them.
  • Customizable Timers: Set deep work sessions for any duration.
  • 100% Local & Private: No accounts. No servers. Everything stays in your browser's chrome.storage.local.

🛠️ Tech Stack

This extension is built using modern web technologies, outputting a static site that Chrome can run natively.

  • Framework: Next.js 15 (App Router, Static Export)
  • UI Library: React 19
  • Styling: Tailwind CSS v4
  • Animations: Motion (Framer Motion)
  • Icons: Lucide React
  • Extension APIs: Manifest V3 (Service Workers, Declarative Net Requests, Alarms)

🚀 Getting Started (Local Development)

Because this is a Next.js application compiled into a Chrome Extension, the development workflow requires building the static export and loading it into Chrome.

1. Prerequisites

  • Node.js (v18+)
  • npm or pnpm
  • Google Chrome browser

2. Installation

Clone the repository and install the dependencies:

git clone <repository-url>
cd Focus
npm install

3. Building the Extension

To build the project for Chrome:

npm run build

This command runs the Next.js build process, exports the static files to the out/ directory, and then runs a custom postbuild script (rename_next.js).

Why the postbuild script? Next.js prefixes its internal assets with an underscore (e.g., _next/). Chrome Extensions explicitly forbid directories starting with an underscore. The rename_next.js script safely renames these directories and updates all file references to ensure the extension functions correctly in Chrome.

4. Loading into Chrome

  1. Open Google Chrome and navigate to chrome://extensions/.
  2. Enable Developer mode (toggle in the top right corner).
  3. Click Load unpacked.
  4. Select the out/ folder generated in the previous step.

The Munshin extension icon should now appear in your browser toolbar!


🏗️ Architecture Overview

The application is structured to support both Next.js page routing (for full-page extension views) and Manifest V3 background scripts.

Directory Structure

├── app/                  # Next.js App Router pages
│   ├── interceptor/      # The mindful pause screen
│   ├── onboarding/       # Initial setup and permissions flow
│   ├── popup/            # The main extension dropdown UI
│   ├── recovery/         # Session crash recovery screen
│   ├── page.tsx          # Marketing/Homepage view
│   └── layout.tsx        # Global layout and fonts
├── public/               # Static extension assets
│   ├── background.js     # Service Worker (Timer logic, Rules)
│   ├── content.js        # Content Script (In-page toasts)
│   ├── manifest.json     # Chrome Extension Manifest V3
│   └── icon*.png         # Brand icons
├── lib/                  # Shared utilities
│   └── chrome.ts         # Wrapper around chrome.* APIs
├── wireframes/           # Original design specifications
└── rename_next.js        # Crucial build script for Chrome compatibility

How the Extension Works

  1. Starting a Session (app/popup/page.tsx): The user selects tabs to keep open and clicks "Start". The React UI sends a message to the Background Service Worker.
  2. Background Worker (public/background.js):
    • Receives the start message.
    • Hides (stows) unselected tabs.
    • Registers dynamic blocking rules via the chrome.declarativeNetRequest API to redirect distracting sites to the interceptor.html page.
    • Starts a chrome.alarms timer.
  3. The Interceptor (app/interceptor/page.tsx): If a user navigates to a blocked site, they are redirected here. It reads the target URL and the remaining session time from local storage.
  4. Session End: The alarm fires. The background worker removes the blocking rules, restores the hidden tabs, and broadcasts a message to the content.js script to display the "Session Complete" toast notification on the user's active screen.

🔒 Privacy & Permissions

Munshin requires the following permissions in manifest.json:

  • tabs: Required to read the user's open tabs (to show in the popup) and to stow/restore them.
  • storage: Required to save session state, preferences, and stowed tab URLs locally.
  • alarms: Required to run the session timer reliably in the background without draining battery.
  • declarativeNetRequest: Required to intercept and redirect requests to distracting websites.
  • notifications: (Optional) Used for system-level alerts.

Everything stays in the browser. There is no database, no telemetry, and no tracking.


🛡️ Security & Code Audit

Munshin has undergone a rigorous, professional security and architecture audit to ensure the safety and robustness of the extension. All identified vulnerabilities and architectural improvements have been 100% resolved.

Please see the Security_Review.md file in the root directory for the full report and the completed action plan.


🐛 Troubleshooting Development

The extension UI is blank or broken after building

Ensure the postbuild script ran successfully. If _next folders exist in your out/ directory, Chrome will refuse to load the scripts.

Background script errors

If you modify background.js, you must open chrome://extensions/ and click the reload icon (↻) on the Munshin extension card to apply the changes. Rebuilding the Next.js app does not automatically hot-reload the background worker.

Tailwind classes aren't applying

This project uses the new Tailwind v4. Ensure you aren't trying to use deprecated v3 configuration patterns. The CSS entrypoint is app/globals.css.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors