Created
December 3, 2024 16:16
-
-
Save mhdcodes/5ac9444da6074eabc2a43c1157cfcd13 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| 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