Created
October 28, 2017 17:24
-
-
Save denisemenov/b46ea56adee60855ca76c047f98c376d to your computer and use it in GitHub Desktop.
Instagram Hashtag or Geotag Autolike
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 clickNextElement() { | |
var nextElement = document.querySelector('.coreSpriteRightPaginationArrow'); | |
nextElement.click(); | |
console.log('Next'); | |
Go(); | |
} | |
function clickLikeElement() { | |
var likeElement = getHeartElement(); | |
if (likeElement !== null) { | |
likeElement.click(); | |
likeCount++; | |
console.log('Liked ' + likeCount); | |
doNextElement(); | |
} else { | |
doNextElement(); | |
} | |
} | |
function doNextElement() { | |
setTimeout(clickNextElement, 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