JS

WAYS TO DETECT ADBLOCKER IN JAVASCRIPT

GOOGLE ADSENSE (HEADERS ONLY) let test = new Request(   "https://pagead2.googlesyndication.com/   pagead/js/adsbygoogle.js",   { method: "HEAD", mode: "no-cors" } );

LOAD AD LIBRARY

01

TEST REQUEST fetch(test) .then((res) => { ALLOWED }) .catch((er)r => { BLOCKED });

"INVISIBLE" DUMMY AD <div class="ad-banner" id="ad-test" style="height: 1px; width: 1px;"></div>

CHECK IF DUMMY AD REMOVED var test = document.getElementById ("ad-test");    if (check.clientHeight == 0) { BLOCKED } else { ALLOWED }

INSERT DUMMY AD

02

SET "BLOCKED" STATUS <script>var blocked = true;</script> THIS WILL SET TO "UNBLOCKED" IF ALLOWED TO LOAD. N MY-ADS.JS - BLOCKED = FALSE; <script src="my-ads.js"></script>

LOAD DUMMY AD LIBRARY

03

RESULT <script> if (blocked) { BLOCKED } else { ALLOWED } </script>

if (typeof blockAdBlock === "undefined") {   LIBRARY CANNOT LOAD, ASSUME   ADBLOCK IN PLACE } else {   blockAdBlock.onDetected(() =>   { BLOCKED });   blockAdBlock.onNotDetected(() =>   { ALLOWED }); }

ADBLOCK DETECT LIBRARY

04