-
-
Save futurGH/1ad7eaffb4fc210b88c951772c95eced to your computer and use it in GitHub Desktop.
unfollow yourself
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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