This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
npm run build # Build Chrome (MV3) and Firefox (MV2) extensions to dist/
npm run build:watch # Watch mode for development
npm run test # Run unit tests (Vitest)
npm run test:watch # Run tests in watch mode
npm run test:e2e # Run Playwright e2e tests
npm run test:all # Run both unit and e2e tests
npm run lint # ESLint
npm run clean # Remove dist/Run a single test file: npx vitest run tests/unit/rules.test.ts
This is a browser extension that blocks algorithmic feeds while preserving utility features (DMs, search, subscriptions). It supports both Chrome (Manifest V3) and Firefox (Manifest V2).
- Hard block: Navigation-level blocking via
declarativeNetRequest(MV3/Chrome) orwebNavigation(MV2/Firefox), redirects to blocked page or safe destination - Soft block: DOM hiding via content scripts, uses MutationObserver for dynamic content
src/
├── mv3/ # Chrome MV3 background service worker
├── mv2/ # Firefox MV2 background script
├── content/ # Content scripts per platform
│ ├── base.ts # PlatformContentScript base class, messaging, DOM helpers
│ ├── router.ts # SPA navigation detection (patches history API)
│ └── platforms/ # Platform-specific implementations
├── shared/ # Shared code between background and content
│ ├── types.ts # TypeScript interfaces
│ ├── config.ts # Default configs, URL rules, CSS selectors
│ ├── rules.ts # URL pattern matching, block decisions
│ └── storage.ts # Chrome storage wrapper
└── ui/ # Popup and blocked page
- MV3 (Chrome):
declarativeNetRequeststatic rules handle redirects; MV2 (Firefox):webNavigationAPI handles navigation - Rules engine (
src/shared/rules.ts) determines if URL should be blocked using pattern matching - Hard blocks redirect to blocked page or platform-specific safe destination
- Content scripts handle soft blocks by hiding DOM elements using selectors from
config.ts - Router (
src/content/router.ts) detects SPA navigation by patchinghistory.pushState/replaceState
Patterns in config.ts support:
- Exact matches:
/home - Single segment wildcards:
/user/*(matches/user/john, not/user/john/posts) - Multi-segment wildcards:
/explore/**(matches/explore,/explore/tabs/for-you)
Each platform has:
hardBlocks: Page-level navigation blocks (e.g.,home,shorts,trending)softBlocks: DOM element hiding (e.g.,recommendations,endCards)redirectTarget: Where to send blocked traffic ('blocked'for blocked page, or path like/feed/subscriptions)
- Add platform ID to
PlatformIdtype intypes.ts - Add default config in
config.ts(PLATFORM_DEFAULT) - Add URL rules (
PLATFORM_RULES) and selectors (PLATFORM_SELECTORS) inconfig.ts - Create content script in
src/content/platforms/ - Add entries to
esbuild.config.js - Add manifest entries (content_scripts, host_permissions)
- For MV3: Add declarativeNetRequest rules JSON file
npm run build produces:
dist/chrome/- Manifest V3 extension (Chrome, Edge)dist/firefox/- Manifest V2 extension (Firefox)