23

For example this one disables function if AdBlock plus is detected, and it works. Is there a way to circumvent this?

33

There are many scripts and projects to help site owners detect AdBlock Plus, but I think you're interested in how they work.

The idea is simple. The website loads a JavaScript file called ads.js (or any other name that AdBlock Plus finds "attractive"), which contains:

var amIHere = document.createElement("div");
amIHere.setAttribute("id", "amIHere");
document.body.appendChild(amIHere); 

If you have AdBlock Plus, then it will block this script from running and the div won't be created. Then they use a normally-named JavaScript file which contains a simple check for the div's existence

if (document.getElementById('amIHere')){
   alert("You're Alright");
}else{
   alert("You're using AdBlock Plus");
}

Other methods is to load a div with the id ads or that has a class text-ads which AdBlock Plus detects as ads and tries to hide, then using JavaScript check if the div is hidden or not.

This will help you detect the majority of AdBlock Plus users, but because of the nature of this problem (everything happens on the client side), in theory, a user is able to circumvent all of your checks and detectors.

As a "power user", when a website I need to use tells me that I have to disable Adblock Plus, I just disable it and enable it after I finish. I don't really want to spend time and resources to find a way around it. So you can assume that the vast majority of your users won't bother. They will be annoyed that you're forcing them to disable it, but they'll either leave your website or just disable AdBlock Plus.

| improve this answer | |
  • About the method to check the div's visibility, ABP seems to be clever enough to hide it and it still returns a display = block. On chrome I get a display = none. Great, thank you. – daVe Oct 15 '15 at 17:40
  • @daVe ABP really is "clever enough to hide it and it still returns a display = block"? – Geremia May 25 '16 at 23:25
  • @Geremia I don't know why. It's maybe a firefox behavior. My solution was to define a var inside ads.js, and check it outside. – daVe May 27 '16 at 8:22

Not the answer you're looking for? Browse other questions tagged or ask your own question.