Last active
April 4, 2017 16:35
-
-
Save miclaus/46aa156a69b891f6f31d to your computer and use it in GitHub Desktop.
Demonstrates simulated keyup event in vanilla JS. Tested in Chrome.
This file contains hidden or 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
javascript:(function() { | |
var $ = document; | |
/// construct | |
var old_password = window.prompt('Old password', 'Old password'); | |
var new_password = window.prompt('New password', 'New password'); | |
element('old_password').value = old_password; | |
element('new_password').value = new_password; | |
element('new_password_chk').value = new_password; | |
var event = $.createEvent('KeyboardEvent'); | |
event.initEvent('keyup', true, true, window, false, false, false, false, 9, 0); | |
element('old_password').dispatchEvent(event); | |
element('new_password').dispatchEvent(event); | |
element('new_password_chk').dispatchEvent(event); | |
element('submit').click(); | |
/// functions | |
function element(id) { | |
return $.getElementById(id); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment