Chrome extension (Manifest V3) that commits your accepted solutions from LeetCode and GeeksforGeeks to a GitHub repository.
This project is a fork in the LeetHub ecosystem:
- Original LeetHub by Qasim Wani: https://github.com/QasimWani/LeetHub
- LeetHub-3.0 reference implementation (LeetCode.com + LeetCode.cn): https://github.com/raphaelheinz/LeetHub-3.0
- Automated Submission Handling: When you submit a solution on LeetCode or GeeksforGeeks and it gets Accepted, the extension automatically creates/updates a folder for that problem in your configured GitHub repo.
- Manual Import: You can manually import your existing accepted solutions from LeetCode by clicking the "Sync" button in the extension popup. This does not happen automatically to prevent unwanted commits.
- Deduplication: It tracks solved counts and file SHAs in
chrome.storage.localto avoid duplicate commits.
LeetHub-3.0 (raphaelheinz) focuses on LeetCode compatibility and adds:
- LeetCode.cn support in addition to LeetCode.com.
- A manual synchronization button (including syncing previously-selected submissions).
- Notes about UI compatibility (old layout vs dynamic layout).
This fork’s notable additions/changes:
- Manifest V3 + stricter CSP with PAT-first auth (fine-grained PAT recommended).
- Repo sync seeding: scans an existing repo and seeds
stats.shato avoid duplicate uploads. - Manual Backfill: imports existing accepted solutions from LeetCode only when explicitly triggered.
- Multi-accepted handling options: latest accepted per language, or keep all accepted submissions (suffix filenames with
_<submissionId>).
- Open
chrome://extensions. - Enable Developer mode.
- Click Load unpacked.
- Select this folder (
LeetHub).
- Click the extension icon.
- Authenticate with GitHub using one of these:
- Fine-grained PAT (recommended): create a fine-grained Personal Access Token restricted to a single repository, then paste it into the popup and click Save token.
- OAuth (convenient): click Authorize with GitHub and complete the OAuth flow.
- On the setup (welcome) page, choose one:
- Create repo (new repo), or
- Link repo (use an existing repo).
If you link a repo that already contains solutions, LeetHub performs a one-time sync that:
- Scans the repo file tree.
- Seeds the internal
stats.shamap so future uploads update existing files instead of re-creating them. - Updates the solved count based on existing problem folders.
- LeetCode: solve a problem -> submit -> once it shows Accepted, the extension commits to GitHub.
- GeeksforGeeks: same idea—when the submission is accepted, it commits to GitHub.
You can view your linked repo and progress stats from the extension popup.
Install dev dependencies:
npm run setupCommon commands:
npm run format
npm run format-test
npm run lint
npm run lint-test- Auth loops / no token saved: finish the GitHub OAuth flow and ensure you didn’t block GitHub cookies/popups.
- Nothing uploads after AC: confirm a repo is linked (mode is
commit), and check extension errors inchrome://extensions-> Service worker -> Inspect. - GitHub API errors / rate limits: syncing very large repos can take time and can hit rate limits.
- Stores the GitHub token in
chrome.storage.local. - Sends requests only to
github.com,api.github.com,leetcode.com, andpractice.geeksforgeeks.org.
- Creating a new repo does not automatically limit a GitHub OAuth token to that repo. OAuth scopes are account-wide.
- If you want repo-scoped access, use a fine-grained PAT restricted to the single repo you want LeetHub to write to (grant Contents: Read and write).
- LeetHub’s OAuth flow uses PKCE (no embedded client secret), but it’s still broader access than a repo-restricted fine-grained PAT.
Goal: create a token that can only write to one repository.
- Open GitHub token settings:
- Under Token name, pick any name (e.g.
leethub). - Set an Expiration (recommended).
- Under Repository access, choose:
- Only select repositories -> pick the repo you want LeetHub to write to.
- Under Permissions -> Repository permissions, set:
- Contents: Read and write
- Metadata: Read-only (usually required)
- Click Generate token.
- Copy it immediately (GitHub won’t show it again).
- In the extension popup -> paste into Fine-grained token -> click Save token.
Notes:
- OAuth in this repo uses a fixed GitHub OAuth client id; for forks (this being one), OAuth may not work. Using a fine-grained PAT avoids this.
- If your repo is owned by an organization, the org may need to allow/approve fine-grained PATs.
- If you get
403errors while uploading, your token likely lacks Contents: Read and write or the repo wasn’t selected.