Autosubmit forms by faking an Enter keypress (#55)

This commit is contained in:
Maxim Baz
2019-03-31 01:42:04 +01:00
committed by GitHub
parent 64a8cdd497
commit 995a4c3094
3 changed files with 36 additions and 2 deletions

View File

@@ -136,9 +136,13 @@
* @since 3.0.0
*
* @param object request Form fill request
* @return void
* @return object result of focusing or submitting a form
*/
function focusOrSubmit(request) {
var result = {
needPressEnter: false
};
// get the login form
var loginForm = form();
@@ -167,6 +171,10 @@
}
} else {
// There is no submit button.
if (request.autoSubmit) {
// signal background script that we want it to press Enter for us
result.needPressEnter = true;
}
// We need to keep focus somewhere within the form, so that Enter hopefully submits the form.
var password = find(PASSWORD_FIELDS, loginForm);
if (password) {
@@ -179,6 +187,8 @@
}
}
}
return result;
}
/**