Skip to content

Instantly share code, notes, and snippets.

@mahowa
Created June 26, 2019 15:13
Show Gist options
  • Save mahowa/5b020bbb05350851e4311e3293d2e982 to your computer and use it in GitHub Desktop.
Save mahowa/5b020bbb05350851e4311e3293d2e982 to your computer and use it in GitHub Desktop.
Easily check if adblock is on
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