diff --git a/extension-app/background.js b/extension-app/background.js new file mode 100644 index 0000000..0f295da --- /dev/null +++ b/extension-app/background.js @@ -0,0 +1,14 @@ +chrome.action.onClicked.addListener((tab) => { + const urlPattern = /leetcode\.com\/problems\/([\w-]+)\//; // Regex to match LeetCode problem URLs + const match = tab.url.match(urlPattern); + + if (match && match[1]) { + const problemID = match[1]; + const redirectUrl = `http://localhost:3000/problems/${problemID}`; + + // Open the corresponding whiteboard page in a new tab + chrome.tabs.create({ url: redirectUrl }); + } else { + console.log("Not a valid LeetCode problem page."); + } +}); diff --git a/extension-app/manifest.json b/extension-app/manifest.json new file mode 100644 index 0000000..23d3ddf --- /dev/null +++ b/extension-app/manifest.json @@ -0,0 +1,24 @@ +{ + "manifest_version": 3, + "name": "LeetCode Problem Redirector", + "version": "1.0", + "description": "Redirects to a specific whiteboard page for LeetCode problems.", + "permissions": [ + "tabs", + "activeTab" + ], + "background": { + "service_worker": "background.js" + }, + "action": { + // "default_popup": "popup.html" + // "default_icon": { + // "16": "icons/icon16.png", + // "48": "icons/icon48.png", + // "128": "icons/icon128.png" + // } + }, + "host_permissions": [ + "*://leetcode.com/*" + ] +} diff --git a/extension-app/popup.html b/extension-app/popup.html new file mode 100644 index 0000000..c5020e1 --- /dev/null +++ b/extension-app/popup.html @@ -0,0 +1,10 @@ + + + + LeetCode Redirect + + +

LeetCode Problem Redirector

+

Click the icon to go to the whiteboard page for the current problem.

+ +