Skip to content

Instantly share code, notes, and snippets.

@reimertz
Created April 24, 2017 06:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save reimertz/56b6ddf93d45a2128c13bc4daa43e488 to your computer and use it in GitHub Desktop.
Save reimertz/56b6ddf93d45a2128c13bc4daa43e488 to your computer and use it in GitHub Desktop.
const selector = '.favorited .ProfileTweet-action--favorite .ProfileTweet-actionButtonUndo'
const generateClickPromise = (el, index) => {
return new Promise((resolve) => {
setTimeout(() => {
el.click()
resolve()
}, index * 200 + 200 * Math.random())
})
}
function unlikeAll() {
const heartElements = Array.from(document.querySelectorAll(selector))
const allHeartsClicked = new Promise.all(heartElements.map(generateClickPromise))
allHeartsClicked.then(() => {
document.querySelector('.stream-items.js-navigable-stream').innerHTML = ''
setTimeout(() => {
window.scrollTo(0, 0)
}, 100 + Math.random() * 100)
setTimeout(() => {
window.scrollTo(0,document.body.scrollHeight)
}, 200 + Math.random() * 100)
setTimeout(unlikeAll, 500 + Math.random() * 1500)
})
}
unlikeAll()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment