How flanker/bilibili-dark-mode works
Main Components
A. Browser Extension Components:
• Popup Interface (from /popup directory)
• Content Scripts (from /contents directory)
• Background Service Worker (implied by modern extension architecture)
B. External Systems:
• Bilibili.com Website
• Chrome/Edge Extension Store
• Browser Extension API
┌─ Browser Context ──────────────────────────────┐
• ┌─ DarkBili Extension ─────────────────────┐ │
• ┌─ Popup UI ─┐ ┌─ Content Scripts ┐ │ │
• index.tsx │◄──►│ dark-mode.ts │ │ │
• index.css │ │ dark-mode.css │ │ │
• ┘ └────────────────┬─┘ │ │
• ▲ │ │ │
• ▼ │ │
• ┌─ Extension Storage ─┐ ┌─ DOM ──┐ │ │
• ┘ └────────┘ │ │
• ┬──┘ │
• ┼────┘
• ┌──────▼─────┐
• Bilibili │
• Website │
• ┘
Important Relationships
a. Data Flow:
• Popup → Content Scripts: Theme toggle commands
• Content Scripts → DOM: Style injection
• Extension Storage → Popup: User preferences
• Content Scripts → Bilibili Website: DOM manipulation
b. Dependencies:
• TypeScript compilation flow
• CSS injection paths
• Browser API interactions
Technical Stack Highlights
Technology indicators:
• TypeScript/TSX for components
• CSS for styling
• Plasmo framework
• Browser Extension APIs
Implementation Details
• The separation between the popup interface and content scripts
• How the dark mode styles are injected into the target website
• Storage and state management for user preferences
• Browser extension security boundaries