Last active
December 26, 2022 00:36
-
-
Save todomodo/bb5da60065fa26dc331a119bfabc714b to your computer and use it in GitHub Desktop.
Fix problem with WF login page not working with pasword manager
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
// ==UserScript== | |
// @name wellsfargo_login_fix | |
// @namespace https://gist.github.com/todomodo/ | |
// @description Fix problem with WF login page not working with pasword manager | |
// @include https://connect.secure.wellsfargo.com/auth/login/* | |
// ==/UserScript== | |
// My preferred WF login page does not play nicely with password managers. The page would not | |
// accept pasted passwords unless the user (me) had actually pressed a key inside the password input. | |
// This is lame and needs to change. This script performs said action on document load. It simulates | |
// pressing of [Backspace] inside the password input, thus unlocking it for direct pasting | |
// | |
window.addEventListener('load', function() { | |
elem = document.querySelector('#j_password'); | |
if (elem) { | |
console.log("TODO: #j_password was found"); | |
// implementation based on | |
// https://stackoverflow.com/questions/596481/is-it-possible-to-simulate-key-press-events-programmatically | |
// | |
var todoKeyboardEvent = document.createEvent('KeyboardEvent'); | |
var todoInitMethod = typeof todoKeyboardEvent.initKeyboardEvent !== 'undefined' ? 'initKeyboardEvent' : 'initKeyEvent'; | |
todoKeyboardEvent[todoInitMethod]( | |
'keydown', // event type: keydown, keyup, keypress | |
true, // bubbles | |
true, // cancelable | |
window, // view: should be window | |
false, // ctrlKey | |
false, // altKey | |
false, // shiftKey | |
false, // metaKey | |
8, // KeyCode: BackSpace | |
0, // Unicode Char Code (optional) | |
); | |
elem.dispatchEvent(todoKeyboardEvent); | |
console.log("TODO: [BackSpace] keyboard event dispatched to #j_password"); | |
} else { | |
console.log("TODO: #j_password was not found"); | |
} | |
}, false); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment