Skip to content

Instantly share code, notes, and snippets.

@todomodo
Last active December 26, 2022 00:36
Show Gist options
  • Save todomodo/bb5da60065fa26dc331a119bfabc714b to your computer and use it in GitHub Desktop.
Save todomodo/bb5da60065fa26dc331a119bfabc714b to your computer and use it in GitHub Desktop.
Fix problem with WF login page not working with pasword manager
// ==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