Reputation:
I see a lot of posts on how to detect AdBlock/AdBlockPlus but none on uBlock Origin.
Is there a way to detect this Adblocker?
I tried getting a script that was blocked (CoinHive) and trying to check if CoinHive (Class) is undefined. This doesnt seem to work as it didnt actually block the script but instead blocked the CoinHive Websocket Connection.
Upvotes: 4
Views: 4352
Reputation: 77
It works for me.
function uBlockActive(){
if ( window.adsbygoogle.push.length > 0) {
return false
}
return true;
}
Upvotes: 0
Reputation: 63
the uBlock filters
list currently includes a filter that is not found in other ad blockers.
HTML elements of the class name adholder2
are cosmetically hidden with the default settings. I'm using this solution to suggest my visitors to use uBlock origin in case they are using something else.
Most ad blockers I checked have their own lists with their own unique rules.
Upvotes: 1
Reputation: 1842
I would just check to see if your ads are loaded. easiest way to do that is have a container element with no set width, then just check that it is greater than or equal to a size smaller than your ads...
function uBlockActive(expected_width){
if ( $('.ad_container').width < expected_width) ) {
return false
}
return true;
}
Edit:
I also found this:
$.ajax('showads.js')
.fail(function(d){
debugger //do some stuff here
});
Upvotes: 7