I'm trying to write a very simple auto-refreshing userscript that immediately stops refreshing when the page is clicked anywhere. I have absolutely no coding experience so help would be greatly appreciated.

```
var cancelled = false;
document.body.addEventListener("click",function(){cancelled=true;});
function goodluck() {
if (cancelled=false) {
      setTimeout(function(){ location.reload(); }, Math.floor(Math.random() * 4000));}
else if (cancelled=true) {return;}
}

```