I have a Greasemonkey script that automates inputting user info. But before the form can be submitted, the fields have to be in focus (I think they use AngularJS to verify that a valid name/email has been entered). So in my code I do:
document.getElementById('name').value = "Name here"; //Enter name in field
document.getElementById('name').focus(); //Focus on the field
This works fine but only when the window is active. If the window is not active, it will enter the name but the field will not come to focus (so it cannot be submitted). Is there any modification that can be done to fix this?
Edit: It is hard for me to provide an example because the code has to be run from a window that is not active but here is the code for the input field.
<input id="namefield[name]" name="name" ng-model="nameField.form.name" ng-pattern="nameRegex()" placeholder="John Doe" required="" style="width: 246px" type="text" class="ng-valid-pattern ng-dirty ng-valid ng-valid-required">