Hello, I am relatively new to JavaScript and am currently attempting to develop a script using Greasemonkey that will automatically fill out a form on a webpage.
Essentially, what I need the script to do is check for a specific error code on the page. If the code exists, I want the script to simply click the "Back" button.
<div>
<div id="registration_error" class="errBlock" style="color:Red;">
<ul><li>Address is required.</li></ul>
</div>
I have attempted several different approaches in my code (even though I am not entirely sure if they are correct), but unfortunately, none of them have yielded success. For example:
if(document.getElementById("registration_error").innerText.Contains("Address is required.")
{
document.getElementsByClassName('btnRegister')[0].click();
}
I also tried variations such as:
if(document.getElementsByClassName('errBlock').innerText.Contains("Address is required")
if ("#registration_error").innerText.Contains("Address is required")
Despite trying numerous combinations within my limited knowledge, I have yet to establish a functional if condition. While the button-clicking aspect works fine, I am struggling with this particular aspect.
Thank you in advance for any assistance or insight provided.