Skip to content

Instantly share code, notes, and snippets.

@0x04
Created April 17, 2020 16:13
Show Gist options
  • Save 0x04/f1440ea85aa3cb7c551f148ac9d23630 to your computer and use it in GitHub Desktop.
Save 0x04/f1440ea85aa3cb7c551f148ac9d23630 to your computer and use it in GitHub Desktop.
var hackInput = document.querySelector('#inputfield')
var hackHighlight = null
var hackCurrent = 0
var hackInterval = 0
function hack() {
hackHighlight = document.querySelector('#row1 .highlight')
if (!hackHighlight) {
clearInterval(hackInterval)
return
}
hackType()
}
function hackType() {
var down = new $.Event('keydown')
var up = new $.Event('keyup')
var value = hackHighlight.innerText.slice(0, hackCurrent + 1)
if (hackCurrent < hackHighlight.innerText.length) {
down.which = up.which = hackHighlight.innerText.slice(hackCurrent++, 1)
} else {
down.which = up.which = 32
value += ' '
hackCurrent = 0
}
console.info(value)
$(document).trigger(down)
$(hackInput).val(value)
$(hackInput).trigger(up)
$(document).trigger(up)
}
hackInterval = setInterval(hack, 25)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment