Created
June 26, 2019 15:13
-
-
Save mahowa/5b020bbb05350851e4311e3293d2e982 to your computer and use it in GitHub Desktop.
Easily check if adblock is on
This file contains 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
adsBlocked = async () => { | |
const testURL = | |
'https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js'; | |
const myInit = { | |
method: 'HEAD', | |
mode: 'no-cors', | |
}; | |
const myRequest = new Request(testURL, myInit); | |
return await fetch(myRequest) | |
.then(() => false) | |
.catch(() => true); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment