embed bsky bug fixed! What an odd thing
This commit is contained in:
parent
b95d08b4f3
commit
2279145be0
1 changed files with 13 additions and 8 deletions
|
@ -20,6 +20,9 @@ let GrandParentpost;
|
||||||
document.getElementsByClassName("Origin Regular")[0].innerHTML = website;
|
document.getElementsByClassName("Origin Regular")[0].innerHTML = website;
|
||||||
GetPost();
|
GetPost();
|
||||||
|
|
||||||
|
// Fixes a bug where the interpreter sucks ass.
|
||||||
|
let EmbedCounter = 0;
|
||||||
|
|
||||||
// Button stuff
|
// Button stuff
|
||||||
Favorite.onclick = (event) => {
|
Favorite.onclick = (event) => {
|
||||||
if (website == "Mastodon") {
|
if (website == "Mastodon") {
|
||||||
|
@ -212,8 +215,8 @@ async function ApplyMedia(Media, Element, Author = undefined) {
|
||||||
// Record and media embed; They are from seperate posts.
|
// Record and media embed; They are from seperate posts.
|
||||||
if (Media.$type == "app.bsky.embed.recordWithMedia") {
|
if (Media.$type == "app.bsky.embed.recordWithMedia") {
|
||||||
await BlueskyBlobEmbed(Media.media, Element, Author);
|
await BlueskyBlobEmbed(Media.media, Element, Author);
|
||||||
var Texty = await BlueskyAPI.GetPosts([Media.record.record.uri]);
|
let Texty = await BlueskyAPI.GetPosts([Media.record.record.uri]);
|
||||||
var Text = BlueskyAPI.ApplyFacets(Texty.posts[0].record, Texty.posts[0].record.text);
|
let Text = BlueskyAPI.ApplyFacets(Texty.posts[0].record, Texty.posts[0].record.text);
|
||||||
Text = Text.replace(/\r?\n|\r/g, "<br/>");
|
Text = Text.replace(/\r?\n|\r/g, "<br/>");
|
||||||
Element.innerHTML += "<p class='Embed'>" + Text + "</p><br/>";
|
Element.innerHTML += "<p class='Embed'>" + Text + "</p><br/>";
|
||||||
// To stop confusion: this is for the RECORD EMBED! It gets an image from the record embed and puts it there.
|
// To stop confusion: this is for the RECORD EMBED! It gets an image from the record embed and puts it there.
|
||||||
|
@ -222,8 +225,8 @@ async function ApplyMedia(Media, Element, Author = undefined) {
|
||||||
}
|
}
|
||||||
// Just a record on it's own.
|
// Just a record on it's own.
|
||||||
} else if (Media.$type == "app.bsky.embed.record") {
|
} else if (Media.$type == "app.bsky.embed.record") {
|
||||||
var Texty = await BlueskyAPI.GetPosts([Media.record.uri]);
|
let Texty = await BlueskyAPI.GetPosts([Media.record.uri]);
|
||||||
var Text = BlueskyAPI.ApplyFacets(Texty.posts[0].record, Texty.posts[0].record.text);
|
let Text = BlueskyAPI.ApplyFacets(Texty.posts[0].record, Texty.posts[0].record.text);
|
||||||
Text = Text.replace(/\r?\n|\r/g, "<br/>");
|
Text = Text.replace(/\r?\n|\r/g, "<br/>");
|
||||||
Element.innerHTML += "<p class='Embed'>" + Text + "</p><br/>";
|
Element.innerHTML += "<p class='Embed'>" + Text + "</p><br/>";
|
||||||
if (Texty.posts[0].record.embed.$type == "app.bsky.embed.images" || Texty.posts[0].record.embed.$type == "app.bsky.embed.video") {
|
if (Texty.posts[0].record.embed.$type == "app.bsky.embed.images" || Texty.posts[0].record.embed.$type == "app.bsky.embed.video") {
|
||||||
|
@ -233,6 +236,7 @@ async function ApplyMedia(Media, Element, Author = undefined) {
|
||||||
} else if (Media.$type == "app.bsky.embed.images" || Media.$type == "app.bsky.embed.video") {
|
} else if (Media.$type == "app.bsky.embed.images" || Media.$type == "app.bsky.embed.video") {
|
||||||
await BlueskyBlobEmbed(Media, Element, Author);
|
await BlueskyBlobEmbed(Media, Element, Author);
|
||||||
}
|
}
|
||||||
|
EmbedCounter = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,9 +247,10 @@ async function BlueskyBlobEmbed(Blob, Element, Author) {
|
||||||
Element.innerHTML += "<img src=\"\" alt=\"\"/>";
|
Element.innerHTML += "<img src=\"\" alt=\"\"/>";
|
||||||
var Blobby = await BlueskyAPI.GetBlob(Author, i.image.ref.$link);
|
var Blobby = await BlueskyAPI.GetBlob(Author, i.image.ref.$link);
|
||||||
var ObjectURL = URL.createObjectURL(Blobby);
|
var ObjectURL = URL.createObjectURL(Blobby);
|
||||||
Element = Element.getElementsByTagName("img")[0];
|
let TempElement = Element.getElementsByTagName("img")[EmbedCounter];
|
||||||
Element.setAttribute("src", ObjectURL);
|
EmbedCounter += 1;
|
||||||
Element.setAttribute("alt", EscapeRegExp(i.alt));
|
TempElement.setAttribute("src", ObjectURL);
|
||||||
|
TempElement.setAttribute("alt", EscapeRegExp(i.alt));
|
||||||
}
|
}
|
||||||
// Video embed.
|
// Video embed.
|
||||||
} else if (Blob.$type == "app.bsky.embed.video") {
|
} else if (Blob.$type == "app.bsky.embed.video") {
|
||||||
|
@ -254,7 +259,7 @@ async function BlueskyBlobEmbed(Blob, Element, Author) {
|
||||||
var Blobby = await BlueskyAPI.GetBlob(Author, Blob.video.ref.$link);
|
var Blobby = await BlueskyAPI.GetBlob(Author, Blob.video.ref.$link);
|
||||||
var ObjectURL = URL.createObjectURL(Blobby);
|
var ObjectURL = URL.createObjectURL(Blobby);
|
||||||
Element.setAttribute("src", ObjectURL);
|
Element.setAttribute("src", ObjectURL);
|
||||||
Element.innerHTML
|
Element.innerHTML = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue