How to write the content of a web page to a local file?

I want to write to replicate the code and test cases from a Leetcode page into a local file

Basically to bypass the rate limit of compiling on leetcode, I would like to sync the code between my local file and the leetcode environment.

I would like

  1. to copy the code from the leetcode text editor and prefix with some headers, main() and write to a local file (vscode workspace ex: C:/workspace/solution.cpp)
  2. to copy test cases to a local testcases files (ex: C:/workspace/test.txt)

What I have tried: creating a chrome extension:
this can read from local file to browser, but cant write to a specific local filesystem
(i looked into chrome extension storage api but its sandboxed?)