diff --git a/src/HTTP/JS/expanded.js b/src/HTTP/JS/expanded.js index cbb402e..117cec0 100644 --- a/src/HTTP/JS/expanded.js +++ b/src/HTTP/JS/expanded.js @@ -16,8 +16,7 @@ let Boostable = false; // Variables let website = document.location.href.split("website=")[1]; let post = JSON.parse(localStorage.getItem("post")); -let Parentpost; -let GrandParentpost; +let ThreadedPost = []; document.getElementsByClassName("Origin Regular")[0].innerHTML = website; GetPost(); @@ -123,11 +122,16 @@ async function GetPost() { } } // Now time to see if there are any parents + let NumberOfThreads = 0; if (post.in_reply_to_id != null) { - Parentpost = await MastodonReplylFunction("Parent", post.in_reply_to_id); + let TemporaryPost = await MastodonReplylFunction(NumberOfThreads, post.in_reply_to_id); + ThreadedPost.push(TemporaryPost); + NumberOfThreads += 1; // Now time to see if there are any grandparents - if (Parentpost != undefined && Parentpost.in_reply_to_id != null) { - GrandParentpost = await MastodonReplylFunction("GrandParent", Parentpost.in_reply_to_id); + while (TemporaryPost.in_reply_to_id != null) { + TemporaryPost = await MastodonReplylFunction(NumberOfThreads, TemporaryPost.in_reply_to_id); + ThreadedPost.push(TemporaryPost); + NumberOfThreads += 1; } } } else if (website == "Bluesky") { @@ -172,17 +176,17 @@ async function GetPost() { } // Because of repeat code, we can put it into it's own function. Hell, more of a thread can be added later. -async function MastodonReplylFunction(ClassName, post) { +async function MastodonReplylFunction(id, post) { let OtherPost = await MastodonAPI.GetStatus(post); - document.getElementsByClassName("Origin " + ClassName)[0].innerHTML = website; - document.getElementsByClassName("Handle " + ClassName)[0].innerHTML = OtherPost.account.acct; + let ShitHTML = "

" + website + "

" + OtherPost.account.acct + "


"; + document.getElementsByTagName("body")[0] = ShitHTML + document.getElementsByTagName("body")[0].innerHTML; if (OtherPost.spoiler_text != "") { - document.getElementsByClassName("PostText " + ClassName)[0].innerHTML = "WARNING: " + OtherPost.spoiler_text; + document.getElementsByClassName("PostText").getElementById(id).innerHTML = "WARNING: " + OtherPost.spoiler_text; } else { - document.getElementsByClassName("PostText " + ClassName)[0].innerHTML = OtherPost.content; + document.getElementsByClassName("PostText").getElementById(id).innerHTML = OtherPost.content; if (OtherPost.media_attachments.length != 0) { for (let i of OtherPost.media_attachments) { - ApplyMedia(i, document.getElementsByClassName("Images " + ClassName)[0]); + ApplyMedia(i, document.getElementsByClassName("Images").getElementById(id)); } } }