···
import { BskyAgent } from "@atproto/api";
const [unfollowNotice, setUnfollowNotice] = createSignal("");
+
let unfollowURIs: number[] = [];
+
let followRecords: any[];
const fetchFollows = async (agent: any) => {
···
···
+
if (!unfollowURIs.length) {
+
followRecords = await fetchFollows(agent);
+
let followsDID: string[] = [];
+
for (let n = 0; n < followRecords.length; n++)
+
followsDID[n] = followRecords[n].value.subject;
+
for (let n = 0; n < followsDID.length; n = n + 25) {
+
const res = await agent.getProfiles({
+
actors: followsDID.slice(n, n + 25),
+
let tmpDID: string[] = [];
+
for (let i = 0; i < res.data.profiles.length; i++) {
+
tmpDID[i] = res.data.profiles[i].did;
+
if (res.data.profiles[i].viewer?.blockedBy) {
+
unfollowURIs.push(i + n);
+
//await agent.deleteFollow(followRecords[i + n].uri);
+
"Found blocked account: " +
+
followRecords[i + n].value.subject +
+
res.data.profiles[i].handle +
+
for (let i = 0; i < res.data.profiles.length; i++) {
+
if (!tmpDID.includes(followsDID[i + n])) {
+
unfollowURIs.push(i + n);
+
//await agent.deleteFollow(followRecords[i + n].uri);
+
"Found deleted account: " +
+
followRecords[i + n].value.subject +
+
for (const i of unfollowURIs) {
+
await agent.deleteFollow(followRecords[i].uri);
+
"Unfollowed account: " +
+
followRecords[i].value.subject +
setUnfollowNotice(unfollowNotice() + "Done");
···
+
unfollowBsky(userHandle(), appPassword(), serviceURL(), true)
+
unfollowBsky(userHandle(), appPassword(), serviceURL(), false)