I'm trying to write a greasemonkey script that autofills ESXi login web page with credentials. The following code fills the input fields and enables the submit button:
// ==UserScript==
// @name ESXi autofill credentials
// @namespace https://esx_address/ui/*
// @version 0.1
// @description Autofills user and password inputs
// @author Mirek
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// @require https://gist.github.com/raw/2625891/waitForKeyElements.js
// @match https://esx_address/ui/*
// @grant none
// ==/UserScript==
try {
waitForKeyElements ("#password", function(jNode) {jNode.val("password");});
waitForKeyElements ("#username", function(jNode) {jNode.val("user");});
waitForKeyElements ("#submit", function(jNode) {jNode.prop("disabled", false);});
} catch(err) {
console.log("Something went wrong: " + err.message);
}
Unfortunately, after I click the submit button I see Cannot complete login due to an incorrect user name or password.
even though the credentials are correct.
The issue is probably with the submit button enabling. The login page enables it once the user types something into username field. Unfortunately, the script doesn't trigger this behavior. I found out that with the script enabled, when I go to the login page and re-type the last letters of username and password fields, the login succeeds.
How could I fill the input fields in a way that will trigger the submit button to turn on?