LeetCode Toolkit
https://github.com/eclipher/Userscripts/blob/main/userscripts/leetcode-toolkit/README.md
Features
This userscript enhances the LeetCode with various tweaking and additions. It supports both the US version of LeetCode.com, and the China version.
Problem Page
Explore Cards
- Save Article as Markdown(*): Scrape and download an Explore Card article as markdown file. See About Editorial Scraping section for more detail.
(*) These features are for US site only.
(**) This feature relies on Tampermonkey's window.onurlchange API. If you're using a different userscript manager that doesn't support this API, the rating may not update correctly when you navigate between problems without a full page reload.
About Editorial Scraping
LeetCode editorial articles contains codes, slides, videos, math expressions and so on. You can use any Markdown readers to view the scraped .md
files, but I developed a dedicated LeetCode Editorial Reader app to view them in best layout.
A few things to notice:
- Codes: will be saved as multiple code blocks in different languages. LeetCode Editorial Reader can display them in tab layout.
- Slides are saved as a series of images. LeetCode Editorial Reader can display them in true slide layout.
- Speaking of images, they are saved as Base64-encoded string, which means they are directly inside the markdown without the risk of "image not found". (This also makes the file larger though.)
- Math expressions are saved, but you may need compatible viewers such as VS Code or LeetCode Editorial Reader to render them correctly.
- Videos are not saved. That's a headache I don't want to deal with.
About Jupyter Notebook
Jupyter Notebook is an open-source web application that allows you to create and share documents that contain live code, equations, visualizations, and narrative text.
The Save as Jupyter Notebook
feature helps you transfer LeetCode problems into a Jupyter Notebook document, so you can read the problem, write and run the solution, add additional notes, all at one place on your local machine.
You can open .ipynb
notebooks with clients such as VS Code. By default it supports Python, but kernels for many other languages are available too.
Installation
To use this userscript, you'll need a userscript manager like Tampermonkey (available for Chrome, Firefox, and other browsers).
- Install Tampermonkey or a similar userscript manager for your browser.
- Click on the "Install this script" button on this page.
- Visit a LeetCode problem page, and you should see the new features added by the script.
Credits
This script is inspired by the following projects:
License
MIT License