From a42c8be258da9b53db7c4b311896d44d354b1514 Mon Sep 17 00:00:00 2001 From: CatAClock Date: Sun, 25 May 2025 17:37:14 -0700 Subject: [PATCH] remove 1kb I am god --- JS/expanded.js | 60 ++++++++++++++++++++------------------------------ 1 file changed, 24 insertions(+), 36 deletions(-) diff --git a/JS/expanded.js b/JS/expanded.js index 57a5dd1..2cec846 100644 --- a/JS/expanded.js +++ b/JS/expanded.js @@ -76,7 +76,7 @@ async function SetThreadPost(element, i) { if (i.classList.contains("Handle")) { window.location.href = "../../HTML/account.html?website=" + website; } else { - document.location.href = "./expanded.html?website=" + website; + window.location.href = "../../HTML/expanded.html?website=" + website; } } @@ -141,43 +141,10 @@ async function GetPost() { SetBoost(); // Now time to see if there are any parents. if (post.hasOwnProperty("reply")) { - Parentpost = await BlueskyAPI.GetRecord(post.reply.parent.uri.split("/")[2], post.reply.parent.uri.split("/")[3], post.reply.parent.uri.split("/")[4]); - document.getElementsByClassName("Origin Parent")[0].innerHTML = website; - document.getElementsByClassName("Handle Parent")[0].innerHTML = post.reply.parent.author.handle; - Text = BlueskyAPI.ApplyFacets(Parentpost.value, Parentpost.value.text); - Text = Text.replace(/\r?\n|\r/g, "
"); - // Sensitive topic :3 - if (Parentpost.value.hasOwnProperty("labels") && Parentpost.value.labels.length != 0) { - document.getElementsByClassName("PostText Parent")[0].innerHTML = "LABELS APPLIED: "; - console.log(Parentpost.value.labels); - for (let lab of Parentpost.value.labels.values) { - document.getElementsByClassName("PostText Parent")[0].innerHTML += lab.val + " "; - } - } else { - document.getElementsByClassName("PostText Parent")[0].innerHTML = Text; - if (Parentpost.value.hasOwnProperty("embed")) { - ApplyMedia(Parentpost.value.embed, document.getElementsByClassName("Images Parent")[0], post.reply.parent.author.did); - } - } + Parentpost = await BlueskyReplyFunction("Parent", post.reply.parent, post.reply.parent.author); // Now time to see if there are any grandparents. if (Parentpost.value.hasOwnProperty("reply")) { - GrandParentpost = await BlueskyAPI.GetRecord(Parentpost.value.reply.parent.uri.split("/")[2], Parentpost.value.reply.parent.uri.split("/")[3], Parentpost.value.reply.parent.uri.split("/")[4]); - document.getElementsByClassName("Origin GrandParent")[0].innerHTML = website; - document.getElementsByClassName("Handle GrandParent")[0].innerHTML = post.reply.grandparentAuthor.handle; - Text = BlueskyAPI.ApplyFacets(GrandParentpost.value, GrandParentpost.value.text); - Text = Text.replace(/\r?\n|\r/g, "
"); - // Sensitive topic :3 - if (GrandParentpost.value.hasOwnProperty("labels") && GrandParentpost.value.labels.length != 0) { - document.getElementsByClassName("PostText GrandParent")[0].innerHTML = "LABELS APPLIED: "; - for (let lab of GrandParentpost.value.labels.values) { - document.getElementsByClassName("PostText GrandParent")[0].innerHTML += lab.val + " "; - } - } else { - document.getElementsByClassName("PostText GrandParent")[0].innerHTML = Text; - if (GrandParentpost.value.hasOwnProperty("embed")) { - ApplyMedia(GrandParentpost.value.embed, document.getElementsByClassName("Images GrandParent")[0], post.reply.grandparentAuthor.did); - } - } + GrandParentpost = await BlueskyReplyFunction("Parent", Parentpost.value.reply.parent, post.reply.grandparentAuthor); } } } else { @@ -203,6 +170,27 @@ async function MastodonReplylFunction(ClassName, post) { return OtherPost; } +async function BlueskyReplyFunction(ClassName, post, OtherAuthor) { + let OtherPost = await BlueskyAPI.GetRecord(post.uri.split("/")[2], post.uri.split("/")[3], post.uri.split("/")[4]); + document.getElementsByClassName("Origin " + ClassName)[0].innerHTML = website; + document.getElementsByClassName("Handle " + ClassName)[0].innerHTML = OtherAuthor.handle; + Text = BlueskyAPI.ApplyFacets(OtherPost.value, OtherPost.value.text); + Text = Text.replace(/\r?\n|\r/g, "
"); + // Sensitive topic :3 + if (OtherPost.value.hasOwnProperty("labels") && OtherPost.value.labels.length != 0) { + document.getElementsByClassName("PostText " + ClassName)[0].innerHTML = "LABELS APPLIED: "; + for (let lab of OtherPost.value.labels.values) { + document.getElementsByClassName("PostText " + ClassName)[0].innerHTML += lab.val + " "; + } + } else { + document.getElementsByClassName("PostText " + ClassName)[0].innerHTML = Text; + if (OtherPost.value.hasOwnProperty("embed")) { + ApplyMedia(OtherPost.value.embed, document.getElementsByClassName("Images " + ClassName)[0], OtherAuthor.did); + } + } + return OtherPost; +} + // Applyers. Essentially applies a thing to an operation. // Finds any associated media and applies it to the post. async function ApplyMedia(Media, Element, Author = undefined) {