Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LeetCode Code Analyzer

Extension in use

LeetCode Code analysis

A Chrome extension that adds a "⚡ Analyze" button to LeetCode problem pages. It reads the code you've currently written in the editor and sends it to Groq's free LLM API to get:

  • Time complexity
  • Space complexity
  • Correctness notes / edge cases
  • Suggested improvements
  • A cleaner approach, if one exists

Everything runs with your own Groq API key, stored locally in your browser (chrome.storage.sync) — it's never sent anywhere except directly to Groq's API.

1. Get a free Groq API key

  1. Go to https://console.groq.com/keys
  2. Sign in and click "Create API Key"
  3. Copy the key (starts with gsk_...)

2. Install the extension (unpacked, for development)

  1. Unzip this folder somewhere permanent (don't delete it afterwards).
  2. Open Chrome and go to chrome://extensions
  3. Turn on Developer mode (top-right toggle)
  4. Click Load unpacked
  5. Select the leetcode-analyzer folder

3. Set up your key

  1. Click the extension icon in the Chrome toolbar
  2. Paste your Groq API key
  3. Pick a model (Llama 3.3 70B is a good default — fast and free)
  4. Click Save settings

4. Use it

  1. Open any problem on leetcode.com/problems/...
  2. Write or paste your solution in the code editor
  3. Click the ⚡ Analyze button in the bottom-right corner
  4. A panel slides in from the right with the analysis

How it works (architecture)

  • inject.js — runs in the page's own JS context (world: "MAIN") so it can read window.monaco directly and pull the current code out of the Monaco editor model. This is necessary because Chrome extension content scripts normally run in an isolated world that can't see the page's own JS variables.
  • content.js — runs in the isolated world (normal content script). It injects the floating button and results panel, asks inject.js for the current code via window CustomEvents, grabs the problem title/description from the DOM, and messages the background worker to run the analysis.
  • background.js — the MV3 service worker. Holds your API key, builds the prompt, and calls Groq's OpenAI-compatible /chat/completions endpoint with response_format: { type: "json_object" } so the model reliably returns structured JSON.
  • popup.html / popup.js — settings UI for the API key and model choice.

Notes & limitations

  • LeetCode changes its DOM/class names periodically. If the problem title or description stops being detected, the analysis still works (code is the important part) — it just has less context.
  • Free Groq rate limits apply (generous, but not unlimited). If you hit a rate limit, the panel will show the error message from the API.
  • This tool is for understanding and improving your own solutions — not a substitute for actually solving the problem yourself.

About

No description or website provided.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages