I didn't say this was impossible, just probably a bad idea. If your application is simple enough for this to work though, go for it.
Patch setTimeout and setInterval. Register a jQuery ajax prefilter that wraps all your ajax callbacks. Patch jQuery's low-level UI event binding function.
And you're done. I've done this in a rather large application. It works fine.
It's times like these when you realize just how flexible JavaScript development can be.
This came from a fairly large library which runs on all manner of third-party sites, many billions of times each month. In that situation trapping and logging all exceptions is very important, and this method has worked reliably for years.