Skip to content

Instantly share code, notes, and snippets.

@lamchau
Last active December 20, 2021 12:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lamchau/e66f31bae97ec4fa0a83aca559ea0f36 to your computer and use it in GitHub Desktop.
Save lamchau/e66f31bae97ec4fa0a83aca559ea0f36 to your computer and use it in GitHub Desktop.
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