Skip to content

Instantly share code, notes, and snippets.

@WisaniShilumani
Created May 22, 2019 20:58
Show Gist options
  • Save WisaniShilumani/1e9e8e627a4689de4374df5b13a0b5ef to your computer and use it in GitHub Desktop.
Save WisaniShilumani/1e9e8e627a4689de4374df5b13a0b5ef to your computer and use it in GitHub Desktop.
const loveAll = () => {
document.querySelectorAll('div[aria-label="Comment"] > div > div > div > ul > li > span a').forEach(element => {
if (element.innerText === 'Like') {
element.addEventListener('mouseover', function() {
console.log('Event triggered');
});
const event = new MouseEvent('mouseover', {
'view': window,
'bubbles': true,
'cancelable': true
});
element.dispatchEvent(event);
}
})
setTimeout(() => {
const loves = document.querySelectorAll('span[aria-label="Love"]')
console.log(`I'm going to love ${loves.length} comments`)
loves.forEach(love => love.click())
}, 2000)
}
var scroller = function(by) {
window.scrollBy(0, by)
}
var startInterval = function(scrollBy, speed, endby) {
var interval = setInterval(() => {
this.scroller(scrollBy)
}, speed*1000)
setTimeout(() => {
clearInterval(interval)
loveAll()
}, endby*1000)
}
startInterval(5000, 0.5, 30)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment