NeatCode Grabber is a simple chrome extension for uploading your LeetCode problem solutions to GitHub.
It's a short and simple story. I store my LeetCode problem solutions in a git repository, in order to keep them in a safe place. I know that LeetCode permanently stores your submitted solutions, but I just like the idea of also storing them in a git repo. However, the process of creating a new file, copy-and-pasting the code into it, staging it and then committing got to tedious for my lazy being. This is why I decided to make this simple tool, which simply grabs and uploads the code for you.
If you also happen to have this extremely specific and (let's be honest) unnecessary problem, I hope this satisfies your needs. :D
- automatically detect problem ID, title and used programming language
- create new problem file
- update problem file
- check and show diff between local (the code in your browser) and remote (the code on GitHub) version
- copy remote version to clipboard
- dark and light appearance modes
NeatCode Grabber does NOT extract and upload the problem description.
-
Go download the latest release and extract the archive.
-
Open your Chromium based browser. (e.g.: Brave, Opera, Google Chrome, ...)
-
Open the context menu (usually three lines or dots in the top right corner) and click on
Extensions
(sometimesExtensions > Manage Extensions
). -
Enable
Developer mode
. -
Click the newly appeared
Load unpacked
option and navigate to the storage location of the application folder. -
Make sure the chosen folder contains the
index.html
andmanifest.json
files. -
Now pin the extension to make your life easier.
-
When clicking on the extension, a popup will appear that links to the options page.
-
In the options menu, the first thing you should do is change the appearance to
Dark
, which will boost your coding skills by a10x
modifier. -
I assume that you already have a GitHub repository for your LeetCode solutions. If not, create one now.
-
Then you will have to configure some GitHub stuff.
- your GitHub API token: you need to create a fine-grained personal access token (see this guide) that has read and write access to your repository
Contents
- your GitHub username
- your GitHub commit email address (which you can find here)
- your repository name
- your GitHub API token: you need to create a fine-grained personal access token (see this guide) that has read and write access to your repository
-
Don't forget to hit the
save
button. -
Now go and solve a LeetCode problem (e.g. Two Sums)
-
When you are happy with your code, hit that extension button, check the info (problem ID, title and programming language) and upload using the
create
button. -
Assuming that my code works (I know, very risky) and that you have configured everything correctly, a success message should pop up.
-
When you change the code and reopen the extension, it should show a
hide diff
button that will expand the diff view between the local and remote versions. -
In case you want to get the content of the remote file (on the GitHub repo), just hit
copy to clipboard
. -
And
update
simply updates the remote file to reflect your new changes. -
If you visit your GitHub repo, you should now see your uploaded code.
I have not yet found a reliable way for extracting the code in the editor window other than going through the corresponding HTML tags and extracting the textContent
. This works fine in most cases, however, when a line is too long it starts wrapping around, which is displayed as if the rest of the code were on a new line.
This means that NeatCode Grabber also interprets this as a new line, thus you get this undesired newline char in the middle of your code. When you check the actual file content on the GitHub repo, you can verify this.
My current workaround is simply to make the code editor bigger until there are no line wraps, before I upload my code. I know it's far from optimal, but it also doesn't occur that often, at least for me personally.
If you have any ideas how to solve this issue, I would be very happy. :D
Feel free to fork the project, create a feature branch, and send me a pull request!
This project is licensed under the MIT License.
You can reach out to me through Reddit. I'd love to chat about this project or any other interesting topics!