redacted my info, into my database #1
2 changed files with 9 additions and 3 deletions
|
|
@ -47,7 +47,7 @@
|
|||
lock.name = "darkreader-lock";
|
||||
document.head.appendChild(lock);
|
||||
|
||||
console.log(await re.TryGetUnredacter());
|
||||
await re.TryGetUnredacter();
|
||||
});
|
||||
|
||||
function nextTheme() {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import type { Readable, Subscriber, Unsubscriber } from "svelte/store";
|
|||
|
||||
class Redactor implements Readable<Profile | undefined> {
|
||||
public unredactedProfile: Profile | undefined = undefined;
|
||||
public wrongKey: boolean | undefined = undefined;
|
||||
|
||||
private subs = new Set<Subscriber<Profile | undefined>>();
|
||||
subscribe(run: Subscriber<Profile | undefined>): Unsubscriber {
|
||||
|
|
@ -16,7 +17,7 @@ class Redactor implements Readable<Profile | undefined> {
|
|||
this.subs.forEach((s) => s(this.unredactedProfile));
|
||||
}
|
||||
|
||||
async TryGetUnredacter(): Promise<Profile> {
|
||||
async TryGetUnredacter(): Promise<Profile | string> {
|
||||
if (this.unredactedProfile) return this.unredactedProfile;
|
||||
|
||||
const storedKey = localStorage.getItem("key");
|
||||
|
|
@ -32,6 +33,11 @@ class Redactor implements Readable<Profile | undefined> {
|
|||
|
||||
const unredactHash = hashResJson.response;
|
||||
initEnv();
|
||||
if (unredactHash == "nawh") {
|
||||
console.log("Wrong key, keeping info about alex secret");
|
||||
return "Wrong key";
|
||||
}
|
||||
|
||||
const url = `${env.POCKETBASE_URL}/api/collections/redacted_content/records/${unredactHash}`;
|
||||
|
||||
const res = await fetch(url, {
|
||||
|
|
@ -46,7 +52,7 @@ class Redactor implements Readable<Profile | undefined> {
|
|||
);
|
||||
this.unredactedProfile = parseProfile(replaced.json);
|
||||
this.notify(); // <-- tell Svelte to update
|
||||
return this.unredactedProfile;
|
||||
return "success";
|
||||
}
|
||||
|
||||
t(path: string, fallback: string): string {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue