Last active
February 4, 2025 19:24
-
-
Save ntfargo/3d356c1165e8c18586f13599796be76f to your computer and use it in GitHub Desktop.
BlueSky | Unfollow All
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
/* | |
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(); |
How does one use this? I could not seem to figure it out.
I tested, it works on replit.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
works on repilt?