Skip to content

Instantly share code, notes, and snippets.

@Bossett
Last active October 28, 2023 23:23
Show Gist options
  • Save Bossett/de32292c1a88e6d92fb85522d6c814ac to your computer and use it in GitHub Desktop.
Save Bossett/de32292c1a88e6d92fb85522d6c814ac to your computer and use it in GitHub Desktop.
getLikesForFeed
// Navigate from https://bsky.app/ to the feed you want to get likes for
// Open the developer tools, and copy/paste this into the console tab:
(async () => {
const [_, handle, rkey] =
window.location.href.match(
/https:\/\/bsky.app\/profile\/(.*?)\/feed\/(.*?)(?:\/|$)/
) || [];
if (!handle)
return console.error("The URL doesn't match the expected format.");
const did = !handle.startsWith("did:")
? (
await (
await fetch(
`https://bsky.social/xrpc/com.atproto.identity.resolveHandle?handle=${handle}`
)
).json()
).did
: handle;
const { session } = JSON.parse(localStorage.root);
const { accessJwt, did: repo } =
session.accounts.find((a) => a.did === session.data.did) || {};
let totalRetrieved = 0, currentCursor = '', likes = [];
do {
let result = await (
await fetch(
`https://bsky.social/xrpc/app.bsky.feed.getLikes?uri=at://${did}/app.bsky.feed.generator/${rkey}&cursor=${currentCursor}`,
{
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${accessJwt}`,
},
}
)
).json();
currentCursor = result.cursor;
totalRetrieved = result.likes.length;
likes = [...likes, ...result.likes];
} while (totalRetrieved > 0);
for (const like of likes) {
console.log(like.actor.handle);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment