From 5e1cf0a83b9069eee89623dc535aa8f67c9b61e0 Mon Sep 17 00:00:00 2001 From: BOTAlex Date: Tue, 7 Oct 2025 17:51:10 +0200 Subject: [PATCH] correctly gets unredactor --- src/routes/+layout.svelte | 13 ++++++++++--- src/ts/Redaction/Redactor.ts | 11 ++++++----- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 21b6322..5ca6bd1 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -23,13 +23,17 @@ navbarHidden = true; } - import { afterNavigate } from "$app/navigation"; - afterNavigate(() => { + function handleUrlParams() { const params = new URLSearchParams(window.location.search); hideOnPrint = params.get("hideOnPrint") === "1"; if (!!params.get("key")) { localStorage.setItem("key", params.get("key")!); } + } + + import { afterNavigate } from "$app/navigation"; + afterNavigate(() => { + handleUrlParams(); }); import onMount from "@e/onMount"; @@ -37,10 +41,13 @@ import CustomScrollBar from "./comps/CustomScrollBar.svelte"; onMount(async () => { + handleUrlParams(); + const lock = document.createElement("meta"); lock.name = "darkreader-lock"; document.head.appendChild(lock); - re.TryGetUnredacter(); + + console.log(await re.TryGetUnredacter()); }); function nextTheme() { diff --git a/src/ts/Redaction/Redactor.ts b/src/ts/Redaction/Redactor.ts index eac2d9c..f647531 100644 --- a/src/ts/Redaction/Redactor.ts +++ b/src/ts/Redaction/Redactor.ts @@ -5,11 +5,14 @@ class Redactor { const storedKey = localStorage.getItem("key"); if (!storedKey) throw new Error("Missing key"); + let jsonKey = JSON.stringify({ key: storedKey }); + console.log("Requesting unredactor.json with: " + jsonKey); + const hashResJson = await ( - await fetch("http://api.deprived.dev/unredact", { + await fetch("http://localhost:8000/unredact", { method: "POST", headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ key: storedKey }), + body: jsonKey, }) ).json(); @@ -25,9 +28,7 @@ class Redactor { if (!res.ok) throw new Error(`HTTP ${res.status}`); const data = await res.json(); - const item = data?.items?.[0]; - const raw = JSON.parse(item.file); - return parseProfile(raw); + return parseProfile(data); } }