From a508c60c48916d5051905c5b05fe140000dd75a2 Mon Sep 17 00:00:00 2001 From: j harishankar Date: Mon, 30 Jun 2025 02:36:22 +0530 Subject: [PATCH 1/8] web scraping --- manifest.json | 5 +++-- popup.js | 14 ++++++++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/manifest.json b/manifest.json index ca20a22..e1f1992 100644 --- a/manifest.json +++ b/manifest.json @@ -2,8 +2,9 @@ "manifest_version": 3, "name": "LeetCode Helper", "version": "1.0", - "description": "Get AI-powered help while solving LeetCode problems.", - "permissions": [], + "description": "Get AI-powered help while solving LeetCode problems", + "permissions": ["activeTab", "scripting", "tabs"], + "host_permissions": ["https://leetcode.com/*"], "action": { "default_popup": "popup.html", "default_icon": { diff --git a/popup.js b/popup.js index b88a2a8..f9323ab 100644 --- a/popup.js +++ b/popup.js @@ -1,3 +1,13 @@ -document.getElementById("getHelp").addEventListener("click", () => { - alert("This will soon talk to your Django backend!"); +document.getElementById("getHelp").addEventListener("click", async () => { + chrome.tabs.query({ active: true, currentWindow: true }, async (tabs) => { + const tab = tabs[0]; + const url = tab.url; + const title = tab.title; + + console.log("LeetCode URL:", url); + console.log("Problem Title:", title); + + // For tomorrow: send to Django here + // fetch("http://127.0.0.1:8000/api/...", { method: "POST", body: ... }) + }); }); From 0f1c70583b9eb21df5114fc42e5131ee4ac201ec Mon Sep 17 00:00:00 2001 From: j harishankar Date: Mon, 30 Jun 2025 02:50:00 +0530 Subject: [PATCH 2/8] backend configuration added --- leetcode_backend/backend/__init__.py | 0 leetcode_backend/backend/asgi.py | 16 ++++ leetcode_backend/backend/settings.py | 122 +++++++++++++++++++++++++++ leetcode_backend/backend/urls.py | 22 +++++ leetcode_backend/backend/wsgi.py | 16 ++++ leetcode_backend/manage.py | 22 +++++ leetcode_backend/requirements.txt | 4 + 7 files changed, 202 insertions(+) create mode 100644 leetcode_backend/backend/__init__.py create mode 100644 leetcode_backend/backend/asgi.py create mode 100644 leetcode_backend/backend/settings.py create mode 100644 leetcode_backend/backend/urls.py create mode 100644 leetcode_backend/backend/wsgi.py create mode 100644 leetcode_backend/manage.py create mode 100644 leetcode_backend/requirements.txt diff --git a/leetcode_backend/backend/__init__.py b/leetcode_backend/backend/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/leetcode_backend/backend/asgi.py b/leetcode_backend/backend/asgi.py new file mode 100644 index 0000000..6aa1b52 --- /dev/null +++ b/leetcode_backend/backend/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for backend project. + +It exposes the ASGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/5.2/howto/deployment/asgi/ +""" + +import os + +from django.core.asgi import get_asgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'backend.settings') + +application = get_asgi_application() diff --git a/leetcode_backend/backend/settings.py b/leetcode_backend/backend/settings.py new file mode 100644 index 0000000..a78e826 --- /dev/null +++ b/leetcode_backend/backend/settings.py @@ -0,0 +1,122 @@ +""" +Django settings for backend project. + +Generated by 'django-admin startproject' using Django 5.2.3. + +For more information on this file, see +https://docs.djangoproject.com/en/5.2/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/5.2/ref/settings/ +""" + +from pathlib import Path + +# Build paths inside the project like this: BASE_DIR / 'subdir'. +BASE_DIR = Path(__file__).resolve().parent.parent + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/5.2/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = 'django-insecure-3i1tui3mzz&3ovzlutdog7y!j=8o9(vuah3yg*k!a57r%u(6%w' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = [] + + +# Application definition + +INSTALLED_APPS = [ + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', +] + +MIDDLEWARE = [ + 'django.middleware.security.SecurityMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', +] + +ROOT_URLCONF = 'backend.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], + }, + }, +] + +WSGI_APPLICATION = 'backend.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/5.2/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': BASE_DIR / 'db.sqlite3', + } +} + + +# Password validation +# https://docs.djangoproject.com/en/5.2/ref/settings/#auth-password-validators + +AUTH_PASSWORD_VALIDATORS = [ + { + 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', + }, +] + + +# Internationalization +# https://docs.djangoproject.com/en/5.2/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'UTC' + +USE_I18N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/5.2/howto/static-files/ + +STATIC_URL = 'static/' + +# Default primary key field type +# https://docs.djangoproject.com/en/5.2/ref/settings/#default-auto-field + +DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' diff --git a/leetcode_backend/backend/urls.py b/leetcode_backend/backend/urls.py new file mode 100644 index 0000000..c677216 --- /dev/null +++ b/leetcode_backend/backend/urls.py @@ -0,0 +1,22 @@ +""" +URL configuration for backend project. + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/5.2/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: path('', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.urls import include, path + 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) +""" +from django.contrib import admin +from django.urls import path + +urlpatterns = [ + path('admin/', admin.site.urls), +] diff --git a/leetcode_backend/backend/wsgi.py b/leetcode_backend/backend/wsgi.py new file mode 100644 index 0000000..ce5c079 --- /dev/null +++ b/leetcode_backend/backend/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for backend project. + +It exposes the WSGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/5.2/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'backend.settings') + +application = get_wsgi_application() diff --git a/leetcode_backend/manage.py b/leetcode_backend/manage.py new file mode 100644 index 0000000..eb6431e --- /dev/null +++ b/leetcode_backend/manage.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +"""Django's command-line utility for administrative tasks.""" +import os +import sys + + +def main(): + """Run administrative tasks.""" + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'backend.settings') + try: + from django.core.management import execute_from_command_line + except ImportError as exc: + raise ImportError( + "Couldn't import Django. Are you sure it's installed and " + "available on your PYTHONPATH environment variable? Did you " + "forget to activate a virtual environment?" + ) from exc + execute_from_command_line(sys.argv) + + +if __name__ == '__main__': + main() diff --git a/leetcode_backend/requirements.txt b/leetcode_backend/requirements.txt new file mode 100644 index 0000000..cba25e0 --- /dev/null +++ b/leetcode_backend/requirements.txt @@ -0,0 +1,4 @@ +asgiref==3.8.1 +Django==5.2.3 +sqlparse==0.5.3 +tzdata==2025.2 From cbe7e3af200886576bd06dbbcbe658726d7ae093 Mon Sep 17 00:00:00 2001 From: j harishankar Date: Mon, 30 Jun 2025 02:50:37 +0530 Subject: [PATCH 3/8] file restructured --- icon.png => extension/icon.png | Bin manifest.json => extension/manifest.json | 0 popup.html => extension/popup.html | 0 popup.js => extension/popup.js | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename icon.png => extension/icon.png (100%) rename manifest.json => extension/manifest.json (100%) rename popup.html => extension/popup.html (100%) rename popup.js => extension/popup.js (100%) diff --git a/icon.png b/extension/icon.png similarity index 100% rename from icon.png rename to extension/icon.png diff --git a/manifest.json b/extension/manifest.json similarity index 100% rename from manifest.json rename to extension/manifest.json diff --git a/popup.html b/extension/popup.html similarity index 100% rename from popup.html rename to extension/popup.html diff --git a/popup.js b/extension/popup.js similarity index 100% rename from popup.js rename to extension/popup.js From af51171b5af31c749bee976cd2d226d27c31daa5 Mon Sep 17 00:00:00 2001 From: J Hari Shankar Date: Mon, 30 Jun 2025 17:22:09 +0530 Subject: [PATCH 4/8] Initial commit --- README.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..7f6a677 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# Leetcode-Helper-2 +Chrome extension to help solve LeetCode problems with Django + AI From 451de2e9ab20566a430f9531ea70f7e2aa00ba2e Mon Sep 17 00:00:00 2001 From: J Hari Shankar Date: Mon, 30 Jun 2025 17:26:23 +0530 Subject: [PATCH 5/8] Update README.md --- README.md | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7f6a677..4f0d807 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,18 @@ -# Leetcode-Helper-2 -Chrome extension to help solve LeetCode problems with Django + AI +# LeetCode Helper Extension + +A Chrome extension to help users get step-by-step AI assistance while solving LeetCode problems. + +## ✅ Current Features +- Simple popup interface +- Button that will trigger AI help (to be added) + +## 🔧 Setup Instructions +1. Clone the repo +2. Go to `chrome://extensions` +3. Enable Developer Mode +4. Click "Load unpacked" and select this folder + +## 🔜 Coming Soon +- Integration with Django backend +- Gemini AI support +- Content script for reading problem content From b4d61bcc5e62f3c84ea7cd4b04242d72e72cc9d6 Mon Sep 17 00:00:00 2001 From: j harishankar Date: Mon, 30 Jun 2025 20:20:48 +0530 Subject: [PATCH 6/8] =?UTF-8?q?=E2=9C=A8=20Integrated=20Chrome=20extension?= =?UTF-8?q?=20with=20Django=20backend=20for=20LeetCode=20helper?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extension/popup.js | 16 +++++++++++- leetcode_backend/api/__init__.py | 0 .../api/__pycache__/__init__.cpython-313.pyc | Bin 0 -> 148 bytes .../api/__pycache__/admin.cpython-313.pyc | Bin 0 -> 192 bytes .../api/__pycache__/apps.cpython-313.pyc | Bin 0 -> 506 bytes .../api/__pycache__/models.cpython-313.pyc | Bin 0 -> 189 bytes .../api/__pycache__/urls.cpython-313.pyc | Bin 0 -> 293 bytes .../api/__pycache__/views.cpython-313.pyc | Bin 0 -> 1136 bytes leetcode_backend/api/admin.py | 3 +++ leetcode_backend/api/apps.py | 6 +++++ leetcode_backend/api/migrations/__init__.py | 0 .../__pycache__/__init__.cpython-313.pyc | Bin 0 -> 159 bytes leetcode_backend/api/models.py | 3 +++ leetcode_backend/api/tests.py | 3 +++ leetcode_backend/api/urls.py | 6 +++++ leetcode_backend/api/views.py | 23 ++++++++++++++++++ .../__pycache__/__init__.cpython-313.pyc | Bin 0 -> 152 bytes .../__pycache__/settings.cpython-313.pyc | Bin 0 -> 2583 bytes .../backend/__pycache__/urls.cpython-313.pyc | Bin 0 -> 1096 bytes .../backend/__pycache__/wsgi.cpython-313.pyc | Bin 0 -> 640 bytes leetcode_backend/backend/settings.py | 5 ++++ leetcode_backend/backend/urls.py | 3 ++- leetcode_backend/db.sqlite3 | 0 23 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 leetcode_backend/api/__init__.py create mode 100644 leetcode_backend/api/__pycache__/__init__.cpython-313.pyc create mode 100644 leetcode_backend/api/__pycache__/admin.cpython-313.pyc create mode 100644 leetcode_backend/api/__pycache__/apps.cpython-313.pyc create mode 100644 leetcode_backend/api/__pycache__/models.cpython-313.pyc create mode 100644 leetcode_backend/api/__pycache__/urls.cpython-313.pyc create mode 100644 leetcode_backend/api/__pycache__/views.cpython-313.pyc create mode 100644 leetcode_backend/api/admin.py create mode 100644 leetcode_backend/api/apps.py create mode 100644 leetcode_backend/api/migrations/__init__.py create mode 100644 leetcode_backend/api/migrations/__pycache__/__init__.cpython-313.pyc create mode 100644 leetcode_backend/api/models.py create mode 100644 leetcode_backend/api/tests.py create mode 100644 leetcode_backend/api/urls.py create mode 100644 leetcode_backend/api/views.py create mode 100644 leetcode_backend/backend/__pycache__/__init__.cpython-313.pyc create mode 100644 leetcode_backend/backend/__pycache__/settings.cpython-313.pyc create mode 100644 leetcode_backend/backend/__pycache__/urls.cpython-313.pyc create mode 100644 leetcode_backend/backend/__pycache__/wsgi.cpython-313.pyc create mode 100644 leetcode_backend/db.sqlite3 diff --git a/extension/popup.js b/extension/popup.js index f9323ab..e00ea0e 100644 --- a/extension/popup.js +++ b/extension/popup.js @@ -1,3 +1,4 @@ +console.log("📦 popup.js loaded"); document.getElementById("getHelp").addEventListener("click", async () => { chrome.tabs.query({ active: true, currentWindow: true }, async (tabs) => { const tab = tabs[0]; @@ -8,6 +9,19 @@ document.getElementById("getHelp").addEventListener("click", async () => { console.log("Problem Title:", title); // For tomorrow: send to Django here - // fetch("http://127.0.0.1:8000/api/...", { method: "POST", body: ... }) + fetch("http://127.0.0.1:8000/api/solve/", { + method: "POST", + headers: { + "Content-Type": "application/json" + }, + body: JSON.stringify({ + title: "Two Sum - LeetCode", + url: "https://leetcode.com/problems/two-sum" + }) + }) + .then(response => response.json()) + .then(data => console.log("✅ Response from Django:", data)) + .catch(error => console.error("❌ Error:", error)); + }); }); diff --git a/leetcode_backend/api/__init__.py b/leetcode_backend/api/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/leetcode_backend/api/__pycache__/__init__.cpython-313.pyc b/leetcode_backend/api/__pycache__/__init__.cpython-313.pyc new file mode 100644 index 0000000000000000000000000000000000000000..bc27834c3875e0e4812eff64ccf963b08b06108d GIT binary patch literal 148 zcmey&%ge<81hsWZ86f&Gh=2h`DC08=kTI1Zok5e)ZzV$!6Oi{ABz4Q!)hfm(HMJx; zKP6SyBQ>WWwJ0VB%8yS4Loh=yqc?*WV-ceQLpqZt^GlGlCgUyE z#FX63JU>mQTYM>5iFxVyddc~DB}JJ@Ma)12D;Yk6)ZH?0wTkgcO)W{zPf6AFNX;oo zEsDv3^5c^dle1IvQeqMdGGoA|=@nGo;;_lhPbtkwwJYKP8o&s|#URE9W=2NFdkhLi HY(NeGG5asI literal 0 HcmV?d00001 diff --git a/leetcode_backend/api/__pycache__/apps.cpython-313.pyc b/leetcode_backend/api/__pycache__/apps.cpython-313.pyc new file mode 100644 index 0000000000000000000000000000000000000000..acdd3178aee2ea8567571c0e134ed5b5b037e22d GIT binary patch literal 506 zcmXv~Jxjzu5Zz63=Y4qiEh-9XA*ArE1Q8MZL{x0H4Gepiy||i7;$~AQXd_tL_#^x` zmJ+bCx=uLloi%Y`XW!$!nVp$otJNTQ?jJgr&-i{C@_#BN7_K3BA&fA3Moy`s%VdtM z5@szBW_xtgE_})g9Jews#HD$CFG&vKs3(JNAs3OBWVndng?L0!MwG>49tCmR@3i}|FT%9FFN3{I$H!8Hes1$bzLE=fB(DKPye|Oq z1^`;K(BM&kn~aC0G6v9-D%GKkL=>Yu>5CrELJb@%qGn1u#+=Upq?&8l1+KM{olJ`q zK-I9Pp&2LNINJ8kh0tB>YW+lniBMixa_I2xwTOHVyThBL?c`RO&He>5SK7kxMBeAO z-kjO@=J?~G8voZXTsv=;W1D1Uc3q^K?+fDuqP(_K47#hPkeW58(-^*NO6dn#`L0@Y M;<^4q@cGO71=}EkzyJUM literal 0 HcmV?d00001 diff --git a/leetcode_backend/api/__pycache__/models.cpython-313.pyc b/leetcode_backend/api/__pycache__/models.cpython-313.pyc new file mode 100644 index 0000000000000000000000000000000000000000..c93b56afb70bc87a5344caef896a80cb41367210 GIT binary patch literal 189 zcmey&%ge<81hsWZ88$%rF^B^LOi;#W0U%>4Loh=yqc?*WV-ceQLpqZt^GlGlCgUx( z-29Z(oMJysrdymTS&4b+`FbfyMa)3Sl?m4b0Z} z(`3EHosyN9m!7XzT9i{<#0*q=ixs4#xQG?R<^~D_4Jk=2$}3*U@EIt?a7*9SD#j-@ zwIn$|B~{lWHK!o8C?*HWk55WW&Q8rsiAgNTi~$*`S5SG2!zMRBr8Fniu80SyALN{3 pIUwn5|B`W8sw=3QY=Ml?%gd5 ze<-i2iTN!?q6TI$i5QlCzQgGL9{vpXVt%`$O>@*TCqGF9jLS0m2sA-MMK1}`+)n`T zLI8GWBtgTx1d{G`m7n=c2VqhrEknOi4S$Jy;Q1C0(9? zZn^Md8gLA;e}G}fW0Zr>{(QH(a3iIxSsA6a zR7{Nrlp@yNcUy`{M>4tj0S;qKTjA8-YkQr0IPzOw9JCGte4o|gBaxF$9pXLZ(?wZE z6=gq4^*Q)0Tm16D7Z3W2XW3WJOIIGIU#I=bPpjXro|P)c=FoZJJNsL^zjWrjc5Drc z<%iv`x+lpu)#3b=VfogR`jg7jg@N<-(77>m zYC~sjSgt*0kMY3S809mI#gSpZoErn%$&Y|Nm;b8_=9l|RgX{Id@|#cDFZs=ZxjB{$ zK{X@t{#`FRAhj;%@#LDswQ1y^4t?Aq)Z>J*ntGO0-4rbWWwJ0VB%8yS$H!;pWtPOp>lIYq;;_lhPbtkwwJTx;ngg<@ Q7{vI<%*e=C#0+Es06b|WAOHXW literal 0 HcmV?d00001 diff --git a/leetcode_backend/backend/__pycache__/settings.cpython-313.pyc b/leetcode_backend/backend/__pycache__/settings.cpython-313.pyc new file mode 100644 index 0000000000000000000000000000000000000000..de24942da608d0247620f33632fbe5c15a329020 GI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=33U)h9j&A9YkNA^v5IT^wLOCydnPwA>KgY^$LQ*Zw<>^}@8SGSTt#ht5*7Q* zt_izm+S(*n{d0BR7}V_sc?ZSTi^BsPu(TfyMx4lqrMS;H?vdanO+%bE4@7KSmD zG83NbhAa?Hcudj(tJ(!DacSzdopo2TEDD6Hid|?gTx;tMNdQZD*7hh33d%*>0(8y6 zPr?wB6h}$Mxb!gYbC%%b#3xx+CMPtD`t`D2DNq8Y6v9>zJ6vwHR!Ut%me3WPl7v2N zskmiZPh%p)Y7c~kQ>cGq!Q_x~MZ_r>S9Ep&>wnm&dWQ&Kfh^m9FxpLncoatI08A+Q zDQW72D}QziV=z#G<59JA*~b0SN^fG<eNz+0=H$` z)=zaaZ7nxRm_(_q=Z11Tub0)QGezD#HAoh@rwy2ktkz$o!*gW67 fG#0-Zjk7!F_0QJj?Zr!D>B_7v=pUMV4gh`wzu7{q literal 0 HcmV?d00001 diff --git a/leetcode_backend/backend/__pycache__/wsgi.cpython-313.pyc b/leetcode_backend/backend/__pycache__/wsgi.cpython-313.pyc new file mode 100644 index 0000000000000000000000000000000000000000..fe5e958c26144c2e8ad5880c8a28ab52609ea879 GIT binary patch literal 640 zcmYjPPjAyO6t|PIPARJ@)0BSt7xjImBnmi ziVw&~68YG-_OQez+k4ioEp37Z_;9g;+~mW?O!@9hx`7;G?@ z0wYr@lj{+uDMVyAq*=z2km^M6;n48CFe<5#KoV{Q)9V2d+>j@Vj1vYAhyrjXT4!p@ z^CA%{H#(*~7L}(^q#kgu?LP7*;#3PSf{cl?6u9-GjjI93A!gT|anru=9GqbG}?|?<&wb;jwDf^Lh{%3qg=uLgmYIBW`H?y9KSZ zjZj_(K24Ad0?R-SSlI`q_@K%Kznh)q zi%;ec{8Tm#hxs%}ZJOh+jWPab)p2ch4`JswdiVob@0|s^R==sm) O`nTr&i-x>wK>q>Ow7OIP literal 0 HcmV?d00001 diff --git a/leetcode_backend/backend/settings.py b/leetcode_backend/backend/settings.py index a78e826..508f195 100644 --- a/leetcode_backend/backend/settings.py +++ b/leetcode_backend/backend/settings.py @@ -37,9 +37,13 @@ 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', + 'api', + 'corsheaders', ] MIDDLEWARE = [ + 'corsheaders.middleware.CorsMiddleware', + 'django.middleware.common.CommonMiddleware', 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', @@ -120,3 +124,4 @@ # https://docs.djangoproject.com/en/5.2/ref/settings/#default-auto-field DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' +CORS_ALLOW_ALL_ORIGINS = True diff --git a/leetcode_backend/backend/urls.py b/leetcode_backend/backend/urls.py index c677216..85c6942 100644 --- a/leetcode_backend/backend/urls.py +++ b/leetcode_backend/backend/urls.py @@ -15,8 +15,9 @@ 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from django.contrib import admin -from django.urls import path +from django.urls import path,include urlpatterns = [ path('admin/', admin.site.urls), + path('api/',include('api.urls')), ] diff --git a/leetcode_backend/db.sqlite3 b/leetcode_backend/db.sqlite3 new file mode 100644 index 0000000..e69de29 From a732d0bb2e6ba25fd2fa16abf3da09ec4e844b3e Mon Sep 17 00:00:00 2001 From: j harishankar Date: Tue, 1 Jul 2025 17:41:23 +0530 Subject: [PATCH 7/8] Send real-time tab title and URL from extension to Django API --- extension/popup.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extension/popup.js b/extension/popup.js index e00ea0e..f201e64 100644 --- a/extension/popup.js +++ b/extension/popup.js @@ -15,8 +15,8 @@ document.getElementById("getHelp").addEventListener("click", async () => { "Content-Type": "application/json" }, body: JSON.stringify({ - title: "Two Sum - LeetCode", - url: "https://leetcode.com/problems/two-sum" + title: title, + url: url }) }) .then(response => response.json()) From 5ed886ecb8be4f10fce63820999be4428eeff950 Mon Sep 17 00:00:00 2001 From: j harishankar Date: Tue, 1 Jul 2025 19:24:52 +0530 Subject: [PATCH 8/8] Finalized Working --- extension/popup.html | 18 ++++++++- extension/popup.js | 37 +++++++++++------- .../api/__pycache__/views.cpython-313.pyc | Bin 1136 -> 2057 bytes leetcode_backend/api/views.py | 33 +++++++++++----- .../__pycache__/settings.cpython-313.pyc | Bin 2583 -> 2649 bytes leetcode_backend/backend/settings.py | 1 + 6 files changed, 64 insertions(+), 25 deletions(-) diff --git a/extension/popup.html b/extension/popup.html index 56d12f3..06c8278 100644 --- a/extension/popup.html +++ b/extension/popup.html @@ -6,8 +6,13 @@ body { font-family: Arial, sans-serif; padding: 10px; - width: 250px; + width: 300px; } + + h3 { + margin-top: 0; + } + #getHelp { padding: 10px; background: #4CAF50; @@ -16,6 +21,15 @@ width: 100%; border-radius: 5px; cursor: pointer; + margin-bottom: 10px; + } + + ul { + padding-left: 20px; + } + + li { + margin-bottom: 5px; } @@ -23,6 +37,8 @@

Need Help with LeetCode?

+
    + diff --git a/extension/popup.js b/extension/popup.js index f201e64..50807f2 100644 --- a/extension/popup.js +++ b/extension/popup.js @@ -1,4 +1,5 @@ console.log("📦 popup.js loaded"); + document.getElementById("getHelp").addEventListener("click", async () => { chrome.tabs.query({ active: true, currentWindow: true }, async (tabs) => { const tab = tabs[0]; @@ -8,20 +9,28 @@ document.getElementById("getHelp").addEventListener("click", async () => { console.log("LeetCode URL:", url); console.log("Problem Title:", title); - // For tomorrow: send to Django here - fetch("http://127.0.0.1:8000/api/solve/", { - method: "POST", - headers: { - "Content-Type": "application/json" - }, - body: JSON.stringify({ - title: title, - url: url - }) - }) - .then(response => response.json()) - .then(data => console.log("✅ Response from Django:", data)) - .catch(error => console.error("❌ Error:", error)); + const response = await fetch("http://127.0.0.1:8000/api/solve/", { + method: "POST", + headers: { + "Content-Type": "application/json" + }, + body: JSON.stringify({ title, url }) + }); + + const data = await response.json(); + console.log("✅ Response from Django:", data); + + const output = document.getElementById("output"); + output.innerHTML = ""; + if (data.steps && Array.isArray(data.steps)) { + data.steps.forEach((step, index) => { + const li = document.createElement("li"); + li.textContent = step; + output.appendChild(li); + }); + } else { + output.innerHTML = "

    No steps found.

    "; + } }); }); diff --git a/leetcode_backend/api/__pycache__/views.cpython-313.pyc b/leetcode_backend/api/__pycache__/views.cpython-313.pyc index 9eccafe2d6c18f5ced78d74104a984437830ddb4..427e8efb787c95e89a138e54787ef8f472fc3b45 100644 GIT binary patch literal 2057 zcmaJC&rcLr_|4AD?(7eig{6QN<12!=mIaKZiNv%TG%6G@J8WAEaWl+3W=Cgdwr^%c z_F!x;Zrg(p+p?a@vG&%Jz55R=(gZq{#I#;|!{Vh$5B=V<3u;ooWaj(vzTfYgZ+4oR zA_yS-RL%b@AoM3=8UTC^c5Vau4#`O7#?cr@In3z5cwmgDe2wPE1uB4y9~Z}hG*pub zI-)6;X|m#Zw&E@N)1V8m=GHn9ip{e=#n_`LQv_wlc&i z+Ll9rkE#xx&yky?P;@7OmmK1{hNU||hm@j`yG|BWuI`GVAUr%gJ4XYot}Mzh>1!Z! zBcCFqJV$5-w00rW=tx5VxSQECkFUXSJ)*^BxlH)ALty2=o<`t*H26IYekR)RAPd<* z9LZvqkE4@9LjyVAV;&(5ZB0}2fcI>lbeP(IW9M!3iLou7#=G;k5Y+A zU${IaPy3>4xF+#=kD8@OhN#52L9`KE3iRVrHiGML#rFCr!HR{+%_5;L{)iBF)Yb?t z5X-gc06vR7hfr)dc)_OEVO+6oVK+~3k=k=6Dd1Wh@Z4SEyYVsa1*D!D*b8t0!ZP&& zR!ySNe(boUn4ViqGmLf5&=gAr4I4YQ395#R|G51vHZ0ZjG!~6$I>D;q5T_r{QO_mm zd7CneykW6)`XPA@+eOzX7$wCuAUi`NinE`>xhXt3HH{aj;Sy|9?0C9P92YC9>nSEy zq1t`rDa%}BrQHB0kSkSOq8lpC6SD|OVM}p63Pz@4>7Js$WLWAbfFsix)JegxjP!|t z;q<(zIC-Co_#&&;@kK(ZO-n7cAncZ~Vw&~>(TpYd3SkWd9Tx&PsU|;IAa35)eBl}_ z5nnWIMRR;%&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r~tMK(`olVoI+n7onQb2Ar*0V9_dP?`~li#aB{a9T}n L=DftB0ptPzuc0oy diff --git a/leetcode_backend/backend/settings.py b/leetcode_backend/backend/settings.py index 508f195..f9e5835 100644 --- a/leetcode_backend/backend/settings.py +++ b/leetcode_backend/backend/settings.py @@ -21,6 +21,7 @@ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = 'django-insecure-3i1tui3mzz&3ovzlutdog7y!j=8o9(vuah3yg*k!a57r%u(6%w' +GEMINI_API_KEY = "AIzaSyDU88ywematkfLK7q9j5GXIRlZhewSDH3E" # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True