Skip to content

Instantly share code, notes, and snippets.

@sayhicoelho
Created August 27, 2017 23:27
Show Gist options
  • Save sayhicoelho/9f3acc3d4ea57e64a1825faa36270da1 to your computer and use it in GitHub Desktop.
Save sayhicoelho/9f3acc3d4ea57e64a1825faa36270da1 to your computer and use it in GitHub Desktop.
Script para detectar se há AdBlock sendo utilizado pelo seu visitante
window.onload = function () {
var ads = document.querySelectorAll('.adsbygoogle');
var isReal = true;
for (var i = 0; i < ads.length; i++) {
if (ads[i].innerHTML.length === 0) isReal = false; break;
}
if (!isReal) {
document.body.innerHTML = '<div style="text-align: center"><img style="height: 200px;" src="https://i.ytimg.com/vi/kaqSZNE2adM/maxresdefault.jpg" alt="Stop blocking Ads!"/><br/>Oops! Notamos que você está com AdBlock habilitado.<br/>Para acessar nosso site é preciso desabilita-lo.</div>';
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment