Skip to content

Instantly share code, notes, and snippets.

@denisemenov
Created October 28, 2017 17:23
Show Gist options
  • Save denisemenov/1cb9fe7412ff5e08b5f8203fa91c4a4c to your computer and use it in GitHub Desktop.
Save denisemenov/1cb9fe7412ff5e08b5f8203fa91c4a4c to your computer and use it in GitHub Desktop.
Instagram Auto Like
function timeOut(min, max) {
return Math.random() * (max - min + 1000) + min;
}
function getHeartElement() {
var knownHeartElementNames = ["coreSpriteHeartOpen", "coreSpriteLikeHeartOpen"];
var i = 0;
for (i = 0; i < knownHeartElementNames.length; i++) {
var heartElement = document.querySelector('.' + knownHeartElementNames[i]);
if (heartElement != undefined) {
break;
}
}
return heartElement;
}
function scrollDown() {
window.scrollTo(0, document.body.scrollHeight);
console.log('Scroll Down');
Go();
}
function clickLikeElement() {
var likeElement = getHeartElement();
if (likeElement !== null) {
likeElement.click();
likeElement.scrollIntoView();
likeCount++;
console.log('Liked ' + likeCount);
Go();
} else {
doNextElement();
}
}
function doNextElement() {
setTimeout(scrollDown, timeOut(1000, 3000));
}
function doLikeElement() {
setTimeout(clickLikeElement, timeOut(2000, 7000));
}
function Go() {
if (likeCount < 1000) {
doLikeElement();
} else {
console.log('Nice! Time for a break.');
}
}
var likeCount = 0;
Go();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment