Another possible hacker approach is to throw an error due to a timeout. For this to work, the error must be (a) not caught in the try-catch ; and (b) occur before the timeout has a chance to take actions that you do not like. Depending on the contents of the timeout, this can be easy, difficult or impossible.
For example, if the timeout is registered as follows:
setTimeout(function(){ if(document.URL.toUpperCase() === "..."){
then the only way (I think) that you can throw an error is to secure the String.prototype.toUpperCase function and check if the calling function is a timeout violation. You cannot do this check with absolute certainty, but (new Error).stack will certainly come in handy ... you can compare it with the expected stack trace. You can do similar things with the getter properties of the monkey nail, or perhaps by setting a specific object to undefined . ES6 may provide additional features.
This is clearly hacked, and in fact it does not clear the timeout, it only prevents its observed behavior. However, this can just do the trick! (If performance is important, then be careful with your monkey patches.)
source share