A Chrome extension that detects accepted submissions on LeetCode and provides time and space complexity analysis through OpenAI.
- The extension observes DOM changes on /submissions/ pages.
- When "Accepted" is detected, a confirmation popup appears.
- If confirmed, the code is extracted from the page and sent to OpenAI API.
- Analysis is displayed in a floating panel.
- Clone this repository
git clone https://github.com/jvarCS/BetterSolutionsLC.git
- Add the extension to Chrome
- Go to
chrome://extensions/- Enable
developer mode - Click on
load unpacked - Select the project folder
You've installed the extension. Nice work. You have to make one quick change before you can use it though.
In background.js at the top, there is a line for an OpenAI key
chrome.runtime.onInstalled.addListener(() => {
chrome.storage.local.set({
openaiKey: "put your own"
});
console.log("API key stored");
});
Replace put your own with your actual OpenAI api key.
Then, go back to
chrome://extensions/
and refresh the extension. Now its ready to be used.
The extension is setup and its time to use it. Do so by going on LeetCode and solving problems. You'll be prompted for analysis upon accepted submissions.
Currently the analysis depends on the OpenAI api. This means there will eventually be a fee associated with your api key if you use it enough, though it would take a while to accumulate even a dollar.
Fix for this would be to include a local llm option to avoid the fee all together and improve privacy as a bonus.
The current analysis looks at your code's time and space complexity and gives a short description for each and for your code in general. More in-depth analysis could see specific suggestions be included to optimize parts of your code.
