I have web page with such javascript:
<script>
window.onblur = function(){
alert("Don't leave this page");
document.location.href = "show_results.php";
}
var sec = 15;
tim = function(){
sec--;
document.getElementById("mytimer").innerHTML=sec;
if(!sec) document.location.href = "show_results.php";
}
stop_timer=function(){
clearInterval(timer);
}
start_timer=function(){
timer = window.setInterval(tim,1000);
}
</script>
So I allow to watch my page for 15 seconds and I disallow to leave it, but for example, using Tampermonkey, users can redefine my functions. They can write something like:
window.onblur = function(){}
function f(){
sec=16;
setTimeout(f,1000);
}
f();
After that timer breaks and users can leave page. How to protect my page from such actions?
P.S.: This page is a quiz and I don't want to allow users to search a correct answer via Internet.