How decodingafterlife/sweetcode works
SweetCode is a browser extension that turns successful LeetCode practice into timed access to selected social sites, and spends that allowance on AI hints. Its main loop is submission detection, validation and difficulty-based reward, followed by allowance enforcement and countdown on social pages. The popup also configures the AI model and reset period, extracts problem context, requests hints from Groq and charges time; content.js presents reward feedback. README documents these capabilities, while excerpts omit some wiring details, so uncertain connections are not shown.
Main entry points: background.js Extension coordinator · popup.js Hint generation · content.js Reward feedback · popup.html Extension popup
Components 19
Practice rewards
- Extension coordinator
background.js - Submission tracking
background.js - Reward calculation
background.js - Reward feedback
content.js
Access control
- Allowance state
background.js - Daily and period reset
background.js - Social-site matching
background.js - Navigation gate
background.js - Access countdown
background.js - Blocked page
blocked.html
Hint assistant
- Extension popup
popup.html - Popup behavior
popup.js - Hint and model settings
popup.js - Problem context extraction
popup.js - Hint generation
popup.js
Other components
- Learner
- LeetCode
- Social sites
- Groq API
Connections 31
- LeetCode → Submission tracking: submits to
- Submission tracking → Extension coordinator: notifies
- Extension coordinator → LeetCode: fetches history
- Extension coordinator → Reward calculation: checks difficulty
- Reward calculation → Allowance state: adds reward
- Extension coordinator → Reward feedback: dispatches popup
- Reward feedback → Learner: shows reward
- Extension coordinator → Allowance state: loads and saves
- Daily and period reset → Allowance state: resets
- Extension coordinator → Daily and period reset: checks schedule
- Extension coordinator → Social-site matching: checks URL
- Extension coordinator → Navigation gate: registers navigation
- Navigation gate → Social-site matching: tests destination
- Navigation gate → Blocked page: redirects
- Extension coordinator → Access countdown: starts timer
- Access countdown → Allowance state: reads and decrements
- Access countdown → Blocked page: redirects at zero
- Learner → Extension popup: opens
- Extension popup → Popup behavior: runs
- Popup behavior → Hint and model settings: loads and saves
- Hint and model settings → Allowance state: reads allowance
- Popup behavior → Problem context extraction: extracts problem
- Problem context extraction → LeetCode: reads page
- Popup behavior → Hint generation: requests hint
- Hint generation → Groq API: sends context
- Groq API → Hint generation: returns hint
- Hint generation → Extension coordinator: requests deduction
- Extension coordinator → Allowance state: deducts hint cost
- Hint generation → Learner: displays hint
- Learner → Social sites: visits
- Navigation gate → Social sites: allows when funded