Ad Blocker detection AKA Adblock Plus

You don’t need to have a plugin to detect adblock, simply use this:

<script type="text/javascript">
    var adblock = true;
</script>
<script type="text/javascript" src="https://stackoverflow.com/questions/18180598/adframe.js"></script>
<script type="text/javascript">
    if(adblock) {
          //adblock is installed and enabled on this site :-D
    }
</script>

Content of adframe.js:

adblock = false;

Update:
Adblock Plus blocks certain requests or hides certain elements based on patterns it already has. One of those patterns is this (in patterns.ini):

[Filter]
text=/adframe.
hitCount=843
lastHit=1456391595626

which blocks any URL that has /adframe. in it.

Update 25th august 2018

Adblock plus has changed the way it finds the list and blocks the ads. It has bunch of lists called subscriptions which are used for blocking. For example this one which is the default one:

https://easylist-downloads.adblockplus.org/easylist.txt

You can use the rules on this file to find a file name to use. For example you can use seo-ads.js

P.S for developers: For some reason I couldn’t get ABP to block these files on local environment.

P.S: ABP is my favorite ad blocker 😀

Leave a Comment

tech