How iszhouhua/social-media-copilot works
Project type and purpose
• This is a browser-extension (Chrome MV3) plugin written in TypeScript + React (WXT framework) that automates data collection from social-media platforms (小红书 XHS, 抖音 DY, 快手 KS).
• It provides a popup UI for user interactions, background scripts for orchestration and cross-origin data fetching, and content scripts injected into each platform’s web pages to parse and process platform data.
File structure
• Top-level directories:
• src/entrypoints – extension entry points:
– background/ – background script
– popup/ – extension popup UI (React+HTML)
– xhs.content/, dy.content/, ks.content/ – content scripts and platform-specific API/task modules
• src/components – shared React UI components
• src/utils – messaging, task orchestration, fileinfo, tailwind helpers
• docs/ – markdown docs and screenshots
• Key config files:
• wxt.config.ts – WXT build config for MV3 packaging
• web-ext.config.ts – additional extension build settings
• postcss.config.js, tailwind.config.js – styling
• tsconfig.json – TypeScript settings
README for additional insights
• Confirms use of WXT framework
• Lists features per platform (download media, crawl posts/comments/authors)
• Describes workflow: install extension → connect to server → invoke server-side APIs that proxy through plugin → receive data
Main components to illustrate
a. Browser environment
– Chrome host runs the extension (MV3)
b. Extension components
– Background Service Worker
• Orchestrates messages, holds persistent socket.io or WebSocket client for server connections (in server-mode)
• Receives commands from popup and forwards to content scripts
• Executes cross-origin fetch requests when needed
– Popup UI (React)
• Renders form fields, buttons, progress indicators using src/components
• Sends messages to background to begin crawling tasks
– Content Scripts (per platform)
• Injected into social media pages (xhs.content, dy.content, ks.content)
• Each has:
– api/ modules (request wrappers, typings)
– tasks/ modules (author, post, comment, mix-post processors & UI entrypoints)
– utils/ for media URL extraction, parsing
• Communicates with background via chrome.runtime messaging
c. Shared modules
– src/components – UI primitives, forms, dialogs (Tailwind + React)
– src/utils – messaging.ts, task.ts, fileinfo.ts, tw.ts
d. Static assets & localization
Relationships and data flows
1) User clicks button in Popup UI →
2) popup → background (chrome.runtime.sendMessage) →
3) background → content script (chrome.tabs.sendMessage) →
4) content script invokes platform’s API via fetch or via background on its behalf →
5) content script processes JSON/data, extracts media URLs, comment lists, author info →
6) content script → background (results) →
7) background → popup (update UI / download links)
• In server-mode (not open source branch), add socket.io channel:
background ↔ server (websocket)
Architectural patterns & design principles
• MV*(ish):
• UI layer (Popup)
• Orchestration layer (Background Worker)
• Platform logic layer (Content Scripts)
• Separation of concerns: platform-specific code isolated under each entrypoint
• Reusable React components under src/components
• Messaging bus via chrome.runtime for loose coupling
• Tailwind CSS + WXT for extensible, themable UI