Skip to content

Instantly share code, notes, and snippets.

@s1n7ax
Created March 22, 2020 10:28
Show Gist options
  • Save s1n7ax/966e98561b4c62c29d1f7b120987cbb7 to your computer and use it in GitHub Desktop.
Save s1n7ax/966e98561b4c62c29d1f7b120987cbb7 to your computer and use it in GitHub Desktop.
// 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