Last active
March 31, 2021 08:50
-
-
Save inorganik/0115437eb1a0a829949595c247fe3f07 to your computer and use it in GitHub Desktop.
Smash Medium's clap button the max number of times (50) in 1 second
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// smash Medium's clap button the max number of times | |
function simulateClick(node) { | |
var md = document.createEvent('MouseEvents'); | |
md.initEvent('mousedown', true, false); | |
node.dispatchEvent(md); | |
var mu = document.createEvent('MouseEvents'); | |
mu.initEvent('mouseup', true, false); | |
node.dispatchEvent(mu); | |
} | |
var claps = document.querySelectorAll('.clapButton') | |
var clapCount = 0 | |
var clapper = setInterval(function() { | |
if (clapCount < 50) { | |
simulateClick(claps[0]) | |
clapCount++; | |
} | |
else { | |
clearInterval(clapper) | |
} | |
}, 10); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment