Wireless Army
This is a blog / tips and tricks website for web developers and security researchers.
follow us in feedly


detect adblock on your site
by admin
 at 2016-06-06 17:34:00.

since adblock is becoming popular you may not have the same revenue from advertisements as before on your site.
you can add the following code where the adversisement is usually on your website to ask the users to turn off the adblock

var ad = document.querySelector("ins.adsbygoogle");
if
(ad && ad.innerHTML.replace(/\s/g, "").length == 0) {
document.write("<h1>TURN OFF ADBLOCK!</h1>");
}

or make the content on your site unavaible to people with adblock turned on.

var ad = document.querySelector("ins.adsbygoogle");
if
(ad && ad.innerHTML.replace(/\s/g, "").length == 0) {
document.getElementById("wrapper").style.display = "none";
document.write("<h1>TURN OFF ADBLOCK!</h1>");
}