From 69605379c3b7801391049cd0656d1d143e5f5ea7 Mon Sep 17 00:00:00 2001 From: CatAClock Date: Tue, 20 May 2025 17:36:28 -0700 Subject: [PATCH] Videos and Images now work with the blob system in Bsky (mastodon doesn't give the user a blob) --- JS/BlueskyAPI.js | 2 +- JS/expanded.js | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/JS/BlueskyAPI.js b/JS/BlueskyAPI.js index 7879277..da94bff 100644 --- a/JS/BlueskyAPI.js +++ b/JS/BlueskyAPI.js @@ -48,7 +48,7 @@ export async function GetPosts(URIs) { // Get a blob (like an image or video). Authentication need not apply. export async function GetBlob(DID, CID) { 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()); + let body = await request.then((response) => response.blob()); return body; } diff --git a/JS/expanded.js b/JS/expanded.js index 7b30090..37e8c65 100644 --- a/JS/expanded.js +++ b/JS/expanded.js @@ -83,11 +83,15 @@ async function GetPost() { if (post.post.record.hasOwnProperty("embed")) { if (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 + "" + i.alt + ""; + var Blobby = await BlueskyAPI.GetBlob(post.post.author.did, post.post.record.embed.images[0].image.ref.$link); + var ObjectURL = URL.createObjectURL(Blobby) + document.getElementsByClassName("Images")[0].innerHTML = document.getElementsByClassName("Images")[0].innerHTML + "" + i.alt + ""; } } else if (post.post.record.embed.$type == "app.bsky.embed.video") { let i = post.post.embed.playlist; - document.getElementsByClassName("Images")[0].innerHTML = document.getElementsByClassName("Images")[0].innerHTML + ""; + var Blobby = await BlueskyAPI.GetBlob(post.post.author.did, post.post.record.embed.video.ref.$link); + var ObjectURL = URL.createObjectURL(Blobby) + document.getElementsByClassName("Images")[0].innerHTML = document.getElementsByClassName("Images")[0].innerHTML + ""; } } // We don't need to update the post with new information. The repos are seperate.