Basically I'm working on a site that has a submit button appear after a form is completed. What I want is to create a function that will automatically click the submit button whenever it appears (there's no choice to go backwards and review work so I don't even know why it's there). I'm already using a userscript with Tampermonkey on chrome for this and want to add this final piece to speed things up a little.
So the code for that particular submit button in the html on this site is:
<form style="width:auto;" id="siteform" action="https://www.example.com" method="post">
<!--
<input type="hidden" id="numTags" name="numTags" value="< %= numTags %>" />
<input type="hidden" id="numMaps" name="numMaps" value="< %= current_map_count %>" />
<input type="hidden" id="numQuestions" name="numQuestions" value="< %= current_question_count %>" />
<input type="hidden" id="challenge" name="challenge" value="< %= challenge %>" />
-->
<input type="hidden" id="assignmentId" name="assignmentId" value="3WSELTNVR4VI8OKXJT4767WDMN3ATT">
<input type="hidden" id="hitId" name="hitId" value="3H1C3QRA01C1P014N961OWQHFGQCEF">
<input type="hidden" id="workerId" name="workerId" value="id1">
<button type="submit">Finished! Click here to submit HIT</button>
</form>
The closest thing I've been able to find to what I need is using the function
if ($(#'element').is(':visible')){}
Although that is in theory what I want, it doesn't work. For instance I've tried
if ($("button[type='submit']").is(':visible')){
$("button[type='submit']").click();
}
With no luck. I'm still really new to javascript and jQuery so it may be that my searches aren't turning anything up because I'm still learning the lingo. Any suggestions? Thanks