Skip to content

Instantly share code, notes, and snippets.

@itsmnthn
Last active January 17, 2024 14:37
Show Gist options
  • Save itsmnthn/cc816601a54e92a88337b0c7606abb98 to your computer and use it in GitHub Desktop.
Save itsmnthn/cc816601a54e92a88337b0c7606abb98 to your computer and use it in GitHub Desktop.
Like tweets based on passed intervals, increase the ms amount to slow it down between likes and page scroll
/**
* @author Manthankumar Satani <satanimanthan@gmail.com>
* @version 1.5.0
*/
/** Interval enough to like 6 to 10 post per minute */
const batchInterval = 60000
const random = true
const waitBetweenLikes = true
async function run() {
let likes = 0
async function startLiking() {
/** window.scrollTo(0, height); */
/** height += incrHeight; */
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms))
}
function like(btn) {
btn.scrollIntoView()
btn.click()
likes += 1
}
const likeButtons = document.querySelectorAll('div[data-testid="like"]')
for (const btn of likeButtons) {
/** Randomly like instead of all posts */
if (random) {
if (Math.floor(Math.random() * 2) + 1 === 1)
like(btn)
}
else {
like(btn)
}
if (waitBetweenLikes)
await sleep(Math.floor(Math.random() * 10000))
}
// eslint-disable-next-line no-console
console.log('Liked', likes)
}
startLiking()
setInterval(startLiking, batchInterval)
}
run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment