Threads and a few bug fixes with links
This commit is contained in:
parent
81ba37fcdf
commit
5dbc2a2b44
3 changed files with 61 additions and 10 deletions
|
@ -13,10 +13,18 @@
|
||||||
|
|
||||||
<body style="margin: 0px; text-align: center;">
|
<body style="margin: 0px; text-align: center;">
|
||||||
<!-- Grandparent is a reply post above the reply post above the regular, clicked post. -->
|
<!-- Grandparent is a reply post above the reply post above the regular, clicked post. -->
|
||||||
|
<header>
|
||||||
|
<h1 class="Handle GrandParent"></h1>
|
||||||
|
<h2 class="Origin GrandParent"></h2>
|
||||||
|
</header>
|
||||||
<p class="PostText GrandParent"></p>
|
<p class="PostText GrandParent"></p>
|
||||||
<div class="Images GrandParent"></div>
|
<div class="Images GrandParent"></div>
|
||||||
<hr/>
|
<hr/>
|
||||||
<!-- Parent is a reply post above the regular, clicked post. -->
|
<!-- Parent is a reply post above the regular, clicked post. -->
|
||||||
|
<header>
|
||||||
|
<h1 class="Handle Parent"></h1>
|
||||||
|
<h2 class="Origin Parent"></h2>
|
||||||
|
</header>
|
||||||
<p class="PostText Parent"></p>
|
<p class="PostText Parent"></p>
|
||||||
<div class="Images Parent"></div>
|
<div class="Images Parent"></div>
|
||||||
<hr/>
|
<hr/>
|
||||||
|
|
|
@ -15,7 +15,7 @@ let BoostFlipper = false;
|
||||||
let website = document.location.href.split("website=")[1];
|
let website = document.location.href.split("website=")[1];
|
||||||
let post = JSON.parse(localStorage.getItem("post"));
|
let post = JSON.parse(localStorage.getItem("post"));
|
||||||
|
|
||||||
document.getElementsByClassName("Origin")[0].innerHTML = website;
|
document.getElementsByClassName("Origin Regular")[0].innerHTML = website;
|
||||||
GetPost();
|
GetPost();
|
||||||
|
|
||||||
// Button stuff
|
// Button stuff
|
||||||
|
@ -47,7 +47,7 @@ async function GetPost() {
|
||||||
// Check for a reblog.
|
// Check for a reblog.
|
||||||
if (post.reblog != null) {
|
if (post.reblog != null) {
|
||||||
document.getElementsByClassName("PostText Regular")[0].innerHTML = post.reblog.content;
|
document.getElementsByClassName("PostText Regular")[0].innerHTML = post.reblog.content;
|
||||||
document.getElementsByClassName("Handle")[0].innerHTML = post.reblog.account.username + " ( R: " + post.account.username + " )";
|
document.getElementsByClassName("Handle Regular")[0].innerHTML = post.reblog.account.username + " ( R: " + post.account.username + " )";
|
||||||
if (post.reblog.media_attachments.length != 0) {
|
if (post.reblog.media_attachments.length != 0) {
|
||||||
for (let i of post.reblog.media_attachments) {
|
for (let i of post.reblog.media_attachments) {
|
||||||
await CreateMedia(i, document.getElementsByClassName("Images Regular")[0]);
|
await CreateMedia(i, document.getElementsByClassName("Images Regular")[0]);
|
||||||
|
@ -55,7 +55,7 @@ async function GetPost() {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
document.getElementsByClassName("PostText Regular")[0].innerHTML = post.content;
|
document.getElementsByClassName("PostText Regular")[0].innerHTML = post.content;
|
||||||
document.getElementsByClassName("Handle")[0].innerHTML = post.account.username;
|
document.getElementsByClassName("Handle Regular")[0].innerHTML = post.account.username;
|
||||||
// Show the image if it exists.
|
// Show the image if it exists.
|
||||||
if (post.media_attachments.length != 0) {
|
if (post.media_attachments.length != 0) {
|
||||||
for (let i of post.media_attachments) {
|
for (let i of post.media_attachments) {
|
||||||
|
@ -71,6 +71,7 @@ async function GetPost() {
|
||||||
// Now time to see if there are any parents
|
// Now time to see if there are any parents
|
||||||
if (post.in_reply_to_id != null) {
|
if (post.in_reply_to_id != null) {
|
||||||
var AnotherPost = await MastodonAPI.GetStatus(post.in_reply_to_id);
|
var AnotherPost = await MastodonAPI.GetStatus(post.in_reply_to_id);
|
||||||
|
document.getElementsByClassName("Origin Parent")[0].innerHTML = website;
|
||||||
if (AnotherPost.reblog != null) {
|
if (AnotherPost.reblog != null) {
|
||||||
document.getElementsByClassName("PostText Parent")[0].innerHTML = AnotherPost.reblog.content;
|
document.getElementsByClassName("PostText Parent")[0].innerHTML = AnotherPost.reblog.content;
|
||||||
if (AnotherPost.reblog.media_attachments.length != 0) {
|
if (AnotherPost.reblog.media_attachments.length != 0) {
|
||||||
|
@ -89,6 +90,7 @@ async function GetPost() {
|
||||||
// Now time to see if there are any grandparents
|
// Now time to see if there are any grandparents
|
||||||
if (AnotherPost.in_reply_to_id != null) {
|
if (AnotherPost.in_reply_to_id != null) {
|
||||||
var AnotherAnotherPost = await MastodonAPI.GetStatus(AnotherPost.in_reply_to_id);
|
var AnotherAnotherPost = await MastodonAPI.GetStatus(AnotherPost.in_reply_to_id);
|
||||||
|
document.getElementsByClassName("Origin GrandParent")[0].innerHTML = website;
|
||||||
if (AnotherAnotherPost.reblog != null) {
|
if (AnotherAnotherPost.reblog != null) {
|
||||||
document.getElementsByClassName("PostText GrandParent")[0].innerHTML = AnotherAnotherPost.reblog.content;
|
document.getElementsByClassName("PostText GrandParent")[0].innerHTML = AnotherAnotherPost.reblog.content;
|
||||||
if (AnotherAnotherPost.reblog.media_attachments.length != 0) {
|
if (AnotherAnotherPost.reblog.media_attachments.length != 0) {
|
||||||
|
@ -109,12 +111,28 @@ async function GetPost() {
|
||||||
} else if (website == "Bluesky") {
|
} else if (website == "Bluesky") {
|
||||||
// Check for a reblog.
|
// Check for a reblog.
|
||||||
if (post.hasOwnProperty("reason") && post.reason.$type == "app.bsky.feed.defs#reasonRepost") {
|
if (post.hasOwnProperty("reason") && post.reason.$type == "app.bsky.feed.defs#reasonRepost") {
|
||||||
document.getElementsByClassName("PostText Regular")[0].innerHTML = post.post.record.text;
|
document.getElementsByClassName("Handle Regular")[0].innerHTML = post.post.author.handle + " ( R: " + post.reason.by.handle + " )";
|
||||||
document.getElementsByClassName("Handle")[0].innerHTML = post.post.author.handle + " ( R: " + post.reason.by.handle + " )";
|
|
||||||
} else {
|
} else {
|
||||||
document.getElementsByClassName("PostText Regular")[0].innerHTML = post.post.record.text;
|
document.getElementsByClassName("Handle Regular")[0].innerHTML = post.post.author.handle;
|
||||||
document.getElementsByClassName("Handle")[0].innerHTML = post.post.author.handle;
|
|
||||||
}
|
}
|
||||||
|
// Text. This will be modified later.
|
||||||
|
var Text = post.post.record.text;
|
||||||
|
// Check for facets. Facets are things that change what the text does or looks like.
|
||||||
|
if (post.post.record.hasOwnProperty("facets")) {
|
||||||
|
for (let i of post.post.record.facets) {
|
||||||
|
if (i.features[0].$type == "app.bsky.richtext.facet#link") {
|
||||||
|
var EmojiRegex = /\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F/gu;
|
||||||
|
var EmojiObjects = Text.match(EmojiRegex);
|
||||||
|
var SubtractNumber = 0;
|
||||||
|
if (EmojiObjects != null) {
|
||||||
|
SubtractNumber = EmojiObjects.length * 2;
|
||||||
|
}
|
||||||
|
Text = Text.substring(0, i.index.byteStart - SubtractNumber) + "<a href='" + i.features[0].uri + "'>" + Text.substring(i.index.byteStart - SubtractNumber, i.index.byteEnd - SubtractNumber) + "</a>" + Text.substring(i.index.byteEnd - SubtractNumber, Text.length - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Place the text.
|
||||||
|
document.getElementsByClassName("PostText Regular")[0].innerHTML = Text;
|
||||||
// Show the image if it exists.
|
// Show the image if it exists.
|
||||||
if (post.post.record.hasOwnProperty("embed")) {
|
if (post.post.record.hasOwnProperty("embed")) {
|
||||||
await CreateMedia(post.post.record, document.getElementsByClassName("Images Regular")[0], post.post.author.did);
|
await CreateMedia(post.post.record, document.getElementsByClassName("Images Regular")[0], post.post.author.did);
|
||||||
|
@ -134,14 +152,18 @@ async function GetPost() {
|
||||||
// Now time to see if there are any parents.
|
// Now time to see if there are any parents.
|
||||||
if (post.hasOwnProperty("reply")) {
|
if (post.hasOwnProperty("reply")) {
|
||||||
var AnotherPost = await BlueskyAPI.GetRecord(post.reply.parent.uri.split("/")[2], post.reply.parent.uri.split("/")[3], post.reply.parent.uri.split("/")[4]);
|
var AnotherPost = await BlueskyAPI.GetRecord(post.reply.parent.uri.split("/")[2], post.reply.parent.uri.split("/")[3], post.reply.parent.uri.split("/")[4]);
|
||||||
console.log(AnotherPost);
|
document.getElementsByClassName("Origin Parent")[0].innerHTML = website;
|
||||||
|
document.getElementsByClassName("Handle Parent")[0].innerHTML = post.reply.parent.author.handle;
|
||||||
document.getElementsByClassName("PostText Parent")[0].innerHTML = AnotherPost.value.text;
|
document.getElementsByClassName("PostText Parent")[0].innerHTML = AnotherPost.value.text;
|
||||||
if (AnotherPost.value.hasOwnProperty("embed")) {
|
if (AnotherPost.value.hasOwnProperty("embed")) {
|
||||||
await CreateMedia(AnotherPost.value, document.getElementsByClassName("Images Parent")[0], post.reply.parent.author.did);
|
await CreateMedia(AnotherPost.value, document.getElementsByClassName("Images Parent")[0], post.reply.parent.author.did);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now time to see if there are any grandparents.
|
// Now time to see if there are any grandparents.
|
||||||
if (AnotherPost.value.hasOwnProperty("reply")) {
|
if (AnotherPost.value.hasOwnProperty("reply")) {
|
||||||
var AnotherAnotherPost = await BlueskyAPI.GetRecord(AnotherPost.value.reply.parent.uri.split("/")[2], AnotherPost.value.reply.parent.uri.split("/")[3], AnotherPost.value.reply.parent.uri.split("/")[4]);
|
var AnotherAnotherPost = await BlueskyAPI.GetRecord(AnotherPost.value.reply.parent.uri.split("/")[2], AnotherPost.value.reply.parent.uri.split("/")[3], AnotherPost.value.reply.parent.uri.split("/")[4]);
|
||||||
|
document.getElementsByClassName("Origin GrandParent")[0].innerHTML = website;
|
||||||
|
document.getElementsByClassName("Handle Parent")[0].innerHTML = post.reply.grandparentAuthor.handle;
|
||||||
document.getElementsByClassName("PostText GrandParent")[0].innerHTML = AnotherAnotherPost.value.text;
|
document.getElementsByClassName("PostText GrandParent")[0].innerHTML = AnotherAnotherPost.value.text;
|
||||||
if (AnotherAnotherPost.value.hasOwnProperty("embed")) {
|
if (AnotherAnotherPost.value.hasOwnProperty("embed")) {
|
||||||
await CreateMedia(AnotherAnotherPost.value, document.getElementsByClassName("Images GrandParent")[0], post.reply.grandparentAuthor.did);
|
await CreateMedia(AnotherAnotherPost.value, document.getElementsByClassName("Images GrandParent")[0], post.reply.grandparentAuthor.did);
|
||||||
|
|
25
JS/index.js
25
JS/index.js
|
@ -213,6 +213,10 @@ async function PosterContainerUpdate(Direction) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Check for a thread.
|
||||||
|
if (MastodonLoadedFeed[CurrentThing + counter].in_reply_to_id != null) {
|
||||||
|
i.getElementsByClassName("PostContent")[0].innerHTML += "This post is a thread!<br/>";
|
||||||
|
}
|
||||||
// Content warning. Don't show the content unless clicked!!!
|
// Content warning. Don't show the content unless clicked!!!
|
||||||
if (MastodonLoadedFeed[CurrentThing + counter].spoiler_text != "") {
|
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>";
|
||||||
|
@ -248,6 +252,10 @@ async function PosterContainerUpdate(Direction) {
|
||||||
i.getElementsByClassName("PostContent")[0].innerHTML += "This post has a video!<br/>";
|
i.getElementsByClassName("PostContent")[0].innerHTML += "This post has a video!<br/>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Check for a thread.
|
||||||
|
if (BlueskyLoadedFeed[CurrentThing + counter].hasOwnProperty("reply")) {
|
||||||
|
i.getElementsByClassName("PostContent")[0].innerHTML += "This post is a thread!<br/>";
|
||||||
|
}
|
||||||
// Labels
|
// Labels
|
||||||
if (BlueskyLoadedFeed[CurrentThing + counter].post.labels.length != 0) {
|
if (BlueskyLoadedFeed[CurrentThing + counter].post.labels.length != 0) {
|
||||||
i.getElementsByClassName("PostContent")[0].innerHTML += "<b>LABELS APPLIED: ";
|
i.getElementsByClassName("PostContent")[0].innerHTML += "<b>LABELS APPLIED: ";
|
||||||
|
@ -260,12 +268,25 @@ async function PosterContainerUpdate(Direction) {
|
||||||
}
|
}
|
||||||
// Check for a reblog
|
// Check for a reblog
|
||||||
if (BlueskyLoadedFeed[CurrentThing + counter].hasOwnProperty("reason") && BlueskyLoadedFeed[CurrentThing + counter].reason.$type == "app.bsky.feed.defs#reasonRepost") {
|
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("Username")[0].innerHTML = BlueskyLoadedFeed[CurrentThing + counter].post.author.handle + " ( R: " + BlueskyLoadedFeed[CurrentThing + counter].reason.by.handle + " )";
|
i.getElementsByClassName("Username")[0].innerHTML = BlueskyLoadedFeed[CurrentThing + counter].post.author.handle + " ( R: " + BlueskyLoadedFeed[CurrentThing + counter].reason.by.handle + " )";
|
||||||
} else {
|
} else {
|
||||||
i.getElementsByClassName("PostContent")[0].innerHTML += BlueskyLoadedFeed[CurrentThing + counter].post.record.text;
|
|
||||||
i.getElementsByClassName("Username")[0].innerHTML = BlueskyLoadedFeed[CurrentThing + counter].post.author.handle;
|
i.getElementsByClassName("Username")[0].innerHTML = BlueskyLoadedFeed[CurrentThing + counter].post.author.handle;
|
||||||
}
|
}
|
||||||
|
var TempText = BlueskyLoadedFeed[CurrentThing + counter].post.record.text;
|
||||||
|
if (BlueskyLoadedFeed[CurrentThing + counter].post.record.hasOwnProperty("facets")) {
|
||||||
|
for (let i of BlueskyLoadedFeed[CurrentThing + counter].post.record.facets) {
|
||||||
|
if (i.features[0].$type == "app.bsky.richtext.facet#link") {
|
||||||
|
var EmojiRegex = /\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F/gu;
|
||||||
|
var EmojiObjects = TempText.match(EmojiRegex);
|
||||||
|
var SubtractNumber = 0;
|
||||||
|
if (EmojiObjects != null) {
|
||||||
|
SubtractNumber = EmojiObjects.length * 2;
|
||||||
|
}
|
||||||
|
TempText = TempText.substring(0, i.index.byteStart - SubtractNumber) + "<a href='" + i.features[0].uri + "'>" + TempText.substring(i.index.byteStart - SubtractNumber, i.index.byteEnd - SubtractNumber) + "</a>" + TempText.substring(i.index.byteEnd - SubtractNumber, TempText.length - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
i.getElementsByClassName("PostContent")[0].innerHTML += TempText;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
WebsiteAPIType.push("Nothing");
|
WebsiteAPIType.push("Nothing");
|
||||||
|
|
Loading…
Add table
Reference in a new issue