Well, it is like Timuks said, if the parent page of a HIT is in focus instead of the frame, it can cause that problem, because it's type is also submit. If you change
Code:
document.querySelector(`[type="submit"]`).click();
to
Code:
document.getElementById("submitButton").click();
It will still submit most HITs, but you won't have that problem anymore.
If you want to make a script that clicks the submit button for no-iframe hits on the woker site, you will need to use
Code:
document.getElementsByClassName("btn btn-primary")[0]
or
Code:
document.getElementsByClassName("btn btn-primary")[1]