From a5f49e7d79cae44ce7ecd4a3a6627bc401a2b938 Mon Sep 17 00:00:00 2001 From: CatAClock Date: Thu, 17 Jul 2025 04:13:19 +0000 Subject: [PATCH 01/19] Update README.md --- README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 4e674f7..21ab19d 100644 --- a/README.md +++ b/README.md @@ -3,12 +3,10 @@ A frontend to accessing my account on the fediverse ## technologies -- node on a bare debian install. -- npm and npx to execute it. +- Rust and Rouille. - Uses MastodonAPI, BlueskyAPI, and YoutubeAPI[1]. -- Your local machine can also run it (with the proper dependencies; take a look at the docker file). -Quick launch server without docker: `npx http-server /home//Documents/Fedi.CrowdedGames.Group --port 4000 --cors` +Quick launch server: `Cargo run --release` ## FAQ -- 2.45.3 From 06770d107b99200cb295ede528f315f1ad7f3ea9 Mon Sep 17 00:00:00 2001 From: CatAClock Date: Wed, 16 Jul 2025 21:47:55 -0700 Subject: [PATCH 02/19] fixed the mastodon reblog. Again --- src/HTTP/JS/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/HTTP/JS/index.js b/src/HTTP/JS/index.js index 8b2347e..6776113 100644 --- a/src/HTTP/JS/index.js +++ b/src/HTTP/JS/index.js @@ -231,10 +231,10 @@ async function PosterContainerUpdate(Direction) { // Put the reblog into the regular post; Make changes as necessary. if (MastodonLoadedFeed[CurrentThing + counter].reblog != null && typeof MastodonLoadedFeed[CurrentThing + counter].reblog != "string") { // Fix a reblog issue. + i.getElementsByClassName("Username")[0].innerHTML = MastodonLoadedFeed[CurrentThing + counter].reblog.account.acct + " ( R: " + MastodonLoadedFeed[CurrentThing + counter].account.acct + " )"; let ReblogFix = MastodonLoadedFeed[CurrentThing + counter].account.acct; MastodonLoadedFeed[CurrentThing + counter] = MastodonLoadedFeed[CurrentThing + counter].reblog; MastodonLoadedFeed[CurrentThing + counter].reblog = ReblogFix; - i.getElementsByClassName("Username")[0].innerHTML = ReblogFix + " ( R: " + MastodonLoadedFeed[CurrentThing + counter].reblog + " )"; } else if (MastodonLoadedFeed[CurrentThing + counter].reblog != null && typeof MastodonLoadedFeed[CurrentThing + counter].reblog == "string") { // this function is if the changes are already made. i.getElementsByClassName("Username")[0].innerHTML = MastodonLoadedFeed[CurrentThing + counter].account.acct + " ( R: " + MastodonLoadedFeed[CurrentThing + counter].reblog + " )"; -- 2.45.3 From 2462400922beab1c937467e4b027ecfebd833484 Mon Sep 17 00:00:00 2001 From: CatAClock Date: Thu, 17 Jul 2025 09:06:48 -0700 Subject: [PATCH 03/19] I probably broke something --- src/HTTP/HTML/account.html | 1 + src/HTTP/JS/BlueskyAPI.js | 18 ++++++++++++++++++ src/HTTP/JS/MastodonAPI.js | 22 ++-------------------- src/HTTP/JS/account.js | 17 +++++++++++++++-- src/HTTP/JS/expanded.js | 17 +++++++++-------- src/HTTP/JS/mail.js | 28 ++-------------------------- 6 files changed, 47 insertions(+), 56 deletions(-) diff --git a/src/HTTP/HTML/account.html b/src/HTTP/HTML/account.html index 66f011c..c8d9a6c 100644 --- a/src/HTTP/HTML/account.html +++ b/src/HTTP/HTML/account.html @@ -25,6 +25,7 @@

Block!

+
diff --git a/src/HTTP/JS/BlueskyAPI.js b/src/HTTP/JS/BlueskyAPI.js index dae55a9..003ab27 100644 --- a/src/HTTP/JS/BlueskyAPI.js +++ b/src/HTTP/JS/BlueskyAPI.js @@ -100,6 +100,24 @@ export async function GetPosts(URIs) { return body; } +export async function GetFollows(Actor) { + if (Token == null) { + return ""; + } + let FetchThing = localStorage.getItem(Variables.BlueskyPDS) + "/xrpc/app.bsky.graph.getFollows?actor=" + Actor; + let DPoP = await ClientDPoPPDS("GET", FetchThing); + let request = fetch(FetchThing, { method: "GET", headers: {"Authorization": "DPoP " + Token, "DPoP": DPoP}}); + let body = await request.then((response) => response.json()); + let status = await request.then((response) => response.status); + let header = await request.then((response) => response.headers.get("dpop-nonce")); + if (status == 401) { + await HandleError(body, header); + body = await GetPosts(URIs); + } + return body; +} + +// Gets the parent. Gets the replies. Also gets the post shit. export async function GetPostThread(URI) { if (Token == null) { return ""; diff --git a/src/HTTP/JS/MastodonAPI.js b/src/HTTP/JS/MastodonAPI.js index b950692..a08b725 100644 --- a/src/HTTP/JS/MastodonAPI.js +++ b/src/HTTP/JS/MastodonAPI.js @@ -57,24 +57,6 @@ export async function GetRelationship(ID) { .then((response) => response.json()); } -// Gets the favorites of a user that you have access to. -export async function GetFavorites() { - if (Token == null || TokenType == null) { - return ""; - } - return await fetch(localStorage.getItem(Variables.MastodonWebsite) + "/api/v1/favourites", {method: "GET", headers: {"Authorization": TokenType + " " + Token}}) - .then((response) => response.json()); -} - -// Gets the bookmarks of a user that you have access to. -export async function GetBookmarks() { - if (Token == null || TokenType == null) { - return ""; - } - return await fetch(localStorage.getItem(Variables.MastodonWebsite) + "/api/v1/bookmarks", {method: "GET", headers: {"Authorization": TokenType + " " + Token}}) - .then((response) => response.json()); -} - // Gets the notifications of a user that you have access to. export async function GetNotifications() { if (Token == null || TokenType == null) { @@ -111,11 +93,11 @@ export async function GetOwnAccount() { } // Get your own account blocks. -export async function GetOwnAccountBlocks() { +export async function GetAccountFollows(ID) { if (Token == null || TokenType == null) { return ""; } - return await fetch(localStorage.getItem(Variables.MastodonWebsite) + "/api/v1/blocks/", {method: "GET", headers: {"Authorization": TokenType + " " + Token}}) + return await fetch(localStorage.getItem(Variables.MastodonWebsite) + "/api/v1/accounts/" + ID + "/Following", {method: "GET", headers: {"Authorization": TokenType + " " + Token}}) .then((response) => response.json()); } diff --git a/src/HTTP/JS/account.js b/src/HTTP/JS/account.js index 62dc8d1..0910068 100644 --- a/src/HTTP/JS/account.js +++ b/src/HTTP/JS/account.js @@ -18,7 +18,7 @@ let AlternateAccountDescription = document.getElementsByClassName("AccountDescri let FollowButton = document.getElementsByClassName("Follow")[0]; let BlockButton = document.getElementsByClassName("Block")[0]; -let AccountPosts = document.getElementsByClassName("Posts")[0]; +let AccountPosts = document.getElementsByClassName("Posts")[1]; // Other vars. let Following = false; @@ -126,10 +126,10 @@ async function GetAccount() { AccountImage.setAttribute("src", account.avatar); // Get their recent posts. Determine if they are cewl or not. let Posts = await BlueskyAPI.GetProfileFeed(account.did); - console.log(Posts); for (let i of Posts.feed) { AccountPosts.innerHTML += i.post.record.text + "

"; } + // No other accounts. Just you. } else { FollowButton.setAttribute("hidden", ""); BlockButton.setAttribute("hidden", ""); @@ -151,12 +151,25 @@ async function GetAccount() { } Token = localStorage.getItem(Variables.BlueskyAccessToken); if (Token != null) { + // Mastodon stuff. + let MastoProfile = await MastodonAPI.GetOwnAccount(); + // Get my followings on Mastodon. + let MyMastodonFollows = await MastodonAPI.GetAccountFollows(Mastodon.id); + for (let i of MyMastodonFollows) { + document.getElementsByClassName("Posts")[0].innerHTML += MyMastodonFollows.acct + "

"; + } + // Bluesky stuff. let BlueProfile = await BlueskyAPI.GetProfile(localStorage.getItem(Variables.BlueskyDID)); AlternateAccountImage.setAttribute("width", "20%"); AlternateAccountImage.setAttribute("height", "20%"); AlternateAccountName.innerHTML = BlueProfile.handle; AlternateAccountDescription.innerHTML = BlueProfile.description; AlternateAccountImage.setAttribute("src", BlueProfile.avatar); + // Get my followings on Bsky + let MyBlueskyFollows = await BlueskyAPI.GetFollows(localStorage.getItem(Variables.BlueskyDID)); + for (let i of MyBlueskyFollows.follows) { + AccountPosts.innerHTML += i.handle + "

"; + } } } diff --git a/src/HTTP/JS/expanded.js b/src/HTTP/JS/expanded.js index 82ca172..494add5 100644 --- a/src/HTTP/JS/expanded.js +++ b/src/HTTP/JS/expanded.js @@ -184,7 +184,6 @@ async function GetPost() { } // Replies, anyone? let Context = await BlueskyAPI.GetPostThread(post.post.uri); - console.log(Context); for (let i of Context.thread.replies) { TemporaryPost = await BlueskyReplyFunction(NumberOfThreads, i); ThreadedPost.push(TemporaryPost); @@ -264,23 +263,25 @@ async function BlueskyThreadFunction(Id, post) { } async function BlueskyReplyFunction(Id, post) { - let ShitHTML = "

" + post.post.author.handle + "

" + website + "


"; + let OtherPost = await BlueskyAPI.GetPosts([post.uri]); + OtherPost = OtherPost.posts[0]; + let ShitHTML = "

" + OtherPost.author.handle + "

" + website + "


"; document.getElementsByTagName("body")[0].insertAdjacentHTML("beforeend", ShitHTML); - Text = BlueskyAPI.ApplyFacets(post.post.record, post.post.record.text); + Text = BlueskyAPI.ApplyFacets(OtherPost.record, OtherPost.record.text); Text = Text.replace(/\r?\n|\r/g, "
"); // Sensitive topic :3 - if (post.post.record.hasOwnProperty("labels") && post.post.record.labels.length != 0) { + if (OtherPost.record.hasOwnProperty("labels") && OtherPost.record.labels.length != 0) { document.getElementsByClassName("PostText " + Id)[0].innerHTML = "LABELS APPLIED: "; - for (let lab of post.post.value.labels.values) { + for (let lab of OtherPost.value.labels.values) { document.getElementsByClassName("PostText " + Id)[0].innerHTML += lab.val + " "; } } else { document.getElementsByClassName("PostText " + Id)[0].innerHTML = Text; - if (post.post.record.hasOwnProperty("embed")) { - ApplyMedia(post.post.record.embed, document.getElementsByClassName("Images " + Id)[0], post.post.author.did); + if (OtherPost.record.hasOwnProperty("embed")) { + ApplyMedia(OtherPost.record.embed, document.getElementsByClassName("Images " + Id)[0], OtherPost.author.did); } } - return post; + return OtherPost; } // Applyers. Essentially applies a thing to an operation. diff --git a/src/HTTP/JS/mail.js b/src/HTTP/JS/mail.js index 8fd6611..a1c18e0 100644 --- a/src/HTTP/JS/mail.js +++ b/src/HTTP/JS/mail.js @@ -4,29 +4,7 @@ import * as TumblrAPI from "/JS/TumblrAPI.js"; import * as Variables from "/JS/Variables.js"; // Below is the thing it populates if you login. -async function PopulateFavorites() { - let Favorites = await MastodonAPI.GetFavorites(); - - let FavoritesArea = document.getElementsByClassName("Favorites")[0]; - // Populate the favorites area. - for (let i in Favorites) { - FavoritesArea.innerHTML += "
"; - FavoritesArea.getElementsByClassName("Favorite")[i].innerHTML = Favorites[i].content; - } -} - -async function PopulateBookmarks() { - let Bookmarks = await MastodonAPI.GetBookmarks(); - - let BookmarksArea = document.getElementsByClassName("Bookmarks")[0]; - // Populate the Bookmarks area. - for (let i in Bookmarks) { - BookmarksArea.innerHTML += "
"; - BookmarksArea.getElementsByClassName("Bookmark")[i].innerHTML = Bookmarks[i].content; - } -} - -async function PopulateNotifications() { +async function PopulateMastodonNotifications() { let Notifications = await MastodonAPI.GetNotifications(); let NotificationsArea = document.getElementsByClassName("Notifications")[0]; @@ -38,9 +16,7 @@ async function PopulateNotifications() { } // Populate the areas. -PopulateFavorites(); -PopulateBookmarks(); -PopulateNotifications(); +PopulateMastodonNotifications(); // Functions stolen elsewhere // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random -- 2.45.3 From b8362a0f01d83814356b0cd2ca3becff7e61ab34 Mon Sep 17 00:00:00 2001 From: CatAClock Date: Thu, 17 Jul 2025 09:12:37 -0700 Subject: [PATCH 04/19] two fixes --- src/HTTP/JS/MastodonAPI.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/HTTP/JS/MastodonAPI.js b/src/HTTP/JS/MastodonAPI.js index a08b725..1daa4be 100644 --- a/src/HTTP/JS/MastodonAPI.js +++ b/src/HTTP/JS/MastodonAPI.js @@ -97,7 +97,7 @@ export async function GetAccountFollows(ID) { if (Token == null || TokenType == null) { return ""; } - return await fetch(localStorage.getItem(Variables.MastodonWebsite) + "/api/v1/accounts/" + ID + "/Following", {method: "GET", headers: {"Authorization": TokenType + " " + Token}}) + return await fetch(localStorage.getItem(Variables.MastodonWebsite) + "/api/v1/accounts/" + ID + "/following", {method: "GET", headers: {"Authorization": TokenType + " " + Token}}) .then((response) => response.json()); } -- 2.45.3 From 18a7d70d51170e5c45283eb281d82b39081e805e Mon Sep 17 00:00:00 2001 From: CatAClock Date: Thu, 17 Jul 2025 09:12:53 -0700 Subject: [PATCH 05/19] AA --- src/HTTP/JS/account.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/HTTP/JS/account.js b/src/HTTP/JS/account.js index 0910068..4446a46 100644 --- a/src/HTTP/JS/account.js +++ b/src/HTTP/JS/account.js @@ -154,7 +154,7 @@ async function GetAccount() { // Mastodon stuff. let MastoProfile = await MastodonAPI.GetOwnAccount(); // Get my followings on Mastodon. - let MyMastodonFollows = await MastodonAPI.GetAccountFollows(Mastodon.id); + let MyMastodonFollows = await MastodonAPI.GetAccountFollows(MastoProfile.id); for (let i of MyMastodonFollows) { document.getElementsByClassName("Posts")[0].innerHTML += MyMastodonFollows.acct + "

"; } -- 2.45.3 From caa1cc7ef440e47092c187bb3fc4eec2fbddc5de Mon Sep 17 00:00:00 2001 From: CatAClock Date: Thu, 17 Jul 2025 11:25:09 -0700 Subject: [PATCH 06/19] oops --- src/HTTP/JS/account.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/HTTP/JS/account.js b/src/HTTP/JS/account.js index 4446a46..1e92f9c 100644 --- a/src/HTTP/JS/account.js +++ b/src/HTTP/JS/account.js @@ -155,8 +155,9 @@ async function GetAccount() { let MastoProfile = await MastodonAPI.GetOwnAccount(); // Get my followings on Mastodon. let MyMastodonFollows = await MastodonAPI.GetAccountFollows(MastoProfile.id); + document.getElementsByClassName("Posts")[0].innerHTML += "FOLLOWS:

"; for (let i of MyMastodonFollows) { - document.getElementsByClassName("Posts")[0].innerHTML += MyMastodonFollows.acct + "

"; + document.getElementsByClassName("Posts")[0].innerHTML += i.acct + "

"; } // Bluesky stuff. let BlueProfile = await BlueskyAPI.GetProfile(localStorage.getItem(Variables.BlueskyDID)); @@ -167,6 +168,7 @@ async function GetAccount() { AlternateAccountImage.setAttribute("src", BlueProfile.avatar); // Get my followings on Bsky let MyBlueskyFollows = await BlueskyAPI.GetFollows(localStorage.getItem(Variables.BlueskyDID)); + AccountPosts.innerHTML += "FOLLOWS:

"; for (let i of MyBlueskyFollows.follows) { AccountPosts.innerHTML += i.handle + "

"; } -- 2.45.3 From 8333be6750541f249c107ed2c58247ad33a90660 Mon Sep 17 00:00:00 2001 From: CatAClock Date: Thu, 17 Jul 2025 11:49:48 -0700 Subject: [PATCH 07/19] replies stopped working :/ --- src/HTTP/JS/expanded.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/HTTP/JS/expanded.js b/src/HTTP/JS/expanded.js index 494add5..52f4ab9 100644 --- a/src/HTTP/JS/expanded.js +++ b/src/HTTP/JS/expanded.js @@ -185,7 +185,7 @@ async function GetPost() { // Replies, anyone? let Context = await BlueskyAPI.GetPostThread(post.post.uri); for (let i of Context.thread.replies) { - TemporaryPost = await BlueskyReplyFunction(NumberOfThreads, i); + TemporaryPost = await BlueskyReplyFunction(NumberOfThreads, i.post); ThreadedPost.push(TemporaryPost); // Any posts? Give them the thing :3 for (let j of document.getElementsByClassName(NumberOfThreads)) { -- 2.45.3 From 764c626ae8ced7126e99af84eb719bca8059b8ec Mon Sep 17 00:00:00 2001 From: CatAClock Date: Thu, 17 Jul 2025 11:53:31 -0700 Subject: [PATCH 08/19] fucking piece of shit! --- src/HTTP/JS/expanded.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/HTTP/JS/expanded.js b/src/HTTP/JS/expanded.js index 52f4ab9..b363232 100644 --- a/src/HTTP/JS/expanded.js +++ b/src/HTTP/JS/expanded.js @@ -281,6 +281,10 @@ async function BlueskyReplyFunction(Id, post) { ApplyMedia(OtherPost.record.embed, document.getElementsByClassName("Images " + Id)[0], OtherPost.author.did); } } + // Get the reply and make it make sense. + if (OtherPost.record.hasOwnProperty("reply")) { + OtherPost.reply = OtherPost.record.reply; + } return OtherPost; } -- 2.45.3 From 7602985f7a05673b4bec37c62a60cc8ad12e72e4 Mon Sep 17 00:00:00 2001 From: CatAClock Date: Thu, 17 Jul 2025 19:57:15 -0700 Subject: [PATCH 09/19] Optimize & fix --- src/HTTP/JS/expanded.js | 80 ++++++++++++----------------------------- 1 file changed, 23 insertions(+), 57 deletions(-) diff --git a/src/HTTP/JS/expanded.js b/src/HTTP/JS/expanded.js index b363232..69a98fc 100644 --- a/src/HTTP/JS/expanded.js +++ b/src/HTTP/JS/expanded.js @@ -19,6 +19,14 @@ let post = JSON.parse(localStorage.getItem("post")); let ThreadedPost = []; document.getElementsByClassName("Origin")[0].innerHTML = website; + +// Other post stuff. +for (let i of document.getElementsByClassName("Handle")) { + i.onclick = (event) => { + window.location.href = "/account?website=" + website; + } +} + GetPost(); // Fixes a bug where the interpreter sucks ass. @@ -63,15 +71,6 @@ Reply.onclick = (event) => { window.location.href = "/post?website=" + website; } -// Other post stuff. -for (let i of document.getElementsByClassName("Regular")) { - i.onclick = (event) => { - if (i.classList.contains("Handle")) { - window.location.href = "/account?website=" + website; - } - } -} - // Threads are the thing above the post you clicked. async function SetThreadPost(element, i) { if (website == "Mastodon") { @@ -114,7 +113,7 @@ async function GetPost() { let NumberOfThreads = 0; let TemporaryPost = post; while (TemporaryPost.in_reply_to_id != null) { - TemporaryPost = await MastodonThreadFunction(NumberOfThreads, TemporaryPost.in_reply_to_id); + TemporaryPost = await MastodonOtherFunction(NumberOfThreads, TemporaryPost.in_reply_to_id, true); ThreadedPost.push(TemporaryPost); // Any posts? Give them the thing :3 for (let i of document.getElementsByClassName(NumberOfThreads)) { @@ -128,7 +127,7 @@ async function GetPost() { // Replies, anyone? let Context = await MastodonAPI.GetContexts(post.id); for (let i of Context.descendants) { - TemporaryPost = await MastodonReplyFunction(NumberOfThreads, i); + TemporaryPost = await MastodonOtherFunction(NumberOfThreads, i, false); ThreadedPost.push(TemporaryPost); // Any posts? Give them the thing :3 for (let j of document.getElementsByClassName(NumberOfThreads)) { @@ -171,7 +170,7 @@ async function GetPost() { let NumberOfThreads = 0; let TemporaryPost = post; while (TemporaryPost.hasOwnProperty("reply")) { - TemporaryPost = await BlueskyThreadFunction(NumberOfThreads, TemporaryPost.reply.parent); + TemporaryPost = await BlueskyOtherFunction(NumberOfThreads, TemporaryPost.reply.parent, true); ThreadedPost.push(TemporaryPost); // Any posts? Give them the thing :3 for (let i of document.getElementsByClassName(NumberOfThreads)) { @@ -185,7 +184,7 @@ async function GetPost() { // Replies, anyone? let Context = await BlueskyAPI.GetPostThread(post.post.uri); for (let i of Context.thread.replies) { - TemporaryPost = await BlueskyReplyFunction(NumberOfThreads, i.post); + TemporaryPost = await BlueskyOtherFunction(NumberOfThreads, i.post, false); ThreadedPost.push(TemporaryPost); // Any posts? Give them the thing :3 for (let j of document.getElementsByClassName(NumberOfThreads)) { @@ -202,8 +201,13 @@ async function GetPost() { } // Because of repeat code, we can put it into it's own function. It grabs posts "above" it. -async function MastodonThreadFunction(Id, post) { - let OtherPost = await MastodonAPI.GetStatus(post); +async function MastodonOtherFunction(Id, post, IsThread) { + let OtherPost; + if (IsThread == true) { + OtherPost = await MastodonAPI.GetStatus(post); + } else { + OtherPost = post; + } let ShitHTML = "

" + OtherPost.account.acct + "

" + website + "


"; document.getElementsByTagName("body")[0].insertAdjacentHTML("afterbegin", ShitHTML); if (OtherPost.spoiler_text != "") { @@ -219,54 +223,16 @@ async function MastodonThreadFunction(Id, post) { return OtherPost; } -async function MastodonReplyFunction(Id, post) { - let ShitHTML = "

" + post.account.acct + "

" + website + "


"; - document.getElementsByTagName("body")[0].insertAdjacentHTML("beforeend", ShitHTML); - if (post.spoiler_text != "") { - document.getElementsByClassName("PostText " + Id)[0].innerHTML = "WARNING: " + post.spoiler_text; - } else { - document.getElementsByClassName("PostText " + Id)[0].innerHTML = post.content; - if (post.media_attachments.length != 0) { - for (let i of post.media_attachments) { - ApplyMedia(i, document.getElementsByClassName("Images " + Id)); - } - } - } - return post; -} - // Because of repeat code, we can put it into it's own function. It grabs posts "above" it. -async function BlueskyThreadFunction(Id, post) { +async function BlueskyOtherFunction(Id, post, IsThread) { let OtherPost = await BlueskyAPI.GetPosts([post.uri]); OtherPost = OtherPost.posts[0]; let ShitHTML = "

" + OtherPost.author.handle + "

" + website + "


"; - document.getElementsByTagName("body")[0].insertAdjacentHTML("afterbegin", ShitHTML); - Text = BlueskyAPI.ApplyFacets(OtherPost.record, OtherPost.record.text); - Text = Text.replace(/\r?\n|\r/g, "
"); - // Sensitive topic :3 - if (OtherPost.record.hasOwnProperty("labels") && OtherPost.record.labels.length != 0) { - document.getElementsByClassName("PostText " + Id)[0].innerHTML = "LABELS APPLIED: "; - for (let lab of OtherPost.value.labels.values) { - document.getElementsByClassName("PostText " + Id)[0].innerHTML += lab.val + " "; - } + if (IsThread == true) { + document.getElementsByTagName("body")[0].insertAdjacentHTML("afterbegin", ShitHTML); } else { - document.getElementsByClassName("PostText " + Id)[0].innerHTML = Text; - if (OtherPost.record.hasOwnProperty("embed")) { - ApplyMedia(OtherPost.record.embed, document.getElementsByClassName("Images " + Id)[0], OtherPost.author.did); - } + document.getElementsByTagName("body")[0].insertAdjacentHTML("beforeend", ShitHTML); } - // Get the reply and make it make sense. - if (OtherPost.record.hasOwnProperty("reply")) { - OtherPost.reply = OtherPost.record.reply; - } - return OtherPost; -} - -async function BlueskyReplyFunction(Id, post) { - let OtherPost = await BlueskyAPI.GetPosts([post.uri]); - OtherPost = OtherPost.posts[0]; - let ShitHTML = "

" + OtherPost.author.handle + "

" + website + "


"; - document.getElementsByTagName("body")[0].insertAdjacentHTML("beforeend", ShitHTML); Text = BlueskyAPI.ApplyFacets(OtherPost.record, OtherPost.record.text); Text = Text.replace(/\r?\n|\r/g, "
"); // Sensitive topic :3 -- 2.45.3 From f67ecccc7dfac2abe60c920f0806293d694a50f7 Mon Sep 17 00:00:00 2001 From: CatAClock Date: Thu, 17 Jul 2025 20:00:38 -0700 Subject: [PATCH 10/19] small bug fix --- src/HTTP/JS/expanded.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/HTTP/JS/expanded.js b/src/HTTP/JS/expanded.js index 69a98fc..e22eb6b 100644 --- a/src/HTTP/JS/expanded.js +++ b/src/HTTP/JS/expanded.js @@ -209,7 +209,11 @@ async function MastodonOtherFunction(Id, post, IsThread) { OtherPost = post; } let ShitHTML = "

" + OtherPost.account.acct + "

" + website + "


"; - document.getElementsByTagName("body")[0].insertAdjacentHTML("afterbegin", ShitHTML); + if (IsThread == true) { + document.getElementsByTagName("body")[0].insertAdjacentHTML("afterbegin", ShitHTML); + } else { + document.getElementsByTagName("body")[0].insertAdjacentHTML("beforeend", ShitHTML); + } if (OtherPost.spoiler_text != "") { document.getElementsByClassName("PostText " + Id)[0].innerHTML = "WARNING: " + OtherPost.spoiler_text; } else { -- 2.45.3 From 3b6145c62164f34d9c41cd2fd03369e47d3f69a4 Mon Sep 17 00:00:00 2001 From: CatAClock Date: Fri, 18 Jul 2025 09:42:50 -0700 Subject: [PATCH 11/19] facets initialized --- src/HTTP/JS/BlueskyAPI.js | 19 ++++++++++++++++++- src/HTTP/JS/post.js | 8 ++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/HTTP/JS/BlueskyAPI.js b/src/HTTP/JS/BlueskyAPI.js index 003ab27..ae8d8c8 100644 --- a/src/HTTP/JS/BlueskyAPI.js +++ b/src/HTTP/JS/BlueskyAPI.js @@ -167,7 +167,7 @@ export async function GetRecord(Repo, Collection, RKey) { // Creators // This creates a post. Requires the DID of the account and the Text for the record. -export async function CreatePost(DID, Text, ContentWarning = undefined, Tags = [], ReplyID = undefined, RootID = undefined) { +export async function CreatePost(DID, Text, ContentWarning = undefined, Tags = [], ReplyID = undefined, RootID = undefined, AddTags = false) { if (Token == null) { return ""; } @@ -202,6 +202,23 @@ export async function CreatePost(DID, Text, ContentWarning = undefined, Tags = [ if (Tags.length != 0) { Record.tags = Tags; } + if (AddTags == true) { + let Facets = []; + for (let i of Tags) { + let ThineIndex = tags.indexOf(i); + Facets.push({ + "index": { + "byteStart": ThineIndex, + "byteEnd": ThineIndex + i.length + }, + "features": { + "$type": "app.bsky.richtext.facet#tag", + "tag": i; + } + }); + } + Record.facets = Facets; + } let body = await CreateRecord(DID, "app.bsky.feed.post", Record, undefined); if (body.hasOwnProperty("error") && body.error == "InvalidRequest") { let matches = body.message.match(/(\d+)/); diff --git a/src/HTTP/JS/post.js b/src/HTTP/JS/post.js index c760c5f..f042b70 100644 --- a/src/HTTP/JS/post.js +++ b/src/HTTP/JS/post.js @@ -140,6 +140,14 @@ async function Post() { } await BlueskyAPI.CreateThreadGate(localStorage.getItem(Variables.BlueskyDID), Post.uri, TempVisible); } + // Try to apply tags as well in another post because Bsky sucks balls. + if (Tags != "") { + let Textures = ""; + for (let i of Tags) { + Textures = Textures + i + " "; + } + Post = await BlueskyAPI.CreatePost(localStorage.getItem(Variables.BlueskyDID), Textures, undefined, [], Post.post, Post.reply.root, true); + } } // Youtube posting. if (YoutubePoser.checked == true) { -- 2.45.3 From cb8ab08edb0b43cbb859eb52e5d619c1f1535643 Mon Sep 17 00:00:00 2001 From: CatAClock Date: Fri, 18 Jul 2025 09:55:20 -0700 Subject: [PATCH 12/19] quick changes to get it to maybe work? --- src/HTTP/JS/BlueskyAPI.js | 2 +- src/HTTP/JS/post.js | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/HTTP/JS/BlueskyAPI.js b/src/HTTP/JS/BlueskyAPI.js index ae8d8c8..ef98f6c 100644 --- a/src/HTTP/JS/BlueskyAPI.js +++ b/src/HTTP/JS/BlueskyAPI.js @@ -213,7 +213,7 @@ export async function CreatePost(DID, Text, ContentWarning = undefined, Tags = [ }, "features": { "$type": "app.bsky.richtext.facet#tag", - "tag": i; + "tag": i } }); } diff --git a/src/HTTP/JS/post.js b/src/HTTP/JS/post.js index f042b70..a8fefbf 100644 --- a/src/HTTP/JS/post.js +++ b/src/HTTP/JS/post.js @@ -82,6 +82,7 @@ async function Post() { } // Bluesky posting. if (localStorage.getItem(Variables.BlueskyAccessToken) != null) { + let Post; let TempVisible; // Adding tags let Tags = TagsInputArea.value.split(";"); @@ -111,7 +112,6 @@ async function Post() { break; } if (website == "Bluesky") { - let Post; if (JSON.parse(localStorage.getItem("post")).hasOwnProperty("reply")) { if (WarningInputArea.value == "") { Post = await BlueskyAPI.CreatePost(localStorage.getItem(Variables.BlueskyDID), Text, undefined, Tags, JSON.parse(localStorage.getItem("post")).post, JSON.parse(localStorage.getItem("post")).reply.root); @@ -132,7 +132,6 @@ async function Post() { TagsInputArea.value = ""; return; } else if (website == "All") { - let Post; if (WarningInputArea.value == "") { Post = await BlueskyAPI.CreatePost(localStorage.getItem(Variables.BlueskyDID), Text, undefined, Tags); } else { -- 2.45.3 From 86038ebbc6ce43ed6dbe311d53924dd21b06c361 Mon Sep 17 00:00:00 2001 From: CatAClock Date: Fri, 18 Jul 2025 10:00:55 -0700 Subject: [PATCH 13/19] oh. forgot about that. --- src/HTTP/JS/post.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/HTTP/JS/post.js b/src/HTTP/JS/post.js index a8fefbf..1497191 100644 --- a/src/HTTP/JS/post.js +++ b/src/HTTP/JS/post.js @@ -145,6 +145,8 @@ async function Post() { for (let i of Tags) { Textures = Textures + i + " "; } + Post = await BlueskyAPI.GetPosts([Post.uri]); + Post = Post.posts[0]; Post = await BlueskyAPI.CreatePost(localStorage.getItem(Variables.BlueskyDID), Textures, undefined, [], Post.post, Post.reply.root, true); } } -- 2.45.3 From e76788fd48457b2f8c0e9169992b97e50a0fe999 Mon Sep 17 00:00:00 2001 From: CatAClock Date: Fri, 18 Jul 2025 10:16:15 -0700 Subject: [PATCH 14/19] ? --- src/HTTP/JS/post.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/HTTP/JS/post.js b/src/HTTP/JS/post.js index 1497191..517c167 100644 --- a/src/HTTP/JS/post.js +++ b/src/HTTP/JS/post.js @@ -147,7 +147,7 @@ async function Post() { } Post = await BlueskyAPI.GetPosts([Post.uri]); Post = Post.posts[0]; - Post = await BlueskyAPI.CreatePost(localStorage.getItem(Variables.BlueskyDID), Textures, undefined, [], Post.post, Post.reply.root, true); + await BlueskyAPI.CreatePost(localStorage.getItem(Variables.BlueskyDID), Textures, undefined, [], Post, Post.reply.root, true); } } // Youtube posting. -- 2.45.3 From 5e3da9843e2ae2e3963eb37d6a455983f601b177 Mon Sep 17 00:00:00 2001 From: CatAClock Date: Fri, 18 Jul 2025 10:23:33 -0700 Subject: [PATCH 15/19] oh I see the issue --- src/HTTP/JS/post.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/HTTP/JS/post.js b/src/HTTP/JS/post.js index 517c167..f54e084 100644 --- a/src/HTTP/JS/post.js +++ b/src/HTTP/JS/post.js @@ -147,7 +147,11 @@ async function Post() { } Post = await BlueskyAPI.GetPosts([Post.uri]); Post = Post.posts[0]; - await BlueskyAPI.CreatePost(localStorage.getItem(Variables.BlueskyDID), Textures, undefined, [], Post, Post.reply.root, true); + if (Post.hasOwnProperty("reply")) { + await BlueskyAPI.CreatePost(localStorage.getItem(Variables.BlueskyDID), Textures, undefined, Tags, Post, Post.reply.root, true); + } else { + await BlueskyAPI.CreatePost(localStorage.getItem(Variables.BlueskyDID), Textures, undefined, Tags, Post, Post, true); + } } } // Youtube posting. -- 2.45.3 From fb3d3b552bc174fe307f19c34d67e5e1d28ba8b8 Mon Sep 17 00:00:00 2001 From: CatAClock Date: Fri, 18 Jul 2025 10:36:12 -0700 Subject: [PATCH 16/19] post is undefined? --- src/HTTP/JS/BlueskyAPI.js | 2 +- src/HTTP/JS/post.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/HTTP/JS/BlueskyAPI.js b/src/HTTP/JS/BlueskyAPI.js index ef98f6c..403b5f9 100644 --- a/src/HTTP/JS/BlueskyAPI.js +++ b/src/HTTP/JS/BlueskyAPI.js @@ -205,7 +205,7 @@ export async function CreatePost(DID, Text, ContentWarning = undefined, Tags = [ if (AddTags == true) { let Facets = []; for (let i of Tags) { - let ThineIndex = tags.indexOf(i); + let ThineIndex = Tags.indexOf(i); Facets.push({ "index": { "byteStart": ThineIndex, diff --git a/src/HTTP/JS/post.js b/src/HTTP/JS/post.js index f54e084..74df905 100644 --- a/src/HTTP/JS/post.js +++ b/src/HTTP/JS/post.js @@ -146,7 +146,7 @@ async function Post() { Textures = Textures + i + " "; } Post = await BlueskyAPI.GetPosts([Post.uri]); - Post = Post.posts[0]; + Post = await Post.posts[0]; if (Post.hasOwnProperty("reply")) { await BlueskyAPI.CreatePost(localStorage.getItem(Variables.BlueskyDID), Textures, undefined, Tags, Post, Post.reply.root, true); } else { -- 2.45.3 From 3a646be50edcdb36b2c9c7b2d9d6e3321b64da68 Mon Sep 17 00:00:00 2001 From: CatAClock Date: Fri, 18 Jul 2025 11:10:48 -0700 Subject: [PATCH 17/19] multitag workie? --- src/HTTP/JS/BlueskyAPI.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/HTTP/JS/BlueskyAPI.js b/src/HTTP/JS/BlueskyAPI.js index 403b5f9..a90b730 100644 --- a/src/HTTP/JS/BlueskyAPI.js +++ b/src/HTTP/JS/BlueskyAPI.js @@ -204,18 +204,20 @@ export async function CreatePost(DID, Text, ContentWarning = undefined, Tags = [ } if (AddTags == true) { let Facets = []; + let LengthStuff = 0; for (let i of Tags) { - let ThineIndex = Tags.indexOf(i); + let ThineIndex = Tags.indexOf(i, LengthStuff); Facets.push({ "index": { "byteStart": ThineIndex, "byteEnd": ThineIndex + i.length }, - "features": { + "features": [{ "$type": "app.bsky.richtext.facet#tag", "tag": i - } + }] }); + LengthStuff = ThineIndex + i.length; } Record.facets = Facets; } -- 2.45.3 From 3b665e8ca84caa4952218195cd95fda137121e52 Mon Sep 17 00:00:00 2001 From: CatAClock Date: Fri, 18 Jul 2025 11:21:26 -0700 Subject: [PATCH 18/19] A different way of making this work --- src/HTTP/JS/BlueskyAPI.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/HTTP/JS/BlueskyAPI.js b/src/HTTP/JS/BlueskyAPI.js index a90b730..cef9679 100644 --- a/src/HTTP/JS/BlueskyAPI.js +++ b/src/HTTP/JS/BlueskyAPI.js @@ -206,18 +206,17 @@ export async function CreatePost(DID, Text, ContentWarning = undefined, Tags = [ let Facets = []; let LengthStuff = 0; for (let i of Tags) { - let ThineIndex = Tags.indexOf(i, LengthStuff); Facets.push({ "index": { - "byteStart": ThineIndex, - "byteEnd": ThineIndex + i.length + "byteStart": LengthStuff, + "byteEnd": LengthStuff + i.length }, "features": [{ "$type": "app.bsky.richtext.facet#tag", "tag": i }] }); - LengthStuff = ThineIndex + i.length; + LengthStuff += 1; } Record.facets = Facets; } -- 2.45.3 From c5dc2572615c0ee8356cb15e94baaf4c2c07c777 Mon Sep 17 00:00:00 2001 From: CatAClock Date: Fri, 18 Jul 2025 11:36:56 -0700 Subject: [PATCH 19/19] Facets finally worke --- src/HTTP/JS/BlueskyAPI.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/HTTP/JS/BlueskyAPI.js b/src/HTTP/JS/BlueskyAPI.js index cef9679..ba7ba59 100644 --- a/src/HTTP/JS/BlueskyAPI.js +++ b/src/HTTP/JS/BlueskyAPI.js @@ -216,7 +216,7 @@ export async function CreatePost(DID, Text, ContentWarning = undefined, Tags = [ "tag": i }] }); - LengthStuff += 1; + LengthStuff = LengthStuff + i.length + 1; } Record.facets = Facets; } -- 2.45.3