Question: I would like to be able to detect if the user is using adblocking software when they visit my website. If they are using it, I want to display a message asking them to turn it off in order to support the project, like [this website](http://www.playonlinux.com/en/) does.

If you enter to that site and your browser has some kind of adblock software enabled, then the site instead of showing the actual ads shows a little banner telling the users that the ad revenue is used for hosting the project and they should consider turning Adblock off.

I want to do that on my website, I'm using adsense ads on it, How can I do that?

Answer: 
I know there are already enough answers, but since this question comes up on Google searched for "detect adblock" at the topic, I wanted to provide some insight in case you're **not using adsense**.

Specifically, with this example you can detect if the default Adblock-list provided by Firefox Adblock is used. It takes advantage that in this blocklist there is an element blocked with the CSS id `#bottomAd`. If I include such an element in the page and test for it's height, I know whether adblocking is active or not:

```
<!-- some code before -->
<div id="bottomAd" style="font-size: 2px;">&nbsp;</div>
<!-- some code after -->

```

The rest is done via the usual jQuery suspect:

```
$(document).ready( function() {
  window.setTimeout( function() {
    var bottomad = $('#bottomAd');
    if (bottomad.length == 1) {
      if (bottomad.height() == 0) {
        // adblocker active
      } else {
        // no adblocker
      }
    }      
  }, 1);
}

```

As can be seen, I'm using `setTimeout` with at least a timeout of 1ms. I've tested this on various browsers and most of the time, directly checking for the element in `ready` always returned 0; no matter whether the adblocker was active or not. I was having two ideas about this: either rendering wasn't yet done or Adblock didn't kick in yet. I didn't bother to investigate further.
For me none of the tricks worked, may be I was doing something wrong. but this is a very specific way to implement for **google ads**.

```
window.onload = function() {
   if (document.getElementsByClassName('google-auto-placed').length == 0){
                // Adblock Detected
   }        
}

```

If you have other ad system like amazon, look for their generic class name / ids by inspecting page. 

If you are planing to put this code in seperate .js file make sure file name **does not have "Ad" word in it**. just name it **magic.js**

If Google ever decides to change div name, this method would fail. but that seems unlikely.