Greasy Fork is available in English.

LeetCode Toolkit

Find & Save Editorial, Copy problem as Markdown or Download as Jupyter Notebook, Format on Save, Unlock IntelliSense, Display Problem Ratings and more.

Skapare
eclipher
Dagliga installationer
1
Totala installationer
22
Betyg
0 0 0
Version
2.7.2
Skapad
2025-04-08
Uppdaterad
2025-08-06
Size
135 KB
Licens
MIT
Gäller för

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

  • On Description Tab:

    • Copy Title: For some reason the problem title is an unclickable link, and you can't simply double click it to select the text. This button will copy the title to your clipboard.
    • Copy Description: Copy the problem description in Markdown format. Ideal for pasting into into your notes, or for asking an AI assistant.
    • Save as Jupyter Notebook: Bundles the problem title, description in Markdown, and the current code you have into a single .ipynb file. See About Jupyter Notebook section for more detail.
    • A difficulty rating(**) of the problem (if one exists) will be displayed in addition to the original difficulty label, offering a more accurate evaluation than "easy" "medium" "hard" labels. The source of the ratings is Leetcode Problem Rating Project.
  • On Editorial Tab:

    • Find Screenshot(*): If you don't have access to an editorial, click on this button to try to find a screenshot of the editorial. If found, it will open the link to the screenshot. The source of the screenshots is Leetcode Screenshotter.
    • Save Editorial as Markdown(*): If you do have access to an editorial, click on this button and the script will scrape the editorial and download it as one single .md file. See About Editorial Scraping section for more detail.
  • The code editor receives some quality-of-life adjustments:

    • Format On Save: Automatically format code when pressing Ctrl + S.
    • Unlock IntelliSense: Enjoy autocompletion and hover suggestions without paying for premium.

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).

  1. Install Tampermonkey or a similar userscript manager for your browser.
  2. Click on the "Install this script" button on this page.
  3. 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