Ad Blocker detection AKA Adblock Plus

前端 未结 15 1353
北海茫月
北海茫月 2020-12-02 06:14

After searching Google and Stackoverflow for a few hours I could not find a solution. What I\'m trying to do is detect Adblock plus and display a simple message for now.

15条回答
  •  情深已故
    2020-12-02 06:21

    The Smartest and easiest way I found is:

    1) add this html code on somewhere in your markup probably on top.

    .

    Usually ad blockers detect ad sizes of (pub_300x250) as mentioned in Easylist and blocked them, which is triggered by "bait".

    2) then add this js code into your script file.

    if (document.getElementById("bait").offsetHeight === 0) {
        // function code or alert (whatever) here.
       alert("Ad-Blocker DETECTED");
    }
    

    Our Script detects if that piece of markup is existed in present html by checking thorugh "bait" id.

    This works for me with Adblock , AdBlock-Plus & uBlock Origin on every site on every browser.

提交回复
热议问题