Code
Code
t
fetc
hOpt
ions
= {
credentials: "include",
headers: {
"X-IG-App-ID": "936619743392459",
},
method: "GET",
};
let username;
window.alert(
"Hey! You need to be on the instagram site before you run the code.
I'm taking you there now but you're going to have to run the code into
the console again."
);
window.location.href = "https://www.instagram.com";
console.clear();
return;
const WARNING = `
1. We use the Instagram search API with your username to obtain your
User ID, which identifies your account on Instagram.\n
2. We call the 'following' API endpoint with your user ID.\n
This mimics scrolling through your own Instagram following list, with
pauses between requests to avoid looking like a bot.\n
3. We repeat this process for the 'followers' API endpoint, creating
lists of your followers and followings.\n
4. We compare the lists, displaying the difference as 'People who don't
follow you back' and vice versa.\n\n
Now that you know how it works, do you want to continue? (If not, close
this tab.)\n`;
// Sorry I know this is ugly I didn't want to make the file too long
await permission;
document.write("<br/><p color='green;font-weight: bolder;'>Ok, thanks.
Look back at the console to see the output. Refreshing this tab will
also make everything go back to normal.</p>")
return await fn(...args);
// Calls the API recursively until there are no more pages to load
list,
user_id,
count,
next_max_id = ""
) => {
let url =
`https://www.instagram.com/api/v1/friendships/${user_id}/${list}/?count=
${count}`;
if (next_max_id) {
url += `&max_id=${next_max_id}`;
if (data.next_max_id) {
console.log(
await sleep(timeToSleep);
return data.users.concat(
return data.users;
};
const url =
`https://www.instagram.com/api/v1/web/search/topsearch/?context=blended&
query=${lower}&include_reel=false`;
const data = await fetch(url, fetchOptions).then((r) => r.json());
);
return result?.user?.pk || null;
};
username = window.prompt(
if (!user_id) {
follower.username.toLowerCase()
);
followed.username.toLowerCase()
);
console.log(Array(28).fill("-").join(""));
console.log(
`Fetched`,
followerSet.size,
followingSet.size,
" following."
);
console.log(
`If this doesn't seem right then some of the output might be
inaccurate`
);
);
);
return {
PeopleIDontFollowBack,
PeopleNotFollowingMeBack,
};
};
//
// Change this:
username = "example_username";
//
//
//
executeWithNotice(getUserFriendshipStats, username).then(console.log);