--- name: leetcode-daily-card description: A Node.js script that fetches the daily LeetCode challenge and renders it as a PNG card, HTML page, or Markdown document. metadata: {"clawdbot":{"emoji":"📋","os":["linux","darwin","win32"]}} --- # LeetCode Daily Card Generator A Node.js script that automatically fetches the daily LeetCode challenge and renders it as a PNG card, HTML page, or Markdown document. ## Features - **Automatic Daily Fetch**: Retrieves the current daily LeetCode problem via GraphQL API - **Browser Rendering**: Uses Puppeteer for high-quality PNG output with CSS styling - **Multiple Output Formats**: `.png` (image), `.html` (styled page), `.md` (markdown) - **Theme Support**: Light and dark themes - **CJK Support**: Noto Sans SC and system fonts for Chinese characters - **Code Highlighting**: Syntax highlighting via highlight.js - **LaTeX Support**: KaTeX rendering for math formulas ## Installation ```bash cd scripts npm install ``` ## Dependencies - **puppeteer-core**: Browser automation (uses local Chrome/Edge) - **marked**: Markdown parsing - **katex**: LaTeX math rendering - **highlight.js**: Code syntax highlighting ## Usage ```bash # Generate PNG card (default light theme) node run.js output.png # Generate PNG with dark theme node run.js output.png --dark # Generate HTML page node run.js output.html # Generate Markdown document node run.js output.md # Custom max width (for long descriptions) node run.js output.png --max-width=800 --dark ``` ## Output Formats ### PNG Card - Gradient header with date and LeetCode icon - Question title, ID, difficulty badge, acceptance rate - Tags as styled pills - Full problem description with code formatting - Footer with link to problem page ### HTML Page - Same styling as PNG, exportable as standalone file - Responsive design - Interactive links ### Markdown Document - Clean Markdown formatting - Question metadata in Info section - Full problem description - Example test cases - Link to problem page ## Supported Platforms - **Windows**: Chrome/Edge from default installation paths - **macOS**: Chrome/Edge from Applications - **Linux**: Chrome/Chromium from system PATH ## Workflow ``` LeetCode GraphQL API ↓ Fetch Question Data ↓ Generate HTML Template ↓ Browser Rendering (PNG) / File Output (HTML/MD) ``` ## Browser Configuration The script auto-detects installed browsers in this order: 1. `CHROME_PATH` environment variable 2. Google Chrome 3. Microsoft Edge 4. Chromium ```bash # Force specific browser CHROME_PATH="C:\Program Files\Google\Chrome\Application\chrome.exe" node run.js output.png ``` ## Notes - Requires internet access to fetch from LeetCode API - Browser must be installed for PNG/HTML output - Markdown output works without browser