π Building a LeetCode Rank Search Chrome Extension β Track Multiple Users in One Click!

Table of contents
- π§ Motivation
- Overcoming the Challenge of Data Access on LeetCode
- π What the Extension Does
- βοΈ Tech Stack
- π§° Folder Structure
- π§± Key Components
- π How the Flow Works
- π‘ Special Features
- πΈ Preview
- β οΈ Common Pitfall: Rank Page Not Found?
- π How to Install Locally
- π Open Source
- π Final Thoughts

π§ Motivation
Have you ever participated in a LeetCode contest and then spent time manually flipping through rank pages just to find where you or your friends placed?
I did too. And it was painful.
So, I decided to solve it with code β by building a Chrome extension that automates this entire process!
In this post, Iβll walk you through:
Challenge for data access on LeetCode π«
The idea π‘
The tech stack βοΈ
How it works π§©
Chrome extension architecture π§±
Publishing & usage π
Overcoming the Challenge of Data Access on LeetCode
π« API Blocking by LeetCode
LeetCode has strict anti-bot mechanisms in place that block automated API requests. This makes traditional API-based data retrieval methods unreliable for scraping or automation tasks.
π Dynamic Frontend Architecture
LeetCodeβs frontend is built on dynamic JavaScript frameworks. The platform frequently updates its internal routing, selectors, and page structures, often breaking static scraping solutions.
β Our Adaptive Solution: Real-Time Page Scraping
To overcome these challenges, we implemented real-time page scraping using browser automation. By simulating real user interactions, we dynamically search for usernames on the leaderboard and determine their corresponding pages.
π§ Smart DOM Traversal for Robustness
Instead of relying on static links or outdated selectors, our method adapts to DOM changes by querying elements intelligently. This makes our solution more robust against frontend updates and layout shifts.
π‘ Result: Resilient and Reliable Data Extraction
This adaptive approach ensures that we can consistently retrieve user data from LeetCode, even as the platform evolves. It strikes a balance between compliance and flexibility in a dynamically changing environment.
π What the Extension Does
LeetCode Rank Search is a Chrome extension that:
β Lets you enter multiple LeetCode usernames β Automatically flips through contest ranking pages β Finds the page number for each user β Stops when all users are found β Gives you a friendly floating UI to view results
βοΈ Tech Stack
- π§ JavaScript (Vanilla, for DOM manipulation & search logic)
π§° Folder Structure
leetcode-rank-search-extension/
βββ manifest.json
βββ background.js
βββ content.js
βββ popup.html
βββ popup.js
βββ styles.css
βββ icon16.png
βββ icon48.png
βββ icon128.png
βββ screenshot.png
βββ README.md
π§± Key Components
1. manifest.json
The brain of the extension, defining permissions, content scripts, icons, and popup.
"content_scripts": [
{
"matches": ["https://leetcode.com/contest/*/ranking/*"],
"js": ["content.js"]
}
],
"action": {
"default_popup": "popup.html"
},
"icons": {
"16": "icon16.png",
"48": "icon48.png",
"128": "icon128.png"
}
2. popup.html
+ popup.js
Provides a simple UI button (Start Search
) that sends a message to the active tab to trigger the rank search.
3. content.js
Handles:
Prompting for user IDs
Navigating back to the first page
Looping through rank pages
Detecting usernames
Updating the floating dialog
Handling STOP and Search Again
π How the Flow Works
You open the LeetCode contest ranking page (e.g.,
weekly-contest-455/ranking
)Click the extension icon β hit βStart Searchβ
You enter usernames like:
alice123, bob_dev, codewarrior
Extension:
Goes to the first page
Starts flipping pages
Checks for usernames on each page
Displays found page numbers in a nice floating box
Stops when done or on your command
π‘ Special Features
β Multi-user support
π Manual STOP at any time
π Search Again without reloading
β Close button to dismiss the box
π§± Handles dynamically loaded LeetCode pages
π§ Special case handled: if rank table not found, instructs user to reload the page
πΈ Preview
A floating UI helps you track user ranks in real-time while flipping pages automatically.
β οΈ Common Pitfall: Rank Page Not Found?
Sometimes LeetCode uses dynamic loading which makes the table undetectable initially.
π§ Fix: Just reload the contest rank page and try again.
π How to Install Locally
Clone the repo or download ZIP
Go to
chrome://extensions
Enable Developer Mode
Click βLoad unpackedβ and select the folder
Visit any LeetCode contest rank page and start using it!
π Open Source
Find the full source code on GitHub:
π GitHub Repo Link
Feel free to star, fork, or contribute!
π Final Thoughts
This was a fun weekend project that solved a real annoyance and introduced me to the world of Chrome Extensions + browser scripting.
If you're into problem-solving, automating workflows, or just love clean tools β consider trying it out!
Thanks for reading! π
More about Author
π Asutoshk - Linktree
Subscribe to my newsletter
Read articles from Asutosh Kataruka directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
