Manifest V3 Chrome extension that watches LeetCode problem pages and uploads accepted solutions to Google Drive.
manifest.json- extension manifest and OAuth2 placeholdercontent.js- detects an accepted submission and extracts title, language, and source codebackground.js- authenticates with Google Drive and uploads the solution intoLeetCode-Solutions
- Create an OAuth client in Google Cloud Console for Chrome extension use.
- Copy your OAuth client ID into
manifest.json:
"oauth2": {
"client_id": "YOUR_GOOGLE_OAUTH_CLIENT_ID.apps.googleusercontent.com",
"scopes": ["https://www.googleapis.com/auth/drive"]
}- Make sure the OAuth client is allowed to request the Google Drive scope used by the extension.
- Open
chrome://extensions/. - Enable Developer mode.
- Click Load unpacked.
- Select the
d:\ChromeExtensionfolder. - Pin the extension if you want quick access.
- The extension only runs on
https://leetcode.com/problems/*. - When an accepted submission appears,
content.jsextracts the problem title, the editor language, and the current source code. background.jsrequests a Google Drive token throughchrome.identity.getAuthToken, creates theLeetCode-Solutionsfolder if needed, and uploads the code as a file such asTwo-Sum.cpp.- The content script opens a small status dialog while saving to Drive and while loading a saved solution so you can see that it is working.
- The extension uses the Google Drive scope so it can search for and create the dedicated folder.
- If you change the OAuth client ID, reload the extension from
chrome://extensions/.