Skip to content

Instantly share code, notes, and snippets.

@dterracino
Forked from maztch/ads_block_detect.js
Created January 29, 2020 06:59
Show Gist options
  • Save dterracino/43a14c9cdb119d4efdf15f00c20dd01e to your computer and use it in GitHub Desktop.
Save dterracino/43a14c9cdb119d4efdf15f00c20dd01e to your computer and use it in GitHub Desktop.
Detects ads blockers
var adBlockEnabled = false;
var testAd = document.createElement('div');
testAd.innerHTML = ' ';
testAd.className = 'adsbox';
document.body.appendChild(testAd);
window.setTimeout(function() {
if (testAd.offsetHeight === 0) {
adBlockEnabled = true;
}
testAd.remove();
console.log('AdBlock Enabled? ', adBlockEnabled)
}, 100);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment