Skip to content

Instantly share code, notes, and snippets.

@krrskl
Last active May 25, 2020 18:41
Show Gist options
  • Save krrskl/1dff65bd971c7af6efd9ef6e262d4200 to your computer and use it in GitHub Desktop.
Save krrskl/1dff65bd971c7af6efd9ef6e262d4200 to your computer and use it in GitHub Desktop.
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
Copy link
Author

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