From 0e5a42c0ce6c561aaea72a951a6473ab2fcbfd14 Mon Sep 17 00:00:00 2001 From: Lumina Mystere Date: Mon, 11 Mar 2024 21:49:47 +1300 Subject: [PATCH] a --- src/Fluff4me.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/Fluff4me.ts b/src/Fluff4me.ts index 09a3ec4..4db9d95 100644 --- a/src/Fluff4me.ts +++ b/src/Fluff4me.ts @@ -70,10 +70,32 @@ export default class Fluff4me { for (const service of Object.keys(OAUTH_SERVICE_REGISTRY)) document.getElementById(service) ?.addEventListener("click", () => void openOAuthPopup(service)); + + const signupbutton = document.createElement("button"); + signupbutton.textContent = "Sign Up"; + document.body.append(signupbutton); + signupbutton.addEventListener("click", async () => { + await fetch(`${Env.API_ORIGIN}author/create`, { + method: "POST", + headers: { + "Content-Type": "application/json", + ...Session.headers(), + }, + body: JSON.stringify({ + vanity: "chiri", + }), + }); + }); } } namespace Session { + export function headers () { + return Object.fromEntries(Object.entries({ + "Session-Token": localStorage.getItem("Session-Token"), + }).filter(([, value]) => value !== null && value !== undefined)); + } + export async function refresh () { const headers: HeadersInit = {}; let sessionToken = localStorage.getItem("Session-Token");