I am writing a chrome extension and I would like to intercept all calls to a form’s submit method, and selectively allow/disallow them.
It appears the form onsubmit event is only fired when a form’s submit button is clicked, and not when submit() is called. So this is not going to help.
I was thinking I could use the form’s prototype to hack my own submit method in there, is that possible?
I don’t know about altering the prototype, but you can definitely overwrite the submit function on the form object itself (this happens often when designers decide to give submit buttons a name=”submit” attribute for no apparent reason).
So, you could just do a node query to find all the forms, and replace each one’s submit property with your own wrapper function.