From 8d4408651620dd86a9cc724f1881f43d331bbda1 Mon Sep 17 00:00:00 2001 From: Jack Case Date: Sat, 8 Nov 2025 20:37:52 +0000 Subject: [PATCH] signup form submission from popup server needs work to support properly --- manifest.json | 2 ++ package.json | 1 + pages/action_popup.html | 37 +++++++++++++++++++++++++++---------- src/browser-action.ts | 22 ++++++++++++++++++++++ yarn.lock | 19 +++++++++++++++++++ 5 files changed, 71 insertions(+), 10 deletions(-) diff --git a/manifest.json b/manifest.json index 6f169ca..15f8d12 100644 --- a/manifest.json +++ b/manifest.json @@ -13,6 +13,8 @@ "*://*.duckduckgo.com/*" ], + "content_security_policy": "script-src 'self' 'wasm-unsafe-eval'; object-src 'self'; worker-src 'self' blob:", + "browser_action": { "default_icon": "icons/virus-slash.png", "default_title": "Slop Farmer", diff --git a/package.json b/package.json index dff4433..2d64861 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,7 @@ { "dependencies": { "@types/firefox-webext-browser": "^143.0.0", + "altcha": "^2.2.4", "typescript": "^5.9.3" } } diff --git a/pages/action_popup.html b/pages/action_popup.html index d901cdc..761f737 100644 --- a/pages/action_popup.html +++ b/pages/action_popup.html @@ -4,17 +4,34 @@ - + Slop Farmer -

Log in to enable slop checking and reporting

-
- - - - - -
-

You're logged in.

+
+
+ + + + + + +
+
+ +
+

Log in to enable slop checking and reporting

+
+ + + + + +
+

You're logged in.

+
+ +
+ +
\ No newline at end of file diff --git a/src/browser-action.ts b/src/browser-action.ts index a0b2d83..0ffe1ef 100644 --- a/src/browser-action.ts +++ b/src/browser-action.ts @@ -2,11 +2,17 @@ import { API_URL, send_message_to_background } from "./common.js" const login_form = document.getElementById("login-form") as HTMLFormElement const login_status = document.getElementById("login-status") + +const signup_form = document.getElementById("signup-form") as HTMLFormElement + if (localStorage.getItem("accessToken")) { login_status.setAttribute("style", "visibility: visible;") } + login_form.addEventListener("submit", (event) => { event.preventDefault(); submit_login_form() }) +signup_form.addEventListener("submit", (event) => { event.preventDefault(); submit_signup_form() }) + async function submit_login_form() { const login_url = new URL("/login", API_URL) @@ -31,4 +37,20 @@ async function submit_login_form() { else { //bad login, update the form } +} + +async function submit_signup_form() { + const signup_url = new URL("/signup", API_URL) + + const request = new Request(signup_url, { + method: "POST", + body: new FormData(signup_form) + }) + + const response = await fetch(request) + + console.log(response) + if (response.ok) { + + } } \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index b0d25f7..d9c002c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,11 +2,30 @@ # yarn lockfile v1 +"@altcha/crypto@^0.0.1": + version "0.0.1" + resolved "https://registry.yarnpkg.com/@altcha/crypto/-/crypto-0.0.1.tgz#0e2f254559fb350c80ff56d29b8e3ab2e6bbea95" + integrity sha512-qZMdnoD3lAyvfSUMNtC2adRi666Pxdcw9zqfMU5qBOaJWqpN9K+eqQGWqeiKDMqL0SF+EytNG4kR/Pr/99GJ6g== + +"@rollup/rollup-linux-x64-gnu@4.18.0": + version "4.18.0" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.18.0.tgz#1a7481137a54740bee1ded4ae5752450f155d942" + integrity sha512-xuglR2rBVHA5UsI8h8UbX4VJ470PtGCf5Vpswh7p2ukaqBGFTnsfzxUBetoWBWymHMxbIG0Cmx7Y9qDZzr648w== + "@types/firefox-webext-browser@^143.0.0": version "143.0.0" resolved "https://registry.yarnpkg.com/@types/firefox-webext-browser/-/firefox-webext-browser-143.0.0.tgz#29413c9f393d4c4b5622d4a74182ff0219e98620" integrity sha512-865dYKMOP0CllFyHmgXV4IQgVL51OSQQCwSoihQ17EwugePKFSAZRc0EI+y7Ly4q7j5KyURlA7LgRpFieO4JOw== +altcha@^2.2.4: + version "2.2.4" + resolved "https://registry.yarnpkg.com/altcha/-/altcha-2.2.4.tgz#e89d9e6fbdf3a754e40a458f0f353b6dd495a5b2" + integrity sha512-UrU2izh1pISqzd7TCAJiJB2N+r7roqA348Qxt1gJlW5k9pJpbDDmMcDaxfuet9h/WFE6Snrritu/WusmERarrg== + dependencies: + "@altcha/crypto" "^0.0.1" + optionalDependencies: + "@rollup/rollup-linux-x64-gnu" "4.18.0" + typescript@^5.9.3: version "5.9.3" resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.9.3.tgz#5b4f59e15310ab17a216f5d6cf53ee476ede670f"