Skip to content

Instantly share code, notes, and snippets.

@thoas

thoas/blocker.js Secret

Created March 16, 2020 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thoas/a6ba5be3d5b647670c8ff1bb930bdc6e to your computer and use it in GitHub Desktop.
Save thoas/a6ba5be3d5b647670c8ff1bb930bdc6e to your computer and use it in GitHub Desktop.
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