Skip to content

Instantly share code, notes, and snippets.

@mhdcodes
Created December 3, 2024 16:16
Show Gist options
  • Select an option

  • Save mhdcodes/5ac9444da6074eabc2a43c1157cfcd13 to your computer and use it in GitHub Desktop.

Select an option

Save mhdcodes/5ac9444da6074eabc2a43c1157cfcd13 to your computer and use it in GitHub Desktop.
import { AtpAgent } from "@atproto/api";
const BSKYHANDLE = "yourhandle.bsky.social";
const BSKYPASS = "your@password";
const main = async () => {
const agent = new AtpAgent({
service: "https://bsky.social",
});
await agent.login({
identifier: BSKYHANDLE,
password: BSKYPASS,
});
let follows = [];
let cursor;
while (true) {
const following = await agent.app.bsky.graph.getFollows({
cursor,
actor: BSKYHANDLE,
});
cursor = following.data.cursor;
follows = [...follows, ...following.data.follows];
if (!cursor) break;
}
for (const actor of follows) {
const followingInfo = actor.viewer ? actor.viewer.following : null;
const [rkey, , repo] = followingInfo
? followingInfo.split("/").reverse()
: [];
console.log(rkey, repo);
console.log(
`Unfollowing ${actor.handle}`,
await agent.com.atproto.repo.deleteRecord({
collection: "app.bsky.graph.follow",
repo,
rkey,
})
);
}
};
main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment