correctly gets unredactor
All checks were successful
Rebuild signaller for deprived.dev to rebuild site / test_service (push) Successful in 15s

This commit is contained in:
BOTAlex 2025-10-07 17:51:10 +02:00
parent 47cea68e04
commit 5e1cf0a83b
2 changed files with 16 additions and 8 deletions

View file

@ -23,13 +23,17 @@
navbarHidden = true; navbarHidden = true;
} }
import { afterNavigate } from "$app/navigation"; function handleUrlParams() {
afterNavigate(() => {
const params = new URLSearchParams(window.location.search); const params = new URLSearchParams(window.location.search);
hideOnPrint = params.get("hideOnPrint") === "1"; hideOnPrint = params.get("hideOnPrint") === "1";
if (!!params.get("key")) { if (!!params.get("key")) {
localStorage.setItem("key", params.get("key")!); localStorage.setItem("key", params.get("key")!);
} }
}
import { afterNavigate } from "$app/navigation";
afterNavigate(() => {
handleUrlParams();
}); });
import onMount from "@e/onMount"; import onMount from "@e/onMount";
@ -37,10 +41,13 @@
import CustomScrollBar from "./comps/CustomScrollBar.svelte"; import CustomScrollBar from "./comps/CustomScrollBar.svelte";
onMount(async () => { onMount(async () => {
handleUrlParams();
const lock = document.createElement("meta"); const lock = document.createElement("meta");
lock.name = "darkreader-lock"; lock.name = "darkreader-lock";
document.head.appendChild(lock); document.head.appendChild(lock);
re.TryGetUnredacter();
console.log(await re.TryGetUnredacter());
}); });
function nextTheme() { function nextTheme() {

View file

@ -5,11 +5,14 @@ class Redactor {
const storedKey = localStorage.getItem("key"); const storedKey = localStorage.getItem("key");
if (!storedKey) throw new Error("Missing key"); if (!storedKey) throw new Error("Missing key");
let jsonKey = JSON.stringify({ key: storedKey });
console.log("Requesting unredactor.json with: " + jsonKey);
const hashResJson = await ( const hashResJson = await (
await fetch("http://api.deprived.dev/unredact", { await fetch("http://localhost:8000/unredact", {
method: "POST", method: "POST",
headers: { "Content-Type": "application/json" }, headers: { "Content-Type": "application/json" },
body: JSON.stringify({ key: storedKey }), body: jsonKey,
}) })
).json(); ).json();
@ -25,9 +28,7 @@ class Redactor {
if (!res.ok) throw new Error(`HTTP ${res.status}`); if (!res.ok) throw new Error(`HTTP ${res.status}`);
const data = await res.json(); const data = await res.json();
const item = data?.items?.[0]; return parseProfile(data);
const raw = JSON.parse(item.file);
return parseProfile(raw);
} }
} }