Reimplement beforeSubmit, afterSubmit and afterRegisterFeatures hooks

All three were present in pre- but not post-TUX JavaScript. Here, they
are recreated in a backwards-friendly way.

Change-Id: Ieae2148dfe2cd1b2e3005683c6e4b1eec3afb263