We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
const adsEnabled = async () => { let ads = true; try { const url = `https://ads.google.com?=${new Date().getTime()}`; await fetch(url, { mode: "no-cors" }); } catch (error) { if (error.message === "Failed to fetch") { ads = false; } } return ads; }; // check const isAdEnabled = await adsEnabled(); console.log(isAdEnabled);
The text was updated successfully, but these errors were encountered:
This doesn't work on firefox. Here's a minimal fix:
if (error.message === 'Failed to fetch' || error.message === 'NetworkError when attempting to fetch resource.') { adBlocked = true; }
Sorry, something went wrong.
Even simpler soultion
<script src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <script> $('#test').append(window.adsbygoogle?.loaded ? 'Ads not blocked' : 'Ads blocked'); </script>
Note: This method is a little heavy handed and actually requires the user to completely disable adblock, or not have it installed.
No branches or pull requests
The text was updated successfully, but these errors were encountered: