Here's what I ended up doing. Feels reeealy hacky.
in footer.tpl
window.addEventListener('DOMContentLoaded', function () {
$(window).on('action:ajaxify.contentLoaded', function(data) {
// attach to all login/reg buttons except for the login and register buttons on the login page.
$("a[href$='/login'], a[href$='/register']").not('#login').not('#login__no-acct').each(function(i, el){
$(el).off('click').on('click', function(){
window.setCookie('login:referrer', window.location.href, 10);
});
});
});
});
</script>
in profile.tpl
<script>
var referrer = window.getCookie('login:referrer');
if (referrer && window.getCookie('login:shouldRedirect')) {
window.setCookie('login:shouldRedirect', '', 0)
window.setCookie('login:referrer', '', 0)
window.location.href = referrer;
}
</script>
in registerComplete.tpl
<script>
window.setCookie('login:shouldRedirect', 'true', 10);
</script>
...and attaching setCookie/getCookie on window in header.
Probably could do this all with client-side hooks now that I understand them though.