Adding a bunch of things

This commit is contained in:
CatAClock 2025-05-11 13:57:17 -07:00
parent 8b66616c4e
commit 73472ab227
12 changed files with 426 additions and 111 deletions

View file

@ -0,0 +1,27 @@
/* HTML items */
img {
border-style: solid;
border-radius: 1%;
width: 45%;
}
/* Classes */
.Handle {
}
.Origin {
}
.PostText {
}
.Images {
display: flex;
justify-content: center;
flex-wrap: wrap;
}

View file

@ -54,6 +54,7 @@
html {
overflow-x: hidden;
overflow-y: hidden;
}
/* Classes for the warning section*/

View file

@ -3,6 +3,7 @@
<head>
<title>The Fediverse</title>
<meta name="description" content="Change the fucking channel already!">
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1" />
<link rel="icon" href="../Icons/favicon.ico" />
<link rel="stylesheet" href="../CSS/expanded.css">
<script type="module" src="../JS/expanded.js"></script>
@ -13,10 +14,16 @@
<body style="margin: 0px; text-align: center;">
<header>
<h1 class="Handle"></h1>
<h2 class="Origin">Bsky/Mastodon (TODO)</h2>
<p class="DetailedText"></p>
<p>Image here if it is a thing (TODO)</p>
<p onclick="history.back()"><b>Back</b></p>
<h2 class="Origin"></h2>
</header>
<p class="PostText"></p>
<div class="Images">
</div>
<div>
<p class="Favorite">Favorite!</p>
<p class="Boost">Boost!</p>
<p class="Reply">Reply!</p>
</div>
<p onclick="history.back()"><b>Back</b></p>
</body>
</html>

View file

@ -3,6 +3,7 @@
<head>
<title>The Fediverse</title>
<meta name="description" content="Change the fucking channel already!">
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1" />
<link rel="icon" href="../Icons/favicon.ico" />
<link rel="stylesheet" href="../CSS/mail.css">
<script type="module" src="../JS/mail.js"></script>
@ -16,7 +17,7 @@
<section style="position: absolute; width: 100%; height: 100%" class="Notifications"></section>
<header style="position: relative; z-index: 1;">
<h1>Mail</h1>
<p onclick="window.location.href = window.location.origin"><b>Back</b></p>
<p onclick="history.back();"><b>Back</b></p>
</header>
</body>
</html>

View file

@ -3,6 +3,7 @@
<head>
<title>The Fediverse</title>
<meta name="description" content="Change the fucking channel already!">
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1" />
<link rel="icon" href="../Icons/favicon.ico" />
<link rel="stylesheet" href="../CSS/post.css">
<script type="module" src="../JS/post.js"></script>
@ -24,6 +25,6 @@
</select>
</div>
<p class="Button">POST!</p>
<p onclick="window.location.href = window.location.origin"><b>Back</b></p>
<p onclick="history.back();"><b>Back</b></p>
</body>
</html>

View file

@ -3,6 +3,7 @@
<head>
<title>The Fediverse</title>
<meta name="description" content="Change the fucking channel already!">
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1" />
<link rel="icon" href="../Icons/favicon.ico" />
<link rel="stylesheet" href="../CSS/setting.css">
<script type="module" src="../JS/setting.js"></script>

View file

@ -26,40 +26,48 @@ export async function GetTimeline(Cursor) {
return body;
}
export async function CreatePost(DID, Text) {
export async function GetPosts(URIs) {
if (localStorage.getItem(Variables.BlueskyAccessToken) == null) {
console.log("No access token!");
return "";
}
let PDS = localStorage.getItem(Variables.BlueskyPDS);
let Json = {
"$type": "app.bsky.feed.post",
"text": Text,
"createdAt": new Date(Date.now()).toISOString()
}
let RequestBody = {
"repo": DID,
"collection": "app.bsky.feed.post",
"record": Json
}
let DPoP = await ClientDPoPPDS("POST", PDS + "/xrpc/com.atproto.repo.createRecord");
let request = fetch(PDS + "/xrpc/com.atproto.repo.createRecord", { body: JSON.stringify(RequestBody), method: "POST", headers: {"Content-Type": "application/json", "Authorization": "DPoP " + localStorage.getItem(Variables.BlueskyAccessToken), "DPoP": DPoP}});
let DPoP = await ClientDPoPPDS("GET", PDS + "/xrpc/app.bsky.feed.getPosts?uris=" + URIs);
let request = fetch(PDS + "/xrpc/app.bsky.feed.getPosts?uris=" + URIs, { method: "GET", headers: {"Authorization": "DPoP " + localStorage.getItem(Variables.BlueskyAccessToken), "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 CreatePost(DID, Text);
body = await GetPosts(URIs);
}
if (status == 400) {
return body;
}
// Get a blob (like an image or video). Authentication need not apply.
export async function GetBlob(DID, CID) {
let PDS = localStorage.getItem(Variables.BlueskyPDS);
let request = fetch("https://bsky.social/xrpc/com.atproto.sync.getBlob?did=" + DID + "&cid=" + CID, {method: "GET"});
let body = await request.then((response) => response.json());
return body;
}
export async function CreatePost(DID, Text) {
if (localStorage.getItem(Variables.BlueskyAccessToken) == null) {
console.log("No access token!");
return "";
}
let Record = {
"$type": "app.bsky.feed.post",
"text": Text,
"createdAt": new Date(Date.now()).toISOString()
}
let body = await CreateRecord(DID, "app.bsky.feed.post", Record, undefined);
if (body.hasOwnProperty("error") && body.error == "InvalidRequest") {
let matches = body.message.match(/(\d+)/);
Json.text = Text.slice(0, matches[0] - 1);
RequestBody.record = Json;
DPoP = await ClientDPoPPDS("POST", PDS + "/xrpc/com.atproto.repo.createRecord");
request = fetch(PDS + "/xrpc/com.atproto.repo.createRecord", { body: JSON.stringify(RequestBody), method: "POST", headers: {"Content-Type": "application/json", "Authorization": "DPoP " + localStorage.getItem(Variables.BlueskyAccessToken), "DPoP": DPoP}});
body = await request.then((response) => response.json());
status = await request.then((response) => response.status);
Record.text = Text.slice(0, matches[0] - 1);
body = await CreateRecord(DID, "app.bsky.feed.post", Record, undefined);
await CreateReplyPost(DID, Text.slice(matches[0] - 1, Text.length - 1), body, body);
}
return body;
@ -70,45 +78,26 @@ export async function CreateReplyPost(DID, Text, ReplyID, RootID) {
console.log("No access token!");
return "";
}
let PDS = localStorage.getItem(Variables.BlueskyPDS);
let Json = {
let Record = {
"$type": "app.bsky.feed.post",
"text": Text,
"createdAt": new Date(Date.now()).toISOString(),
"reply": {
"root": {
"parent": {
"uri": ReplyID.uri,
"cid": ReplyID.cid
},
"parent": {
"root": {
"uri": RootID.uri,
"cid": RootID.cid
}
}
}
let RequestBody = {
"repo": DID,
"collection": "app.bsky.feed.post",
"record": Json
}
let DPoP = await ClientDPoPPDS("POST", PDS + "/xrpc/com.atproto.repo.createRecord");
let request = fetch(PDS + "/xrpc/com.atproto.repo.createRecord", { body: JSON.stringify(RequestBody), method: "POST", headers: {"Content-Type": "application/json", "Authorization": "DPoP " + localStorage.getItem(Variables.BlueskyAccessToken), "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 CreatePost(DID, Text);
}
if (status == 400) {
let body = await CreateRecord(DID, "app.bsky.feed.post", Record, undefined);
if (body.hasOwnProperty("error") && body.error == "InvalidRequest") {
let matches = body.message.match(/(\d+)/);
Json.text = Text.slice(0, matches[0] - 1);
RequestBody.record = Json;
let DPoP = await ClientDPoPPDS("POST", PDS + "/xrpc/com.atproto.repo.createRecord");
let request = fetch(PDS + "/xrpc/com.atproto.repo.createRecord", { body: JSON.stringify(RequestBody), method: "POST", headers: {"Content-Type": "application/json", "Authorization": "DPoP " + localStorage.getItem(Variables.BlueskyAccessToken), "DPoP": DPoP}});
let body = await request.then((response) => response.json());
let status = await request.then((response) => response.status);
Record.text = Text.slice(0, matches[0] - 1);
body = await CreateRecord(DID, "app.bsky.feed.post", Record, undefined);
await CreateReplyPost(DID, Text.slice(matches[0] - 1, Text.length - 1), body, RootID);
}
return body;
@ -119,28 +108,119 @@ export async function SetThreadGate(DID, Post, VisibilitySettings) {
console.log("No access token!");
return "";
}
let PDS = localStorage.getItem(Variables.BlueskyPDS);
let Json = {
let Record = {
"$type": "app.bsky.feed.threadgate",
"post": Post,
"allow": VisibilitySettings,
"createdAt": new Date(Date.now()).toISOString()
}
let RequestBody = {
"repo": DID,
"collection": "app.bsky.feed.threadgate",
"record": Json,
"rkey": Post.split("/")[Post.split("/").length - 1]
let body = CreateRecord(DID, "app.bsky.feed.threadgate", Record, undefined);
return body;
}
export async function SendLike(DID, RefURI, RefCID) {
if (localStorage.getItem(Variables.BlueskyAccessToken) == null) {
console.log("No access token!");
return "";
}
let DPoP = await ClientDPoPPDS("POST", PDS + "/xrpc/com.atproto.repo.createRecord");
let request = fetch(PDS + "/xrpc/com.atproto.repo.createRecord", { body: JSON.stringify(RequestBody), method: "POST", headers: {"Content-Type": "application/json", "Authorization": "DPoP " + localStorage.getItem(Variables.BlueskyAccessToken), "DPoP": DPoP}});
let StrongRef = {
"$type": "com.atproto.repo.strongRef",
"uri": RefURI,
"cid": RefCID
}
let Record = {
"$type": "app.bsky.feed.like",
"subject": StrongRef,
"createdAt": new Date(Date.now()).toISOString()
}
let body = await GetRecord(DID, "app.bsky.feed.like", RefURI.split("/")[RefURI.split("/").length - 1]);
// We might have a record. If we do, delete the thing. If we don't, create the thing.
if (body.hasOwnProperty("error") && body.error == "RecordNotFound") {
body = await CreateRecord(DID, "app.bsky.feed.like", Record, RefURI.split("/")[RefURI.split("/").length - 1]);
} else {
body = await DeleteRecord(DID, "app.bsky.feed.like", RefURI.split("/")[RefURI.split("/").length - 1]);
}
return body;
}
export async function SendRepost(DID, RefURI, RefCID) {
if (localStorage.getItem(Variables.BlueskyAccessToken) == null) {
console.log("No access token!");
return "";
}
let StrongRef = {
"$type": "com.atproto.repo.strongRef",
"uri": RefURI,
"cid": RefCID
}
let Record = {
"$type": "app.bsky.feed.repost",
"subject": StrongRef,
"createdAt": new Date(Date.now()).toISOString()
}
let body = await GetRecord(DID, "app.bsky.feed.repost", RefURI.split("/")[RefURI.split("/").length - 1]);
// We might have a record. If we do, delete the thing. If we don't, create the thing.
if (body.hasOwnProperty("error") && body.error == "RecordNotFound") {
body = await CreateRecord(DID, "app.bsky.feed.repost", Record, RefURI.split("/")[RefURI.split("/").length - 1]);
} else {
body = await DeleteRecord(DID, "app.bsky.feed.repost", RefURI.split("/")[RefURI.split("/").length - 1]);
}
return body;
}
export async function GetRecord(Repo, Collection, RKey) {
let RequestBody = {
"repo": Repo,
"collection": Collection,
"rkey": RKey
}
let DPoP = await ClientDPoPPDS("GET", localStorage.getItem(Variables.BlueskyPDS) + "/xrpc/com.atproto.repo.getRecord?repo=" + Repo + "&collection=" + Collection + "&rkey=" + RKey);
let request = fetch(localStorage.getItem(Variables.BlueskyPDS) + "/xrpc/com.atproto.repo.getRecord?repo=" + Repo + "&collection=" + Collection + "&rkey=" + RKey, { method: "GET", headers: {"Content-Type": "application/json", "Authorization": "DPoP " + localStorage.getItem(Variables.BlueskyAccessToken), "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 SetThreadGate(DID, Post, VisibilitySettings);
body = await DeleteRecord(Repo, Collection, RKey);
}
return body;
}
export async function CreateRecord(Repo, Collection, Record, RKey) {
let RequestBody = {
"repo": Repo,
"collection": Collection,
"record": Record
}
if (RKey != undefined) {
RequestBody.rkey = RKey;
}
let DPoP = await ClientDPoPPDS("POST", localStorage.getItem(Variables.BlueskyPDS) + "/xrpc/com.atproto.repo.createRecord");
let request = fetch(localStorage.getItem(Variables.BlueskyPDS) + "/xrpc/com.atproto.repo.createRecord", { body: JSON.stringify(RequestBody), method: "POST", headers: {"Content-Type": "application/json", "Authorization": "DPoP " + localStorage.getItem(Variables.BlueskyAccessToken), "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 CreateRecord(Repo, Collection, Record, RKey);
}
return body;
}
export async function DeleteRecord(Repo, Collection, RKey) {
let RequestBody = {
"repo": Repo,
"collection": Collection,
"rkey": RKey
}
let DPoP = await ClientDPoPPDS("POST", localStorage.getItem(Variables.BlueskyPDS) + "/xrpc/com.atproto.repo.deleteRecord");
let request = fetch(localStorage.getItem(Variables.BlueskyPDS) + "/xrpc/com.atproto.repo.deleteRecord", { body: JSON.stringify(RequestBody), method: "POST", headers: {"Content-Type": "application/json", "Authorization": "DPoP " + localStorage.getItem(Variables.BlueskyAccessToken), "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 DeleteRecord(Repo, Collection, RKey);
}
return body;
}

View file

@ -77,6 +77,17 @@ export async function GetNotifications() {
.then((response) => response.json());
}
export async function GetStatus(ID) {
if (localStorage.getItem(Variables.MastodonAccessToken) == null) {
console.log("No access token!");
return "";
}
let Website = localStorage.getItem(Variables.MastodonWebsite);
// Get the varaibles that are stored in Variables and then input it.
return await fetch(Website + "/api/v1/statuses/" + ID, {method: "GET", headers: {"Authorization": localStorage.getItem(Variables.MastodonTokenType) + " " + localStorage.getItem(Variables.MastodonAccessToken)}})
.then((response) => response.json());
}
// Make a status
export async function CreateStatus(Text, Visibility = "public") {
if (localStorage.getItem(Variables.MastodonAccessToken) == null) {
@ -93,7 +104,6 @@ export async function CreateStatus(Text, Visibility = "public") {
// This is in case you went over the characters.
if (status == 422) {
let matches = body.error.match(/(\d+)/);
console.log(matches);
request = fetch(Website + "/api/v1/statuses?status=" + Text.slice(0, matches[0] - 1) + "&visibility=" + Visibility, {method: "POST", headers: {"Authorization": localStorage.getItem(Variables.MastodonTokenType) + " " + localStorage.getItem(Variables.MastodonAccessToken)}});
body = await request.then((response) => response.json());
await CreateReplyStatus(Text.slice(matches[0] - 1, Text.length - 1), Visibility, body.id);
@ -123,6 +133,36 @@ export async function CreateReplyStatus(Text, Visibility = "public", ReplyID) {
return body;
}
export async function SendFavorite(ID, IsFavorited) {
if (localStorage.getItem(Variables.MastodonAccessToken) == null) {
console.log("No access token!");
return "";
}
let Website = localStorage.getItem(Variables.MastodonWebsite);
if (IsFavorited == false) {
return await fetch(Website + "/api/v1/statuses/" + ID + "/favourite", {method: "POST", headers: {"Authorization": localStorage.getItem(Variables.MastodonTokenType) + " " + localStorage.getItem(Variables.MastodonAccessToken)}})
.then((response) => response.json());
} else {
return await fetch(Website + "/api/v1/statuses/" + ID + "/unfavourite", {method: "POST", headers: {"Authorization": localStorage.getItem(Variables.MastodonTokenType) + " " + localStorage.getItem(Variables.MastodonAccessToken)}})
.then((response) => response.json());
}
}
export async function SendReblog(ID, IsReblogged) {
if (localStorage.getItem(Variables.MastodonAccessToken) == null) {
console.log("No access token!");
return "";
}
let Website = localStorage.getItem(Variables.MastodonWebsite);
if (IsReblogged == false) {
return await fetch(Website + "/api/v1/statuses/" + ID + "/reblog", {method: "POST", headers: {"Authorization": localStorage.getItem(Variables.MastodonTokenType) + " " + localStorage.getItem(Variables.MastodonAccessToken)}})
.then((response) => response.json());
} else {
return await fetch(Website + "/api/v1/statuses/" + ID + "/unreblog", {method: "POST", headers: {"Authorization": localStorage.getItem(Variables.MastodonTokenType) + " " + localStorage.getItem(Variables.MastodonAccessToken)}})
.then((response) => response.json());
}
}
// The first step to using the app.
export async function HandleAuthentication(Website) {
// See if the user is smart enough to put https.

View file

@ -1,5 +1,107 @@
let content = decodeURI(document.location.href.split("content=")[1]);
let username = decodeURI(document.location.href.split("username=")[1].split("&content")[0]);
import * as MastodonAPI from "./MastodonAPI.js";
import * as BlueskyAPI from "./BlueskyAPI.js";
import * as TumblrAPI from "./TumblrAPI.js";
import * as Variables from "./Variables.js";
document.getElementsByClassName("Handle")[0].innerHTML = username;
document.getElementsByClassName("DetailedText")[0].innerHTML = content;
// Buttons
let Favorite = document.getElementsByClassName("Favorite")[0];
let Boost = document.getElementsByClassName("Boost")[0];
let Reply = document.getElementsByClassName("Reply")[0];
let FavoriteFlipper = false;
let BoostFlipper = false;
// Variables
let website = document.location.href.split("website=")[1];
let post = JSON.parse(localStorage.getItem("post"));
document.getElementsByClassName("Origin")[0].innerHTML = website;
GetPost();
// Button stuff
Favorite.onclick = (event) => {
if (website == "Mastodon") {
MastodonAPI.SendFavorite(post.id, post.favourited);
} else if (website == "Bluesky") {
BlueskyAPI.SendLike(localStorage.getItem(Variables.BlueskyDID), post.post.uri, post.post.cid);
}
SetFavorite();
}
Boost.onclick = (event) => {
if (website == "Mastodon") {
MastodonAPI.SendReblog(post.id, post.reblogged);
} else if (website == "Bluesky") {
BlueskyAPI.SendRepost(localStorage.getItem(Variables.BlueskyDID), post.post.uri, post.post.cid);
}
SetBoost();
}
Reply.onclick = (event) => {
window.location.href = "../../HTML/post.html?website=" + website;
}
// Functions and things.
async function GetPost() {
if (website == "Mastodon") {
// Check for a reblog.
if (post.reblog != null) {
document.getElementsByClassName("PostText")[0].innerHTML = post.reblog.content;
document.getElementsByClassName("Handle")[0].innerHTML = post.reblog.account.username + " ( R: " + post.account.username + " )";
} else {
document.getElementsByClassName("PostText")[0].innerHTML = post.content;
document.getElementsByClassName("Handle")[0].innerHTML = post.account.username;
}
// Show the image if it exists.
if (post.media_attachments.length != 0) {
for (let i of post.media_attachments) {
document.getElementsByClassName("Images")[0].innerHTML = document.getElementsByClassName("Images")[0].innerHTML + "<img src=" + i.remote_url + " alt='" + i.description + "'/>";
}
}
// Update the post to see if there is new information.
post = await MastodonAPI.GetStatus(post.id);
// Set the texts.
FavoriteFlipper = !(post.favourite);
BoostFlipper = !(post.reblogged);
SetFavorite();
SetBoost();
} else if (website == "Bluesky") {
// Check for a reblog.
if (post.hasOwnProperty("reason") && post.reason.$type == "app.bsky.feed.defs#reasonRepost") {
document.getElementsByClassName("PostText")[0].innerHTML = post.post.record.text;
document.getElementsByClassName("Handle")[0].innerHTML = post.post.author.handle + " ( R: " + post.reason.by.handle + " )";
} else {
document.getElementsByClassName("PostText")[0].innerHTML = post.post.record.text;
document.getElementsByClassName("Handle")[0].innerHTML = post.post.author.handle;
}
// Show the image if it exists.
if (post.post.record.hasOwnProperty("embed") && post.post.record.embed.$type == "app.bsky.embed.images") {
for (let i of post.post.embed.images) {
document.getElementsByClassName("Images")[0].innerHTML = document.getElementsByClassName("Images")[0].innerHTML + "<img src=" + i.fullsize + " alt='" + i.alt + "'/>";
}
}
// We don't need to update the post with new information. The repos are seperate.
// Set the texts.
// TODO!
} else {
document.getElementsByClassName("PostText")[0].innerHTML = "Nothing to load.";
}
}
function SetFavorite() {
FavoriteFlipper = !(FavoriteFlipper);
if (FavoriteFlipper == false) {
Favorite.innerHTML = "Favorite!";
} else {
Favorite.innerHTML = "Unfavorite...";
}
}
function SetBoost() {
BoostFlipper = !(BoostFlipper);
if (BoostFlipper == false) {
Boost.innerHTML = "Boost!";
} else {
Boost.innerHTML = "Unboost...";
}
}

View file

@ -101,27 +101,45 @@ ArrowsButton[0].onclick = (event) => {
}
}
for (let i of ClickableContainers) {
i.onclick = (event) => {
let content = i.getElementsByClassName("PostContent")[0].innerHTML
let username = i.getElementsByClassName("Username")[0].innerHTML
// Save some info
window.location.href = "./HTML/expanded.html?username=" + username + "&content=" + content;
}
}
// These numbers are here so you don't go back.
let MastodonLoadedFeed = [];
let BlueskyLoadedFeed = [];
let CurrentThing = 0;
let WebsiteAPIType = [];
let Mastodon = true;
let Bluesky = true;
// This will allow you to click on a post and get an "expended" version of that post.
for (let i of ClickableContainers) {
i.onclick = (event) => {
let number = parseInt(i.getAttribute("number"));
let post;
let website;
// Roundabout way of doing things. Very funny.
website = WebsiteAPIType[number];
if (WebsiteAPIType[number] == "Mastodon") {
post = MastodonLoadedFeed[CurrentThing + number];
} else if (WebsiteAPIType[number] == "Bluesky") {
if (Mastodon == true) {
// *hardcoded bullshit*
number = number - 6;
}
post = BlueskyLoadedFeed[CurrentThing + number];
} else {
return;
}
// Save some info
localStorage.setItem("post", JSON.stringify(post));
document.location.href = "./HTML/expanded.html?website=" + website;
}
}
// Call this to update the things :)
async function PosterContainerUpdate(Direction) {
let Lim = 6;
let Website = localStorage.getItem(Variables.MastodonWebsite);
let Mastodon = true;
// Mastodon gaining of timeline.
if (localStorage.getItem(Variables.MastodonWebsite) == null) {
// The default website is Wetdry :3
@ -135,6 +153,7 @@ async function PosterContainerUpdate(Direction) {
if (localStorage.getItem(Variables.BlueskyPDS) == null) {
console.log("No Bluesky instance. multiplying mastodon posts by 2...");
Lim = Lim * 2;
Bluesky = false;
} else if (BlueskyLoadedFeed.length == 0) {
BlueskyLoadedFeed = await BlueskyAPI.GetTimeline("").then((response) => response.feed);
}
@ -145,9 +164,6 @@ async function PosterContainerUpdate(Direction) {
CurrentThing = CurrentThing - Lim;
}
}
// Debugging
console.log(MastodonLoadedFeed);
console.log(BlueskyLoadedFeed);
// The first one is for counting.
// The countergroup increments to another timeline once posts hit the "limit".
let counter = 0;
@ -155,33 +171,43 @@ async function PosterContainerUpdate(Direction) {
if (Mastodon == false) {
countergroup = countergroup + 1;
}
if (Bluesky == false) {
countergroup = countergroup + 1;
}
// This var is meant to stop "already seen" posts.
let BlueskyPostsDup = [];
WebsiteAPIType = [];
for (let i of ClickableContainers) {
switch(countergroup) {
// Mastodon
case 0:
WebsiteAPIType.push("Mastodon");
if (MastodonLoadedFeed[CurrentThing + counter] == undefined) {
let TempFeed = await MastodonAPI.GetTimeline(MastodonLoadedFeed[CurrentThing + counter - 1].id);
MastodonLoadedFeed = MastodonLoadedFeed.concat(TempFeed);
}
// Check for images.
if (MastodonLoadedFeed[CurrentThing + counter].media_attachments.length != 0) {
i.getElementsByClassName("PostContent")[0].innerHTML += "This post has an image!<br/>";
}
// Content warning. Don't show the content unless clicked!!!
if (MastodonLoadedFeed[CurrentThing + counter].spoiler_text != "") {
i.getElementsByClassName("PostContent")[0].innerHTML = "<b>WARNING: " + MastodonLoadedFeed[CurrentThing + counter].spoiler_text + "</b>";
i.getElementsByClassName("PostContent")[0].innerHTML += "<b>WARNING: " + MastodonLoadedFeed[CurrentThing + counter].spoiler_text + "</b>";
i.getElementsByClassName("Username")[0].innerHTML = MastodonLoadedFeed[CurrentThing + counter].account.username;
break;
}
// Check for a reblog.
if (MastodonLoadedFeed[CurrentThing + counter].reblog != null) {
i.getElementsByClassName("PostContent")[0].innerHTML = MastodonLoadedFeed[CurrentThing + counter].reblog.content;
i.getElementsByClassName("PostContent")[0].innerHTML += MastodonLoadedFeed[CurrentThing + counter].reblog.content;
i.getElementsByClassName("Username")[0].innerHTML = MastodonLoadedFeed[CurrentThing + counter].reblog.account.username + " ( R: " + MastodonLoadedFeed[CurrentThing + counter].account.username + " )";
} else {
i.getElementsByClassName("PostContent")[0].innerHTML = MastodonLoadedFeed[CurrentThing + counter].content;
i.getElementsByClassName("PostContent")[0].innerHTML += MastodonLoadedFeed[CurrentThing + counter].content;
i.getElementsByClassName("Username")[0].innerHTML = MastodonLoadedFeed[CurrentThing + counter].account.username;
}
break;
// Bsky
case 1:
WebsiteAPIType.push("Bluesky");
if (BlueskyLoadedFeed[CurrentThing + counter] == undefined) {
let TempFeed = await BlueskyAPI.GetTimeline(BlueskyLoadedFeed[CurrentThing + counter - 1].post.indexedAt).then((response) => response.feed)
BlueskyLoadedFeed = BlueskyLoadedFeed.concat(TempFeed);
@ -189,25 +215,32 @@ async function PosterContainerUpdate(Direction) {
// check for "already seen" posts, then put it as a seen post.
BlueskyLoadedFeed = CheckForDups(BlueskyLoadedFeed, BlueskyPostsDup, counter);
BlueskyPostsDup.push(BlueskyLoadedFeed[counter].post.uri);
// Check for an image
if (BlueskyLoadedFeed[CurrentThing + counter].post.record.hasOwnProperty("embed") && BlueskyLoadedFeed[CurrentThing + counter].post.record.embed.$type == "app.bsky.embed.images") {
i.getElementsByClassName("PostContent")[0].innerHTML += "This post has an image!<br/>";
}
// Labels
if (BlueskyLoadedFeed[CurrentThing + counter].post.labels.length != 0) {
i.getElementsByClassName("PostContent")[0].innerHTML = "<b>LABELS APPLIED: ";
i.getElementsByClassName("PostContent")[0].innerHTML += "<b>LABELS APPLIED: ";
i.getElementsByClassName("Username")[0].innerHTML = BlueskyLoadedFeed[CurrentThing + counter].post.author.handle;
for (let lab of BlueskyLoadedFeed[CurrentThing + counter].post.labels) {
i.getElementsByClassName("PostContent")[0].innerHTML = i.getElementsByClassName("PostContent")[0].innerHTML + lab.val + " ";
i.getElementsByClassName("PostContent")[0].innerHTML += lab.val + " ";
}
i.getElementsByClassName("PostContent")[0].innerHTML = i.getElementsByClassName("PostContent")[0].innerHTML + "</b>";
i.getElementsByClassName("PostContent")[0].innerHTML += "</b>";
break;
}
// Check for a reblog
if (BlueskyLoadedFeed[CurrentThing + counter].hasOwnProperty("reason") && BlueskyLoadedFeed[CurrentThing + counter].reason.$type == "app.bsky.feed.defs#reasonRepost") {
i.getElementsByClassName("PostContent")[0].innerHTML = BlueskyLoadedFeed[CurrentThing + counter].post.record.text;
i.getElementsByClassName("PostContent")[0].innerHTML += BlueskyLoadedFeed[CurrentThing + counter].post.record.text;
i.getElementsByClassName("Username")[0].innerHTML = BlueskyLoadedFeed[CurrentThing + counter].post.author.handle + " ( R: " + BlueskyLoadedFeed[CurrentThing + counter].reason.by.handle + " )";
} else {
i.getElementsByClassName("PostContent")[0].innerHTML = BlueskyLoadedFeed[CurrentThing + counter].post.record.text;
i.getElementsByClassName("PostContent")[0].innerHTML += BlueskyLoadedFeed[CurrentThing + counter].post.record.text;
i.getElementsByClassName("Username")[0].innerHTML = BlueskyLoadedFeed[CurrentThing + counter].post.author.handle;
}
// Direction for where you go :3
break;
case 2:
WebsiteAPIType.push("Nothing");
console.log("The number you are trying to reach is unavailable. Try signing in dumbass.");
break;
}
counter = counter + 1;

View file

@ -8,21 +8,26 @@ let PostButton = document.getElementsByClassName("Button")[0];
let VisibilityDropdown = document.getElementsByClassName("PostVisibility")[0];
let InputArea = document.getElementsByClassName("Text")[0];
// Extra Variables
// Clicking the beeg POST button.
PostButton.onclick = (event) => {
Post();
}
async function Post() {
let website;
if (document.location.href.split("website=").length > 1) {
website = document.location.href.split("website=")[1];
} else {
website = "All";
}
// Check to see if you are replying.
let Text = InputArea.value;
let Visible = VisibilityDropdown.value;
// don't do anything if there is no value
if (Text == "") {
return;
}
InputArea.value = "";
// Mastodon posting.
if (localStorage.getItem(Variables.MastodonAccessToken) != null) {
let TempVisible;
@ -40,7 +45,12 @@ async function Post() {
TempVisible = "direct";
break;
}
MastodonAPI.CreateStatus(Text, TempVisible);
if (website == "Mastodon") {
await MastodonAPI.CreateReplyStatus(Text, TempVisible, JSON.parse(localStorage.getItem("post")).id);
return;
} else if (website == "All") {
await MastodonAPI.CreateStatus(Text, TempVisible);
}
}
// Bluesky posting.
if (localStorage.getItem(Variables.BlueskyAccessToken) != null) {
@ -59,10 +69,21 @@ async function Post() {
TempVisible = [];
break;
}
let Post = await BlueskyAPI.CreatePost(localStorage.getItem(Variables.BlueskyDID), Text);
let ThreadGate = await BlueskyAPI.SetThreadGate(localStorage.getItem(Variables.BlueskyDID), Post.uri, TempVisible);
if (website == "Bluesky") {
if (JSON.parse(localStorage.getItem("post")).hasOwnProperty("reply")) {
let Post = await BlueskyAPI.CreateReplyPost(localStorage.getItem(Variables.BlueskyDID), Text, JSON.parse(localStorage.getItem("post")).post, JSON.parse(localStorage.getItem("post")).reply.root);
await BlueskyAPI.SetThreadGate(localStorage.getItem(Variables.BlueskyDID), Post.uri, TempVisible);
return;
} else {
let Post = await BlueskyAPI.CreateReplyPost(localStorage.getItem(Variables.BlueskyDID), Text, JSON.parse(localStorage.getItem("post")).post, JSON.parse(localStorage.getItem("post")).post);
await BlueskyAPI.SetThreadGate(localStorage.getItem(Variables.BlueskyDID), Post.uri, TempVisible);
return;
}
} else if (website == "All") {
let Post = await BlueskyAPI.CreatePost(localStorage.getItem(Variables.BlueskyDID), Text);
await BlueskyAPI.SetThreadGate(localStorage.getItem(Variables.BlueskyDID), Post.uri, TempVisible);
}
}
InputArea.value = "";
}
// Check if you can interact with the textbox

View file

@ -3,6 +3,7 @@
<head>
<title>The Fediverse</title>
<meta name="description" content="Change the fucking channel already!">
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1" />
<link rel="icon" href="./Icons/favicon.ico" />
<link rel="stylesheet" href="./CSS/index.css">
<!-- I am terribly sorry.
@ -135,51 +136,51 @@
<!-- This is the container that houses the current viewing stuff -->
<div class="PostContainer">
<article class="Post">
<article number=0 class="Post">
<p class="Username"></p>
<p class="PostContent"></p>
</article>
<article class="Post">
<article number=1 class="Post">
<p class="Username"></p>
<p class="PostContent"></p>
</article>
<article class="Post">
<article number=2 class="Post">
<p class="Username"></p>
<p class="PostContent"></p>
</article>
<article class="Post">
<article number=3 class="Post">
<p class="Username"></p>
<p class="PostContent"></p>
</article>
<article class="Post">
<article number=4 class="Post">
<p class="Username"></p>
<p class="PostContent"></p>
</article>
<article class="Post">
<article number=5 class="Post">
<p class="Username"></p>
<p class="PostContent"></p>
</article>
<article class="Post">
<article number=6 class="Post">
<p class="Username"></p>
<p class="PostContent"></p>
</article>
<article class="Post">
<article number=7 class="Post">
<p class="Username"></p>
<p class="PostContent"></p>
</article>
<article class="Post">
<article number=8 class="Post">
<p class="Username"></p>
<p class="PostContent"></p>
</article>
<article class="Post">
<article number=9 class="Post">
<p class="Username"></p>
<p class="PostContent"></p>
</article>
<article class="Post">
<article number=10 class="Post">
<p class="Username"></p>
<p class="PostContent"></p>
</article>
<article class="Post">
<article number=11 class="Post">
<p class="Username"></p>
<p class="PostContent"></p>
</article>