Skip to content

Instantly share code, notes, and snippets.

@inorganik
Last active March 31, 2021 08:50
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save inorganik/0115437eb1a0a829949595c247fe3f07 to your computer and use it in GitHub Desktop.
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
// 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