Last active
May 7, 2024 10:17
-
-
Save Jeandcc/3c05d6104e94ded9884f4e39880d1be3 to your computer and use it in GitHub Desktop.
Open Instagram on your browser; Login to instagram; Open your browser's console (CTRL + SHIFT + J); Paste the code below; Update the username in the first line; RUN IT (Hit enter)
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
const username = "USER_NAME_HERE"; | |
/** | |
* Initialized like this so typescript can infer the type | |
*/ | |
let followers = [{ username: "", full_name: "" }]; | |
let followings = [{ username: "", full_name: "" }]; | |
let dontFollowMeBack = [{ username: "", full_name: "" }]; | |
let iDontFollowBack = [{ username: "", full_name: "" }]; | |
followers = []; | |
followings = []; | |
dontFollowMeBack = []; | |
iDontFollowBack = []; | |
(async () => { | |
try { | |
console.log(`Process started! Give it a couple of seconds`); | |
const userQueryRes = await fetch( | |
`https://www.instagram.com/web/search/topsearch/?query=${username}` | |
); | |
const userQueryJson = await userQueryRes.json(); | |
const userId = userQueryJson.users[0].user.pk; | |
let after = null; | |
let has_next = true; | |
while (has_next) { | |
await fetch( | |
`https://www.instagram.com/graphql/query/?query_hash=c76146de99bb02f6415203be841dd25a&variables=` + | |
encodeURIComponent( | |
JSON.stringify({ | |
id: userId, | |
include_reel: true, | |
fetch_mutual: true, | |
first: 50, | |
after: after, | |
}) | |
) | |
) | |
.then((res) => res.json()) | |
.then((res) => { | |
has_next = res.data.user.edge_followed_by.page_info.has_next_page; | |
after = res.data.user.edge_followed_by.page_info.end_cursor; | |
followers = followers.concat( | |
res.data.user.edge_followed_by.edges.map(({ node }) => { | |
return { | |
username: node.username, | |
full_name: node.full_name, | |
}; | |
}) | |
); | |
}); | |
} | |
console.log({ followers }); | |
after = null; | |
has_next = true; | |
while (has_next) { | |
await fetch( | |
`https://www.instagram.com/graphql/query/?query_hash=d04b0a864b4b54837c0d870b0e77e076&variables=` + | |
encodeURIComponent( | |
JSON.stringify({ | |
id: userId, | |
include_reel: true, | |
fetch_mutual: true, | |
first: 50, | |
after: after, | |
}) | |
) | |
) | |
.then((res) => res.json()) | |
.then((res) => { | |
has_next = res.data.user.edge_follow.page_info.has_next_page; | |
after = res.data.user.edge_follow.page_info.end_cursor; | |
followings = followings.concat( | |
res.data.user.edge_follow.edges.map(({ node }) => { | |
return { | |
username: node.username, | |
full_name: node.full_name, | |
}; | |
}) | |
); | |
}); | |
} | |
console.log({ followings }); | |
dontFollowMeBack = followings.filter((following) => { | |
return !followers.find( | |
(follower) => follower.username === following.username | |
); | |
}); | |
console.log({ dontFollowMeBack }); | |
iDontFollowBack = followers.filter((follower) => { | |
return !followings.find( | |
(following) => following.username === follower.username | |
); | |
}); | |
console.log({ iDontFollowBack }); | |
console.log( | |
`Process is done: Type 'copy(followers)' or 'copy(followings)' or 'copy(dontFollowBack)' in the console and paste it into a text editor to take a look at it'` | |
); | |
} catch (err) { | |
console.log({ err }); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment