Skip to content

Instantly share code, notes, and snippets.

@krrskl
Last active May 25, 2020
Embed
What would you like to do?
Follow users who have liked an Instagram post
(() => {
let followButtons = [];
const _getUsers = () =>
document.querySelector(".sqdOP.yWX7d._8A5w5[type='button']");
const _getFollowsButtons = () => [
...document.querySelectorAll(".sqdOP.L3NKy.y3zKF"),
];
const _getContainer = () =>
document.querySelector(".Igw0E.IwRSH.eGOV_.vwCYk.i0EQd").children[0];
const _plusOrMinus = () => (Math.random() < 0.5 ? -1 : 1);
const _randomTimeout = () =>
_plusOrMinus() * Math.floor(Math.random() * 500) + 3000;
const _scrollDown = () =>
(_getContainer().scrollTop = _getContainer().scrollHeight);
_getUsers().click();
setTimeout(() => {
followButtons = _getFollowsButtons();
_follow();
}, _randomTimeout());
function _follow() {
try {
if (followButtons.length === 0) {
throw new Error("No hay usuarios.");
}
current = followButtons.shift();
current.click();
const _createTimeOut = () =>
setTimeout(() => _follow(), _randomTimeout());
timeOut = _createTimeOut();
if (followButtons.length === 1) {
clearTimeout(timeOut);
_scrollDown();
setTimeout(() => {
followButtons = _getFollowsButtons();
_createTimeOut();
}, 2000);
}
} catch (err) {
throw new Error("Ha ocurrido un error al dar follow.");
}
}
})();
@krrskl

This comment has been minimized.

Copy link
Owner Author

@krrskl krrskl commented May 24, 2020

For run this code go to https://www.instagram.com/p/{POST_ID}

Important: This code not working in post of a video

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment