Recently Leetcode started to deprecate the old session system, and the button to create a new session is not clickable, sooo we cannot create new sessions anymore. This is a simple script that creates a new session for you.
- Clone the repository, make sure you have Node.js installed
- Open index.js
- Enter your Leetcode session under LEETCODE_SESSION
- Enter your Leetcode csrf token under CSRF_TOKEN
- Change NEW_SESSION_NAME to the name of the new session you want to create
- Fire up your terminal and run
node index.js
- Enjoy
WARNING: Sometimes Leetcode servers reject requests with 403 (maybe it hits new (post deprecation) server nodes with their Load Balancer (just a guess).
I have added retries count to make requests run until it passes with 200. If it stops working completely (and I'm sure it will after some time) it's nothing we can do.
- Open Leetcode in your browser
- Open developer tools
- Go to Application tab
- Find the cookies section
- Copy the value of
LEETCODE_SESSION
andcsrftoken
Use at your own risk. Since this is not an official API. Leetcode may change the way they handle sessions at any time, remove this endpoint, rate limit it, or do anything else. Since this script is using deprecated way of creating sessions, it's just a matter of time when they will remove it and this script will stop working.