IssueCleaner #74
9 changed files with 107 additions and 111 deletions
|
@ -3,12 +3,10 @@
|
||||||
A frontend to accessing my account on the fediverse
|
A frontend to accessing my account on the fediverse
|
||||||
|
|
||||||
## technologies
|
## technologies
|
||||||
- node on a bare debian install.
|
- Rust and Rouille.
|
||||||
- npm and npx to execute it.
|
|
||||||
- Uses MastodonAPI, BlueskyAPI, and YoutubeAPI<sup>[1]</sup>.
|
- Uses MastodonAPI, BlueskyAPI, and YoutubeAPI<sup>[1]</sup>.
|
||||||
- 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/<HomeDirectory>/Documents/Fedi.CrowdedGames.Group --port 4000 --cors`
|
Quick launch server: `Cargo run --release`
|
||||||
|
|
||||||
## FAQ
|
## FAQ
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
<p class="Button Follow">Follow!</p>
|
<p class="Button Follow">Follow!</p>
|
||||||
<p class="Button Block">Block!</p>
|
<p class="Button Block">Block!</p>
|
||||||
</aside>
|
</aside>
|
||||||
|
<div class="Posts"></div>
|
||||||
</div>
|
</div>
|
||||||
<!-- Either other account info goes here, or posts go here. -->
|
<!-- Either other account info goes here, or posts go here. -->
|
||||||
<div>
|
<div>
|
||||||
|
|
|
@ -100,6 +100,24 @@ export async function GetPosts(URIs) {
|
||||||
return body;
|
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) {
|
export async function GetPostThread(URI) {
|
||||||
if (Token == null) {
|
if (Token == null) {
|
||||||
return "";
|
return "";
|
||||||
|
@ -149,7 +167,7 @@ export async function GetRecord(Repo, Collection, RKey) {
|
||||||
|
|
||||||
// Creators
|
// Creators
|
||||||
// This creates a post. Requires the DID of the account and the Text for the record.
|
// 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) {
|
if (Token == null) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -184,6 +202,24 @@ export async function CreatePost(DID, Text, ContentWarning = undefined, Tags = [
|
||||||
if (Tags.length != 0) {
|
if (Tags.length != 0) {
|
||||||
Record.tags = Tags;
|
Record.tags = Tags;
|
||||||
}
|
}
|
||||||
|
if (AddTags == true) {
|
||||||
|
let Facets = [];
|
||||||
|
let LengthStuff = 0;
|
||||||
|
for (let i of Tags) {
|
||||||
|
Facets.push({
|
||||||
|
"index": {
|
||||||
|
"byteStart": LengthStuff,
|
||||||
|
"byteEnd": LengthStuff + i.length
|
||||||
|
},
|
||||||
|
"features": [{
|
||||||
|
"$type": "app.bsky.richtext.facet#tag",
|
||||||
|
"tag": i
|
||||||
|
}]
|
||||||
|
});
|
||||||
|
LengthStuff = LengthStuff + i.length + 1;
|
||||||
|
}
|
||||||
|
Record.facets = Facets;
|
||||||
|
}
|
||||||
let body = await CreateRecord(DID, "app.bsky.feed.post", Record, undefined);
|
let body = await CreateRecord(DID, "app.bsky.feed.post", Record, undefined);
|
||||||
if (body.hasOwnProperty("error") && body.error == "InvalidRequest") {
|
if (body.hasOwnProperty("error") && body.error == "InvalidRequest") {
|
||||||
let matches = body.message.match(/(\d+)/);
|
let matches = body.message.match(/(\d+)/);
|
||||||
|
|
|
@ -57,24 +57,6 @@ export async function GetRelationship(ID) {
|
||||||
.then((response) => response.json());
|
.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.
|
// Gets the notifications of a user that you have access to.
|
||||||
export async function GetNotifications() {
|
export async function GetNotifications() {
|
||||||
if (Token == null || TokenType == null) {
|
if (Token == null || TokenType == null) {
|
||||||
|
@ -111,11 +93,11 @@ export async function GetOwnAccount() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get your own account blocks.
|
// Get your own account blocks.
|
||||||
export async function GetOwnAccountBlocks() {
|
export async function GetAccountFollows(ID) {
|
||||||
if (Token == null || TokenType == null) {
|
if (Token == null || TokenType == null) {
|
||||||
return "";
|
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());
|
.then((response) => response.json());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ let AlternateAccountDescription = document.getElementsByClassName("AccountDescri
|
||||||
let FollowButton = document.getElementsByClassName("Follow")[0];
|
let FollowButton = document.getElementsByClassName("Follow")[0];
|
||||||
let BlockButton = document.getElementsByClassName("Block")[0];
|
let BlockButton = document.getElementsByClassName("Block")[0];
|
||||||
|
|
||||||
let AccountPosts = document.getElementsByClassName("Posts")[0];
|
let AccountPosts = document.getElementsByClassName("Posts")[1];
|
||||||
|
|
||||||
// Other vars.
|
// Other vars.
|
||||||
let Following = false;
|
let Following = false;
|
||||||
|
@ -126,10 +126,10 @@ async function GetAccount() {
|
||||||
AccountImage.setAttribute("src", account.avatar);
|
AccountImage.setAttribute("src", account.avatar);
|
||||||
// Get their recent posts. Determine if they are cewl or not.
|
// Get their recent posts. Determine if they are cewl or not.
|
||||||
let Posts = await BlueskyAPI.GetProfileFeed(account.did);
|
let Posts = await BlueskyAPI.GetProfileFeed(account.did);
|
||||||
console.log(Posts);
|
|
||||||
for (let i of Posts.feed) {
|
for (let i of Posts.feed) {
|
||||||
AccountPosts.innerHTML += i.post.record.text + "<br/><br/>";
|
AccountPosts.innerHTML += i.post.record.text + "<br/><br/>";
|
||||||
}
|
}
|
||||||
|
// No other accounts. Just you.
|
||||||
} else {
|
} else {
|
||||||
FollowButton.setAttribute("hidden", "");
|
FollowButton.setAttribute("hidden", "");
|
||||||
BlockButton.setAttribute("hidden", "");
|
BlockButton.setAttribute("hidden", "");
|
||||||
|
@ -151,12 +151,27 @@ async function GetAccount() {
|
||||||
}
|
}
|
||||||
Token = localStorage.getItem(Variables.BlueskyAccessToken);
|
Token = localStorage.getItem(Variables.BlueskyAccessToken);
|
||||||
if (Token != null) {
|
if (Token != null) {
|
||||||
|
// Mastodon stuff.
|
||||||
|
let MastoProfile = await MastodonAPI.GetOwnAccount();
|
||||||
|
// Get my followings on Mastodon.
|
||||||
|
let MyMastodonFollows = await MastodonAPI.GetAccountFollows(MastoProfile.id);
|
||||||
|
document.getElementsByClassName("Posts")[0].innerHTML += "FOLLOWS: <br/><br/>";
|
||||||
|
for (let i of MyMastodonFollows) {
|
||||||
|
document.getElementsByClassName("Posts")[0].innerHTML += i.acct + "<br/><br/>";
|
||||||
|
}
|
||||||
|
// Bluesky stuff.
|
||||||
let BlueProfile = await BlueskyAPI.GetProfile(localStorage.getItem(Variables.BlueskyDID));
|
let BlueProfile = await BlueskyAPI.GetProfile(localStorage.getItem(Variables.BlueskyDID));
|
||||||
AlternateAccountImage.setAttribute("width", "20%");
|
AlternateAccountImage.setAttribute("width", "20%");
|
||||||
AlternateAccountImage.setAttribute("height", "20%");
|
AlternateAccountImage.setAttribute("height", "20%");
|
||||||
AlternateAccountName.innerHTML = BlueProfile.handle;
|
AlternateAccountName.innerHTML = BlueProfile.handle;
|
||||||
AlternateAccountDescription.innerHTML = BlueProfile.description;
|
AlternateAccountDescription.innerHTML = BlueProfile.description;
|
||||||
AlternateAccountImage.setAttribute("src", BlueProfile.avatar);
|
AlternateAccountImage.setAttribute("src", BlueProfile.avatar);
|
||||||
|
// Get my followings on Bsky
|
||||||
|
let MyBlueskyFollows = await BlueskyAPI.GetFollows(localStorage.getItem(Variables.BlueskyDID));
|
||||||
|
AccountPosts.innerHTML += "FOLLOWS: <br/><br/>";
|
||||||
|
for (let i of MyBlueskyFollows.follows) {
|
||||||
|
AccountPosts.innerHTML += i.handle + "<br/><br/>";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,14 @@ let post = JSON.parse(localStorage.getItem("post"));
|
||||||
let ThreadedPost = [];
|
let ThreadedPost = [];
|
||||||
|
|
||||||
document.getElementsByClassName("Origin")[0].innerHTML = website;
|
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();
|
GetPost();
|
||||||
|
|
||||||
// Fixes a bug where the interpreter sucks ass.
|
// Fixes a bug where the interpreter sucks ass.
|
||||||
|
@ -63,15 +71,6 @@ Reply.onclick = (event) => {
|
||||||
window.location.href = "/post?website=" + website;
|
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.
|
// Threads are the thing above the post you clicked.
|
||||||
async function SetThreadPost(element, i) {
|
async function SetThreadPost(element, i) {
|
||||||
if (website == "Mastodon") {
|
if (website == "Mastodon") {
|
||||||
|
@ -114,7 +113,7 @@ async function GetPost() {
|
||||||
let NumberOfThreads = 0;
|
let NumberOfThreads = 0;
|
||||||
let TemporaryPost = post;
|
let TemporaryPost = post;
|
||||||
while (TemporaryPost.in_reply_to_id != null) {
|
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);
|
ThreadedPost.push(TemporaryPost);
|
||||||
// Any posts? Give them the thing :3
|
// Any posts? Give them the thing :3
|
||||||
for (let i of document.getElementsByClassName(NumberOfThreads)) {
|
for (let i of document.getElementsByClassName(NumberOfThreads)) {
|
||||||
|
@ -128,7 +127,7 @@ async function GetPost() {
|
||||||
// Replies, anyone?
|
// Replies, anyone?
|
||||||
let Context = await MastodonAPI.GetContexts(post.id);
|
let Context = await MastodonAPI.GetContexts(post.id);
|
||||||
for (let i of Context.descendants) {
|
for (let i of Context.descendants) {
|
||||||
TemporaryPost = await MastodonReplyFunction(NumberOfThreads, i);
|
TemporaryPost = await MastodonOtherFunction(NumberOfThreads, i, false);
|
||||||
ThreadedPost.push(TemporaryPost);
|
ThreadedPost.push(TemporaryPost);
|
||||||
// Any posts? Give them the thing :3
|
// Any posts? Give them the thing :3
|
||||||
for (let j of document.getElementsByClassName(NumberOfThreads)) {
|
for (let j of document.getElementsByClassName(NumberOfThreads)) {
|
||||||
|
@ -171,7 +170,7 @@ async function GetPost() {
|
||||||
let NumberOfThreads = 0;
|
let NumberOfThreads = 0;
|
||||||
let TemporaryPost = post;
|
let TemporaryPost = post;
|
||||||
while (TemporaryPost.hasOwnProperty("reply")) {
|
while (TemporaryPost.hasOwnProperty("reply")) {
|
||||||
TemporaryPost = await BlueskyThreadFunction(NumberOfThreads, TemporaryPost.reply.parent);
|
TemporaryPost = await BlueskyOtherFunction(NumberOfThreads, TemporaryPost.reply.parent, true);
|
||||||
ThreadedPost.push(TemporaryPost);
|
ThreadedPost.push(TemporaryPost);
|
||||||
// Any posts? Give them the thing :3
|
// Any posts? Give them the thing :3
|
||||||
for (let i of document.getElementsByClassName(NumberOfThreads)) {
|
for (let i of document.getElementsByClassName(NumberOfThreads)) {
|
||||||
|
@ -184,9 +183,8 @@ async function GetPost() {
|
||||||
}
|
}
|
||||||
// Replies, anyone?
|
// Replies, anyone?
|
||||||
let Context = await BlueskyAPI.GetPostThread(post.post.uri);
|
let Context = await BlueskyAPI.GetPostThread(post.post.uri);
|
||||||
console.log(Context);
|
|
||||||
for (let i of Context.thread.replies) {
|
for (let i of Context.thread.replies) {
|
||||||
TemporaryPost = await BlueskyReplyFunction(NumberOfThreads, i);
|
TemporaryPost = await BlueskyOtherFunction(NumberOfThreads, i.post, false);
|
||||||
ThreadedPost.push(TemporaryPost);
|
ThreadedPost.push(TemporaryPost);
|
||||||
// Any posts? Give them the thing :3
|
// Any posts? Give them the thing :3
|
||||||
for (let j of document.getElementsByClassName(NumberOfThreads)) {
|
for (let j of document.getElementsByClassName(NumberOfThreads)) {
|
||||||
|
@ -203,10 +201,19 @@ async function GetPost() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Because of repeat code, we can put it into it's own function. It grabs posts "above" it.
|
// Because of repeat code, we can put it into it's own function. It grabs posts "above" it.
|
||||||
async function MastodonThreadFunction(Id, post) {
|
async function MastodonOtherFunction(Id, post, IsThread) {
|
||||||
let OtherPost = await MastodonAPI.GetStatus(post);
|
let OtherPost;
|
||||||
|
if (IsThread == true) {
|
||||||
|
OtherPost = await MastodonAPI.GetStatus(post);
|
||||||
|
} else {
|
||||||
|
OtherPost = post;
|
||||||
|
}
|
||||||
let ShitHTML = "<header> <h1 class=\"Handle " + Id + "\"> " + OtherPost.account.acct + "</h1> <h2 class=\"Origin " + Id + "\"> " + website + "</h2> </header> <p class=\"PostText " + Id + "\"></p> <div class=\"Images " + Id + "\"></div> <hr/>";
|
let ShitHTML = "<header> <h1 class=\"Handle " + Id + "\"> " + OtherPost.account.acct + "</h1> <h2 class=\"Origin " + Id + "\"> " + website + "</h2> </header> <p class=\"PostText " + Id + "\"></p> <div class=\"Images " + Id + "\"></div> <hr/>";
|
||||||
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 != "") {
|
if (OtherPost.spoiler_text != "") {
|
||||||
document.getElementsByClassName("PostText " + Id)[0].innerHTML = "WARNING: " + OtherPost.spoiler_text;
|
document.getElementsByClassName("PostText " + Id)[0].innerHTML = "WARNING: " + OtherPost.spoiler_text;
|
||||||
} else {
|
} else {
|
||||||
|
@ -220,28 +227,16 @@ async function MastodonThreadFunction(Id, post) {
|
||||||
return OtherPost;
|
return OtherPost;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function MastodonReplyFunction(Id, post) {
|
|
||||||
let ShitHTML = "<header> <h1 class=\"Handle " + Id + "\"> " + post.account.acct + "</h1> <h2 class=\"Origin " + Id + "\"> " + website + "</h2> </header> <p class=\"PostText " + Id + "\"></p> <div class=\"Images " + Id + "\"></div> <hr/>";
|
|
||||||
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.
|
// 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]);
|
let OtherPost = await BlueskyAPI.GetPosts([post.uri]);
|
||||||
OtherPost = OtherPost.posts[0];
|
OtherPost = OtherPost.posts[0];
|
||||||
let ShitHTML = "<header> <h1 class=\"Handle " + Id + "\"> " + OtherPost.author.handle + "</h1> <h2 class=\"Origin " + Id + "\"> " + website + "</h2> </header> <p class=\"PostText " + Id + "\"></p> <div class=\"Images " + Id + "\"></div> <hr/>";
|
let ShitHTML = "<header> <h1 class=\"Handle " + Id + "\"> " + OtherPost.author.handle + "</h1> <h2 class=\"Origin " + Id + "\"> " + website + "</h2> </header> <p class=\"PostText " + Id + "\"></p> <div class=\"Images " + Id + "\"></div> <hr/>";
|
||||||
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);
|
||||||
|
}
|
||||||
Text = BlueskyAPI.ApplyFacets(OtherPost.record, OtherPost.record.text);
|
Text = BlueskyAPI.ApplyFacets(OtherPost.record, OtherPost.record.text);
|
||||||
Text = Text.replace(/\r?\n|\r/g, "<br/>");
|
Text = Text.replace(/\r?\n|\r/g, "<br/>");
|
||||||
// Sensitive topic :3
|
// Sensitive topic :3
|
||||||
|
@ -263,26 +258,6 @@ async function BlueskyThreadFunction(Id, post) {
|
||||||
return OtherPost;
|
return OtherPost;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function BlueskyReplyFunction(Id, post) {
|
|
||||||
let ShitHTML = "<header> <h1 class=\"Handle " + Id + "\"> " + post.post.author.handle + "</h1> <h2 class=\"Origin " + Id + "\"> " + website + "</h2> </header> <p class=\"PostText " + Id + "\"></p> <div class=\"Images " + Id + "\"></div> <hr/>";
|
|
||||||
document.getElementsByTagName("body")[0].insertAdjacentHTML("beforeend", ShitHTML);
|
|
||||||
Text = BlueskyAPI.ApplyFacets(post.post.record, post.post.record.text);
|
|
||||||
Text = Text.replace(/\r?\n|\r/g, "<br/>");
|
|
||||||
// Sensitive topic :3
|
|
||||||
if (post.post.record.hasOwnProperty("labels") && post.post.record.labels.length != 0) {
|
|
||||||
document.getElementsByClassName("PostText " + Id)[0].innerHTML = "LABELS APPLIED: ";
|
|
||||||
for (let lab of post.post.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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return post;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Applyers. Essentially applies a thing to an operation.
|
// Applyers. Essentially applies a thing to an operation.
|
||||||
// Finds any associated media and applies it to the post.
|
// Finds any associated media and applies it to the post.
|
||||||
async function ApplyMedia(Media, Element, Author = undefined) {
|
async function ApplyMedia(Media, Element, Author = undefined) {
|
||||||
|
|
|
@ -231,10 +231,10 @@ async function PosterContainerUpdate(Direction) {
|
||||||
// Put the reblog into the regular post; Make changes as necessary.
|
// Put the reblog into the regular post; Make changes as necessary.
|
||||||
if (MastodonLoadedFeed[CurrentThing + counter].reblog != null && typeof MastodonLoadedFeed[CurrentThing + counter].reblog != "string") {
|
if (MastodonLoadedFeed[CurrentThing + counter].reblog != null && typeof MastodonLoadedFeed[CurrentThing + counter].reblog != "string") {
|
||||||
// Fix a reblog issue.
|
// 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;
|
let ReblogFix = MastodonLoadedFeed[CurrentThing + counter].account.acct;
|
||||||
MastodonLoadedFeed[CurrentThing + counter] = MastodonLoadedFeed[CurrentThing + counter].reblog;
|
MastodonLoadedFeed[CurrentThing + counter] = MastodonLoadedFeed[CurrentThing + counter].reblog;
|
||||||
MastodonLoadedFeed[CurrentThing + counter].reblog = ReblogFix;
|
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") {
|
} else if (MastodonLoadedFeed[CurrentThing + counter].reblog != null && typeof MastodonLoadedFeed[CurrentThing + counter].reblog == "string") {
|
||||||
// this function is if the changes are already made.
|
// this function is if the changes are already made.
|
||||||
i.getElementsByClassName("Username")[0].innerHTML = MastodonLoadedFeed[CurrentThing + counter].account.acct + " ( R: " + MastodonLoadedFeed[CurrentThing + counter].reblog + " )";
|
i.getElementsByClassName("Username")[0].innerHTML = MastodonLoadedFeed[CurrentThing + counter].account.acct + " ( R: " + MastodonLoadedFeed[CurrentThing + counter].reblog + " )";
|
||||||
|
|
|
@ -4,29 +4,7 @@ import * as TumblrAPI from "/JS/TumblrAPI.js";
|
||||||
import * as Variables from "/JS/Variables.js";
|
import * as Variables from "/JS/Variables.js";
|
||||||
|
|
||||||
// Below is the thing it populates if you login.
|
// Below is the thing it populates if you login.
|
||||||
async function PopulateFavorites() {
|
async function PopulateMastodonNotifications() {
|
||||||
let Favorites = await MastodonAPI.GetFavorites();
|
|
||||||
|
|
||||||
let FavoritesArea = document.getElementsByClassName("Favorites")[0];
|
|
||||||
// Populate the favorites area.
|
|
||||||
for (let i in Favorites) {
|
|
||||||
FavoritesArea.innerHTML += "<article style='top:" + getRandomArbitrary(0, 84) + "%; left: " + getRandomArbitrary(0, 84) + "%;' class='Favorite'></article>";
|
|
||||||
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 += "<article style='top:" + getRandomArbitrary(0, 84) + "%; left: " + getRandomArbitrary(0, 84) + "%;' class='Bookmark'></article>";
|
|
||||||
BookmarksArea.getElementsByClassName("Bookmark")[i].innerHTML = Bookmarks[i].content;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function PopulateNotifications() {
|
|
||||||
let Notifications = await MastodonAPI.GetNotifications();
|
let Notifications = await MastodonAPI.GetNotifications();
|
||||||
|
|
||||||
let NotificationsArea = document.getElementsByClassName("Notifications")[0];
|
let NotificationsArea = document.getElementsByClassName("Notifications")[0];
|
||||||
|
@ -38,9 +16,7 @@ async function PopulateNotifications() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Populate the areas.
|
// Populate the areas.
|
||||||
PopulateFavorites();
|
PopulateMastodonNotifications();
|
||||||
PopulateBookmarks();
|
|
||||||
PopulateNotifications();
|
|
||||||
|
|
||||||
// Functions stolen elsewhere
|
// Functions stolen elsewhere
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random
|
||||||
|
|
|
@ -82,6 +82,7 @@ async function Post() {
|
||||||
}
|
}
|
||||||
// Bluesky posting.
|
// Bluesky posting.
|
||||||
if (localStorage.getItem(Variables.BlueskyAccessToken) != null) {
|
if (localStorage.getItem(Variables.BlueskyAccessToken) != null) {
|
||||||
|
let Post;
|
||||||
let TempVisible;
|
let TempVisible;
|
||||||
// Adding tags
|
// Adding tags
|
||||||
let Tags = TagsInputArea.value.split(";");
|
let Tags = TagsInputArea.value.split(";");
|
||||||
|
@ -111,7 +112,6 @@ async function Post() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (website == "Bluesky") {
|
if (website == "Bluesky") {
|
||||||
let Post;
|
|
||||||
if (JSON.parse(localStorage.getItem("post")).hasOwnProperty("reply")) {
|
if (JSON.parse(localStorage.getItem("post")).hasOwnProperty("reply")) {
|
||||||
if (WarningInputArea.value == "") {
|
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);
|
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 = "";
|
TagsInputArea.value = "";
|
||||||
return;
|
return;
|
||||||
} else if (website == "All") {
|
} else if (website == "All") {
|
||||||
let Post;
|
|
||||||
if (WarningInputArea.value == "") {
|
if (WarningInputArea.value == "") {
|
||||||
Post = await BlueskyAPI.CreatePost(localStorage.getItem(Variables.BlueskyDID), Text, undefined, Tags);
|
Post = await BlueskyAPI.CreatePost(localStorage.getItem(Variables.BlueskyDID), Text, undefined, Tags);
|
||||||
} else {
|
} else {
|
||||||
|
@ -140,6 +139,20 @@ async function Post() {
|
||||||
}
|
}
|
||||||
await BlueskyAPI.CreateThreadGate(localStorage.getItem(Variables.BlueskyDID), Post.uri, TempVisible);
|
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.GetPosts([Post.uri]);
|
||||||
|
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 {
|
||||||
|
await BlueskyAPI.CreatePost(localStorage.getItem(Variables.BlueskyDID), Textures, undefined, Tags, Post, Post, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Youtube posting.
|
// Youtube posting.
|
||||||
if (YoutubePoser.checked == true) {
|
if (YoutubePoser.checked == true) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue