0% found this document useful (0 votes)
41 views2 pages

Message

The document is a JavaScript code snippet that retrieves a user's Instagram followers and following lists using Instagram's API. It identifies users who do not follow back and copies their usernames to the clipboard. The code includes error handling for JSON parsing and logs relevant information to the console.

Uploaded by

lucacettolin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views2 pages

Message

The document is a JavaScript code snippet that retrieves a user's Instagram followers and following lists using Instagram's API. It identifies users who do not follow back and copies their usernames to the clipboard. The code includes error handling for JSON parsing and logs relevant information to the console.

Uploaded by

lucacettolin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

(async () => {

const username = "Luca_cettolin"; // tu user fijo

// 1. Buscar userId de tu perfil


const profileRes = await
fetch(`https://i.instagram.com/api/v1/users/web_profile_info/?username=$
{username}`, {
headers: {
"x-ig-app-id": "936619743392459" // App ID pública de Instagram Web
},
credentials: "include"
});

const text = await profileRes.text();


let profileData;
try {
profileData = JSON.parse(text);
} catch (e) {
console.error("⚠️ No pude parsear JSON. Respuesta fue:", text);
alert("Error al obtener tu perfil. Mirá la consola.");
return;
}

const userId = profileData.data.user.id;


console.log("✅ Tu userId es:", userId);

// 2. Función genérica para traer listas


async function getUsers(hash, edge) {
let users = [], endCursor = null, hasNextPage = true;
while (hasNextPage) {
const url = `https://www.instagram.com/graphql/query/?query_hash=$
{hash}&variables=${encodeURIComponent(JSON.stringify({
id: userId,
include_reel: true,
fetch_mutual: true,
first: 50,
after: endCursor
}))}`;
const res = await fetch(url, { credentials: "include" });
const txt = await res.text();
let data;
try {
data = JSON.parse(txt);
} catch {
console.error("⚠️ No pude parsear JSON en getUsers. Respuesta fue:", txt);
break;
}
const edgeObj = data.data.user[edge];
users = users.concat(edgeObj.edges.map(e => e.node));
hasNextPage = edgeObj.page_info.has_next_page;
endCursor = edgeObj.page_info.end_cursor;
}
return users;
}

// 3. Obtener seguidos/seguidores
console.log("⏳ Obteniendo seguidos...");
const following = await getUsers("3dec7e2c57367ef3da3d987d89f9dbc8",
"edge_follow");
console.log("⏳ Obteniendo seguidores...");
const followers = await getUsers("c76146de99bb02f6415203be841dd25a",
"edge_followed_by");

// 4. Comparar
const followersSet = new Set(followers.map(u => u.username));
const notFollowingBack = following.filter(u => !followersSet.has(u.username));

console.log("🚫 Usuarios que NO te siguen de vuelta:");


console.table(notFollowingBack.map(u => ({ username: u.username, full_name:
u.full_name })));

const list = notFollowingBack.map(u => u.username).join("\n");


await navigator.clipboard.writeText(list);
alert(`✅ ${notFollowingBack.length} usuarios no te siguen. Lista copiada al
portapapeles.`);
})();

You might also like