Skip to content

Instantly share code, notes, and snippets.

@futurGH
Last active July 15, 2024 19:08
Show Gist options
  • Save futurGH/1ad7eaffb4fc210b88c951772c95eced to your computer and use it in GitHub Desktop.
Save futurGH/1ad7eaffb4fc210b88c951772c95eced to your computer and use it in GitHub Desktop.
unfollow yourself
const { accessJwt, did, pdsUrl } = JSON.parse(localStorage.BSKY_STORAGE).session.currentAccount;
let cursor="", records, rkey;
while (!rkey) {
({cursor, records} = await fetch(pdsUrl + `xrpc/com.atproto.repo.listRecords?repo=${did}&collection=app.bsky.graph.follow&cursor=${cursor}`).then(r => r.json()));
if (!records?.length) break;
rkey = records.find(r => r.value.subject === did)?.uri?.split("/").pop();
if (rkey) break;
}
if (rkey) {
const headers = new Headers();
headers.append("Authorization", "Bearer " + accessJwt);
headers.append("Content-Type", "application/json");
await fetch(pdsUrl + "xrpc/com.atproto.repo.deleteRecord", {
method: "POST",
body: JSON.stringify({ repo: did, collection: "app.bsky.graph.follow", rkey }),
headers
});
} else console.error("Could not find follow record");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment