-
-
Save thoas/a6ba5be3d5b647670c8ff1bb930bdc6e to your computer and use it in GitHub Desktop.
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
import "whatwg-fetch"; | |
const BLOCKER_TEST_URL = | |
"https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"; | |
const detectBlocker = callback => { | |
fetch( | |
new Request(BLOCKER_TEST_URL, { | |
method: "HEAD", | |
mode: "no-cors" | |
}) | |
) | |
.then(function(response) { | |
return response; | |
}) | |
.then(function(res) { | |
callback(false); | |
}) | |
.catch(function(e) { | |
callback(true); | |
}); | |
}; | |
export default detectBlocker; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment