I am writing a web extension, and one task of it is to speed up the login process on a particular page by automatically submitting the credentials if the browser autofills them.
In Firefox I was able to simply use the change
event to detect if text is entered, and by testing whether a type
event also fired I can distinguish browser and user input.
In Chrome, however, I am unable to use these events, because they don't fire until the user clicks somewhere outside the input fields. In some places it is suggested to regularly check the value of the input fields, but that does not work either, they stay empty. I managed to use
document.querySelectorAll('*:-webkit-autofill').length !== 0
to detect whether the browser autofilled the input fields. However, when I then click the submit button from JS, the login fails, because the exposed value of the input fields is still an empty string. I tried clicking onto the background or focusing the submit button from JS, but Chrome does still not fill the input fields if the click wasn't initiated by the user.
So my question is: is there a way to force Chrome to properly fill the input fields, such that the value can be read from JavaScript?