Created
March 22, 2020 10:28
-
-
Save s1n7ax/966e98561b4c62c29d1f7b120987cbb7 to your computer and use it in GitHub Desktop.
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
// promisified setTimeout | |
const wait = async time => { | |
return new Promise(res => { | |
setTimeout(res, time); | |
}); | |
}; | |
// return random number in given min max range | |
const getRandomNumber = (min, max) => { | |
return Math.floor(Math.random() * (max - min + 1) + min); | |
}; | |
const clickOnLikeButtons = async () => { | |
while (true) { | |
const button = document.querySelector( | |
'div[aria-label="Like"] span > img' | |
); | |
button.scrollIntoViewIfNeeded(); | |
button.click(); | |
// wait 1 to 5 seconds randomly and click the like button | |
await wait(getRandomNumber(1, 5) * 1000); | |
} | |
}; | |
// reload the page to stop | |
clickOnLikeButtons(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment