Created
March 3, 2017 08:42
-
-
Save maztch/0045a104d4ef8b6d4600e50a2e4b644b to your computer and use it in GitHub Desktop.
Detects ads blockers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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