Last active
December 20, 2021 12:22
-
-
Save lamchau/e66f31bae97ec4fa0a83aca559ea0f36 to your computer and use it in GitHub Desktop.
This file contains 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
const triggerMouseEvent = (node, eventType) => { | |
const clickEvent = document.createEvent('MouseEvents'); | |
clickEvent.initEvent(eventType, true, true); | |
node.dispatchEvent(clickEvent); | |
}; | |
const clapButton = document.querySelector('[aria-label="clap"]').parentNode; | |
const click = button => { | |
triggerMouseEvent(button, 'mousedown'); | |
triggerMouseEvent(button, 'mouseup'); | |
}; | |
// max: 50 claps per medium article | |
for (let i = 0; i < 51; i++) { | |
click(clapButton); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment