JavaScript Adblock detection js help required - solved

SGT Oddball

Aspirant
Joined
Feb 24, 2010
Messages
34
HI

I've been using the method here + example 1 to measure adblocking with google analytics - http://www.detectadblock.com/

What I'd like to do is modify the example 1 script to load my skimlinks js file if adblock is detected (as skimlinks isn't blocked by adblock plus so at least the blockers are getting something).

So I need to load the external file
Code:
<script type="text/javascript" src="//s.skimresources.com/js/xxxMY-IDxxxxxx.skimlinks.js"></script>


From inside this code when the adblock/yes is detected.
Code:
<script src="/ads.js" type="text/javascript"></script>
<script type="text/javascript">

if(document.getElementById('nhkuFZebDsTB')){
  nhkuFZebDsTB='No';
} else {
  nhkuFZebDsTB='Yes';
}

if(typeof ga !=='undefined'){
  ga('send','event','Blocking Ads',nhkuFZebDsTB,{'nonInteraction':1});
} else if(typeof _gaq !=='undefined'){
  _gaq.push(['_trackEvent','Blocking Ads',nhkuFZebDsTB,undefined,undefined,true]);
}

</script>

I've had a play and google but js really isn't my thing.
 
Last edited:

SGT Oddball

Aspirant
Joined
Feb 24, 2010
Messages
34
I've managed to do it with the help of google and jquery, adblock users now get skimlinks as a replacement for regular ads :D

Code:
<script src="/ads.js" type="text/javascript"></script>
<script type="text/javascript">

if(document.getElementById('nhkuFZebDsTB')){
  nhkuFZebDsTB='No';
} else {
  nhkuFZebDsTB='Yes';
$.getScript('//s.skimresources.com/js/XXXXX-myid-XXXXX.skimlinks.js', function() {
  //script is loaded and executed put your dependent JS here
});
}

if(typeof ga !=='undefined'){
  ga('send','event','Blocking Ads',nhkuFZebDsTB,{'nonInteraction':1});
} else if(typeof _gaq !=='undefined'){
  _gaq.push(['_trackEvent','Blocking Ads',nhkuFZebDsTB,undefined,undefined,true]);

}

</script>
 

mysiteguy

Fanatic
Joined
Feb 20, 2007
Messages
3,619
Site? I'd like to see this in action, because I was under the impression ad blockers blocked Skimlinks/Viglink/Infolinks/Vibrant type of keyword link ads.
 

SGT Oddball

Aspirant
Joined
Feb 24, 2010
Messages
34
It's late on a Saturday night for me with lots of beer :) if you have any questions I'll help tomorrow :)
 

mysiteguy

Fanatic
Joined
Feb 20, 2007
Messages
3,619
I'm going to give this a shot. I've tested it against Ad Block, Ad Block Plus and UBlock. It works against Ad Block Plus but not the other two. But that's better than nothing at all!
 

Alex.

The Ancient Dragon
Joined
Jul 1, 2007
Messages
11,568
Using the site in the original post, it says I'm allowing ads. It shows up with AdBlock Plus and Ad Block. Same with UBlock Origin. I'm using the Reek Killer.

http://reek.github.io/anti-adblock-killer/

Works great on monthly read limits, like on NY Times.
 

mysiteguy

Fanatic
Joined
Feb 20, 2007
Messages
3,619
Hah, Reek Killer doesn't work against my sites. I use random ids to block thieves.
 

Alex.

The Ancient Dragon
Joined
Jul 1, 2007
Messages
11,568
Mind PM'ing me the site? I'm generally curious to see how it is. I don't think I've come across a site that Reek fails at except one, but I couldn't figure out how it was detecting it. Though looking back on it, I believe it was due to Firefox splitting privacy protection and it causing problems. The new baked in feature for Firefox breaks sites and gives false-positives.
 

mysiteguy

Fanatic
Joined
Feb 20, 2007
Messages
3,619
First test run was with Chrome, I installed Ublock.

Since then I've tested against all combinations of Ublock/AdBlock/Adblock Plus and Reek. Took a while to install the filters for each, install each, etc. My notice requesting they turn off their blocker still gets through. And as usual, if you right click it and manually block the notice it will reappear on the next page load. Gotta love the power of random!

No offense, but giving a fox a tour of the hen house isn't in my best interest.
 
Top