This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
bun run dev- Start development mode with hot reload using WXTbun run dev:firefox- Start development mode for Firefox (MV2)bun run build- Build the extension for productionbun run build:firefox- Build for Firefox specificallybun run compile- Run TypeScript type checking without emitting files
bun run zip- Create Chrome extension zip for distributionbun run zip:firefox- Create Firefox extension zipbun run submit- Submit to Chrome Web Store (requires setup)
bun run pkg:check- Check for package updatesbun run pkg:bump- Update packages to latest versions
This project uses WXT (Web Extension Toolkit) for cross-browser compatibility. The extension targets Manifest V3 for Chrome and can build MV2 versions for Firefox.
- Background Script (
entrypoints/background.ts) - Handles extension icon clicks, keyboard shortcuts, and coordinates with content scripts - Content Script (
entrypoints/content.tsx) - Main processing logic that converts webpage content to markdown - Options Page (
entrypoints/options/) - React-based settings UI with shadcn/ui components
The extension supports three content extraction modes:
- Defuddle - Advanced content extraction and markdown cleanup (default)
- Mozilla Readability - Article extraction using Mozilla's Readability algorithm
- Basic Turndown - Direct HTML to markdown conversion
Special handling for YouTube videos:
- Extracts video information via YouTube's internal API
- Downloads and converts SRT subtitles to clean markdown
- Includes video title and formatted transcript
defuddle- Main content extraction and cleanup@mozilla/readability- Alternative article extractionturndown- HTML to markdown conversionjs-tiktoken- Token counting for LLM usage estimation
react&react-dom- Options page UI@radix-ui/react-switch- Toggle componentssonner- Toast notificationstailwindcss- Utility-first CSS framework
@fxts/core- Functional programming utilities (memoization)ofetch- HTTP client for API requestssrt-parser-2- SRT subtitle parsing
Options are stored using the browser's storage.sync API with the following structure:
useDeffudle: boolean - Use Defuddle for content processinguseReadability: boolean - Use Mozilla Readability (mutually exclusive with Defuddle)wrapInTripleBackticks: boolean - Wrap output in markdown code blocksshowSuccessToast: boolean - Show success notificationsshowConfetti: boolean - Trigger Raycast confetti animation
The project uses TypeScript path aliases with @/ pointing to the root directory for clean imports.
/lib/storage.ts- Typed storage management with defaults/lib/showNotification.tsx- Toast notification system/lib/tagsToRemove.ts- HTML elements to filter during conversion/lib/yt/- YouTube-specific utilities for video info and subtitle extraction
/components/ToggleOption.tsx- Reusable settings toggle component/components/ui/- shadcn/ui component library integration
The project uses Biome instead of ESLint/Prettier with comprehensive rules configured in biome.jsonc. Code is automatically formatted with:
- 2-space indentation
- 80 character line width
- Semicolons as needed
- Sorted imports and Tailwind classes
Load the unpacked extension during development:
- Run
bun run dev - Open
chrome://extensions - Enable "Developer mode"
- Click "Load unpacked" and select
.output/chrome-mv3
- Chrome: Uses Manifest V3 by default
- Firefox: Use
dev:firefoxandbuild:firefoxcommands for MV2 compatibility
The extension uses message passing between background and content scripts:
COPY_TEXT- Process regular webpage contentCOPY_YOUTUBE_SUBTITLE- Handle YouTube video subtitlesOPEN_CONFETTI- Trigger Raycast confetti (background only)
YouTube data is fetched using internal YouTube API endpoints. The implementation includes comprehensive TypeScript interfaces for the YouTube API response structure.
- Defuddle processing includes fallback to basic Turndown on errors
- Storage operations have try-catch blocks with console error logging
- Missing subtitles or video info are handled gracefully