How wintorse/copylink-dev works
Project Type and Purpose
• This is a browser extension (Chrome + Firefox) written in TypeScript/Vite.
• Its purpose is to let end users trigger keyboard shortcuts to copy Markdown-style links or Slack-formatted links from any web page, with site-specific title formatting and emoji support.
File Structure
• Top level:
• src/ — TypeScript source, split into popup logic, background scripts, content scripts, utilities, types
• .github/workflows — CI/CD for releases
• vite.config.js, tsconfig.json — build configuration
• In src/:
• src/popup/popup.ts — UI logic for the extension popup and settings page
• src/scripts/background.ts & background_firefox.ts — event listeners, command registration, central message router
• src/scripts/content.ts — injected script that lives in the web page context
• src/scripts/commands.ts — maps keyboard shortcuts to actions
• src/scripts/copyTextLink.ts & formattedTitleRetriever.ts & getEmojiName.ts — core business logic modules
• src/utils/notification.ts & toast.ts — helper modules for user notifications
• src/types — shared type definitions and constants
Extract Key Insights from the README
• Core features: Copy link, copy link with Slack emoji, copy title.
• Site support: Google Workspace, GitHub, Jira, Asana, Backlog, Redmine, plus custom sites via regex.
• Installation flows for Chrome vs Firefox (background_firefox.ts differs slightly).
• Keyboard commands configurable in the browser settings.
Main Components
a. Manifest & Static Assets (public/)
b. Popup UI
c. Background Script (Chrome & Firefox variants)
d. Content Script (in-page)
e. Business Logic Modules (formattedTitleRetriever, copyTextLink, getEmojiName)
f. Utility Modules (notification, toast)
g. External Targets: Web pages (various sites), Clipboard API, Browser Commands API
Relationships & Interactions
• Popup sends/receives messages to/from Background via browser.runtime.sendMessage.
• User triggers keyboard shortcut → Browser Commands API invokes Background Script handler.
• Background Script injects or communicates with Content Script in active tab.
• Content Script uses formattedTitleRetriever & getEmojiName to build the link string.
• Result is sent back to Background, which writes to the Clipboard via Clipboard API or uses background.execClipboard.
• Notification or toast UI (via content script injection or popup) confirms success.
• Settings stored via chrome.storage (not in file tree, but implied).
Architectural Patterns & Design Principles
• Modular separation: UI layer (popup), orchestration layer (background), domain logic (scripts/*), helpers (utils/*).
• Message-driven: All interactions use the browser’s messaging framework.
• Platform abstraction: background.ts vs background_firefox.ts.
• Build pipeline: Vite bundles TS → dist/ for Chrome and Firefox.