If you don't use interval timers then disable setInterval function =/UserScript=įor(var i = killId i > 0 i-) clearInterval(i) My approach is to kill all the timers inside the script and it worked for me with Chrome 49 I have in an old VM. The pages you're trying to hook your timer and change the window.onbeforeunload = null are probably also using a timer to set the same event with a very small interval value, even 1 millisecond, so it will be really difficult to override that event when having an other timer with a smaller interval setting it again and again.
Browsers ( Chrome and Firefox at least) have disabled messages from inside onUnload event. The problem relies on onBeforeUnload event.
I assume you're using some older version of Chrome, because this behavior has been removed since Chrome 51.