A Node.js project that extracts Leetcode submissions and pushes them to a repository. See an example repository.
- Node.js 20+
- Bash
- Get Leetcode tokens from your Leetcode cookie.
The easiest way to do this is by opening your browser's inspect mode and loading a page while signed into Leetcode. Then, switch to the network tab and choose a request that is being sent to Leetcode, such as a graphql request. In the headers for the request Headers section, you will find a Cookie containing your "LEETCODE_SESSION" and "csrftoken". Do not share these tokens with anybody.
- Save tokens in a json file.
Save the tokens in a in a json file with the following format:
{
"LEETCODE_SESSION": "...",
"csrftoken": "..."
}
-
Set the environment variable LEETCODE_CREDENTIALS_PATH to the path to the file.
-
Create a remote repository to push to. Set the variable githubRepo in the bash script run.sh.
githubRepo="..." # <-- your github repo ssh URL
Note: Occasionally you will need to get fresh tokens and replace the ones in your tokens file.
Run the following command from your Bash terminal:
npm start
Add file extension support for all Leetcode languages