Skip to content

Instantly share code, notes, and snippets.

@duydev
Last active August 19, 2021 05:50
Show Gist options
  • Save duydev/c6ae0d0b10219ba9d2a1085d054b27fa to your computer and use it in GitHub Desktop.
Save duydev/c6ae0d0b10219ba9d2a1085d054b27fa to your computer and use it in GitHub Desktop.
Popcat.click
function trigger() {
var keyboardEvent = document.createEvent('KeyboardEvent');
var initMethod =
typeof keyboardEvent.initKeyboardEvent !== 'undefined'
? 'initKeyboardEvent'
: 'initKeyEvent';
keyboardEvent[initMethod](
'keydown', // event type: keydown, keyup, keypress
true, // bubbles
true, // cancelable
window, // view: should be window
false, // ctrlKey
false, // altKey
false, // shiftKey
false, // metaKey
40, // keyCode: unsigned long - the virtual key code, else 0
0 // charCode: unsigned long - the Unicode character associated with the depressed key, else 0
);
document.dispatchEvent(keyboardEvent);
}
function auto() {
Array(799)
.fill()
.forEach(() => trigger());
setTimeout(() => {
auto();
}, 30000);
}
auto();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment