Skip to content

Instantly share code, notes, and snippets.

@pechitook
Created September 24, 2016 16:25
Show Gist options
  • Save pechitook/58600db87205d06ea302cbf7511c9ea1 to your computer and use it in GitHub Desktop.
Save pechitook/58600db87205d06ea302cbf7511c9ea1 to your computer and use it in GitHub Desktop.
Instagram scripts to automate common tasks
clickAndWait = (cb, ms = 2000) => {
setTimeout(cb, ms)
}
openFirstPhoto = () => {
document.querySelectorAll('._nljxa')[0].childNodes[0].childNodes[0].click()
}
likePhoto = () => {
document.querySelectorAll('.coreSpriteHeartOpen')[0].click()
}
nextPhoto = () => {
document.querySelectorAll('.coreSpriteRightPaginationArrow')[0].click()
}
getWaitingTime = (min = 1, max = 5) => (Math.floor(Math.random() * (max - min + 1)) + min) * 1000
// open first photo of desired hashtag and run
startLikingPhotos = () => {
setInterval(() => {
clickAndWait(likePhoto)
clickAndWait(nextPhoto)
}, getWaitingTime())
}
// open the following panel and run
startUnfollowingPeople = () => {
let i = 0
document.querySelectorAll('._aj7mu._r4e4p._95tat._o0442').forEach((button) => {
i++
setTimeout(() => {
button.click()
}, 3000*i)
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment