Skip to content

Instantly share code, notes, and snippets.

@ntfargo
Last active December 8, 2024 21:55
Show Gist options
  • Save ntfargo/3d356c1165e8c18586f13599796be76f to your computer and use it in GitHub Desktop.
Save ntfargo/3d356c1165e8c18586f13599796be76f to your computer and use it in GitHub Desktop.
BlueSky | Unfollow All
/*
You need create .env file with the following variables:
BSKYHANDLE=yourhandle
BSKYPASS=yourpass
*/
const {
BskyAgent
} = require('@atproto/api');
require('dotenv').config();
const BSKYHANDLE = process.env.BSKYHANDLE || 'defaultHandle';
const BSKYPASS = process.env.BSKYPASS || 'defaultPassword';
const Unfollowing = async () => {
const agent = new BskyAgent({
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,
})
);
}
};
Unfollowing();
@numerarys
Copy link

works on repilt?

@subz
Copy link

subz commented Dec 6, 2024

How does one use this? I could not seem to figure it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment