1

I was looking for a universal solution for detecting Adblocking not only for Chrome addons but also to detect Firefox private blocking. The only solution that I found was from this website.

I know that this has already been discussed here but that was a long time ago and some scripts are not working anymore or do not work in firefox private browsing.

I have managed to snip a code from the website mentioned above but problem is that I do not fully understand it so was wondering if you guys could help me out.

<script type="text/javascript">
       $(window).load(function() {
         null==document.getElementsByTagName("iframe").item(ga.length-1)&&$("div.login:last").html("<div>message to display if adblock or private browsing is detected</div>")
    }
 );
</script>

I know it is a jQuery and know that is utilising googles "iframe" but the next element, which is ".item(ga.length-1)", I dont understand. Only other thing with "ga" element is from google analytics but Im not sure if its related as javascript and jquery is not something Im completely familiar with.

The other element which is "$("div.login:last").html" I`m suspecting it is calling where to show the message which is in the last div class="login" which is in the ads section on their website.

Any solution that coveres both adblocks and private browsing will be most welcome. Thanks in advance.

Community
  • 1
  • 1

1 Answers1

0

Ok this is awkward of me answering my own question but I have done it. It works and I think "ga" is indeed calling for google analytics tracking or the lack of it which applies to private browsing.

If you want to make it work, you are going to have to download this:

jquery-2.1.1.min.js"

and place it somewhere on your server and call for it in the head tag. Rest is explained above.

May it serve you well.