add variable to url after ad blocking detected
Hello all I am in need of help. Javascript is not my strong suit so I am asking my first of many questions on this board, so please be gentle with me:)
Okay here is the problem. After a lot of goggling and piecing code together I have the following below that somewhat works. What it does is detect when an ad blocker is active and then refreshes the page and adds a variable to the end of the active page url after detection. However, the issue I am running into is that is will not stop refreshing the page and adding the variable to the end of the url. I need it to refresh once and add the variable to the end of the url. Any help you can give will be greatly appreciated.
PHP Code:
<script type="text/javascript">
window.onload = function() {
setTimeout(function() {
var url = window.location.href;
if (typeof(window.google_jobrunner) === "undefined") {
window.location.href = window.location.href + "&fkdk"
} else {
console.log("no ad blocking found.");
}
}, 10000);
};
</script>