How saitokento/dlsite-browsing-companion works
1. Project type and runtime boundary
- This is a browser extension called DLsite Browsing Companion.
- The architecture is organized around extension contexts rather than a traditional app/server split: background script, content scripts injected into DLsite pages, and extension UI surfaces.
2. Framework and build model
- The repo is built with WXT (wxt.config.ts), which is why the source is organized around src/entrypoints/....
- TypeScript is the main implementation language, with React used for the extension UIs.
3. Core extension controller
- src/entrypoints/background.ts is the central non-UI runtime.
- In extension terms, this is the place for persistent coordination: cross-tab logic, shared state, and message routing between page scripts and extension UI.
4. Page-injected content scripts
- The repo has several content-script entrypoints tailored to specific DLsite pages:
- home.content.ts
- work.content.ts
- circle.content.ts
- cart.content.ts
- download.content.ts
- userbuy.content.ts
- These scripts are the boundary where the extension interacts with the DLsite website DOM and page context.
- The naming suggests page-specific augmentation rather than one generic scraper.
5. Data flow from site pages into the extension
- The likely primary flow is: DLsite page → content script → shared messaging/background → extension UI.
- This is reinforced by src/utils/messaging.ts, which indicates structured communication across extension contexts.
6. Extension UI surfaces
- There are three separate UI entrypoints:
- popup for the toolbar popup
- sidepanel for a persistent side panel
- options for configuration/settings
- Each UI has its own App.tsx, main.tsx, HTML shell, and CSS, so they are independent entrypoints rather than routes in one SPA.
7. Shared types and exports
- src/utils/types.ts and src/utils/exports.ts provide shared contracts and re-exports used across background, content scripts, and UI.
- This is important for keeping the message payloads and domain data consistent across isolated extension contexts.
8. Static assets
- public/icon contains extension icons and other static assets needed by the browser extension packaging pipeline.
- There is no separate backend or API asset pipeline shown in the tree.
9. Styling and UI implementation
- The UI entrypoints use plain CSS files alongside React components, which suggests a lightweight, per-surface styling approach.
- Each surface is self-contained, so popup/sidepanel/options can evolve independently.
10. Operational and delivery tooling
- The repo includes CI/release automation under .github/workflows, plus Husky hooks and Commitlint for commit hygiene.
- Tooling files for ESLint, Prettier, and pnpm lockfile indicate a strongly managed TypeScript codebase, but these affect development quality more than runtime architecture.
11. Architectural boundary summary
- The key architectural split is:
- Website context: DLsite page-specific content scripts
- Extension core: background coordinator
- Extension UI: popup, sidepanel, options
- Shared utilities connect these parts through typed messaging and common data definitions, rather than direct coupling.
12. What to show in a diagram
- A useful architecture diagram would place DLsite pages on one side, the extension background in the middle, and popup/sidepanel/options on the other side.
- Draw arrows showing content scripts reading/modifying page state and sending messages through the background to the UI surfaces.
Main entry points: background.ts Background · wxt.config.ts WXT config · messaging.ts Messaging · exports.ts Exports
Components 17
DLsite pages
Website contexts augmented by page-specific content scripts
- Home script · Injected into DLsite home pages
src/entrypoints/home.content.ts - Work script · Injected into DLsite work pages
src/entrypoints/work.content.ts - Circle script · Injected into DLsite circle pages
src/entrypoints/circle.content.ts - Cart script · Injected into DLsite cart pages
src/entrypoints/cart.content.ts - Download script · Injected into DLsite download pages
src/entrypoints/download.content.ts - Purchase script · Injected into DLsite purchase history pages
src/entrypoints/userbuy.content.ts
Extension core
Persistent background coordination and message routing
- Background · Persistent coordinator for state and routing
src/entrypoints/background.ts
Extension UI
Independent browser extension surfaces
- Popup app · Toolbar popup interface
src/entrypoints/popup/App.tsx - Popup entry · Popup mount and startup
src/entrypoints/popup/main.tsx - Sidepanel app · Persistent side panel interface
src/entrypoints/sidepanel/App.tsx - Sidepanel entry · Sidepanel mount and startup
src/entrypoints/sidepanel/main.tsx - Options app · Extension settings interface
src/entrypoints/options/App.tsx - Options entry · Options mount and startup
src/entrypoints/options/main.tsx
Shared and build
Contracts, messaging, and WXT entrypoint wiring
- WXT config · Extension build and entrypoint wiring
wxt.config.ts - Shared types · Common domain and message types
src/utils/types.ts - Messaging · Cross-context message helpers
src/utils/messaging.ts - Exports · Shared re-exports for extension contexts
src/utils/exports.ts
Connections 33
- WXT config → Background: builds · Registers the background entrypoint
- WXT config → Home script: builds · Registers page injection
- WXT config → Work script: builds · Registers page injection
- WXT config → Circle script: builds · Registers page injection
- WXT config → Cart script: builds · Registers page injection
- WXT config → Download script: builds · Registers page injection
- WXT config → Purchase script: builds · Registers page injection
- WXT config → Popup entry: builds · Registers popup surface
- WXT config → Sidepanel entry: builds · Registers side panel surface
- WXT config → Options entry: builds · Registers options surface
- Home script → Background: messages · Sends page-derived events and state
- Work script → Background: messages · Sends page-derived events and state
- Circle script → Background: messages · Sends page-derived events and state
- Cart script → Background: messages · Sends page-derived events and state
- Download script → Background: messages · Sends page-derived events and state
- Purchase script → Background: messages · Sends page-derived events and state
- Background → Popup app: updates · Feeds popup state and actions
- Background → Sidepanel app: updates · Feeds side panel state and actions
- Background → Options app: updates · Feeds settings state and actions
- Messaging → Background: used by · Shared message channel helpers
- Messaging → Home script: used by · Shared message channel helpers
- Messaging → Work script: used by · Shared message channel helpers
- Messaging → Circle script: used by · Shared message channel helpers
- Messaging → Cart script: used by · Shared message channel helpers
- Messaging → Download script: used by · Shared message channel helpers
- Messaging → Purchase script: used by · Shared message channel helpers
- Shared types → Messaging: defines · Typed payload contracts
- Exports → Shared types: re-exports · Shared surface for common contracts
- Exports → Messaging: re-exports · Shared surface for message helpers
- Exports → Background: imports · Common extension helpers
- Exports → Popup app: imports · Common extension helpers
- Exports → Sidepanel app: imports · Common extension helpers
- Exports → Options app: imports · Common extension helpers