Skip to content

Instantly share code, notes, and snippets.

@nischay876
Created August 11, 2022 03:37
Show Gist options
  • Save nischay876/385b179205d37e54d96907e3e86875a7 to your computer and use it in GitHub Desktop.
Save nischay876/385b179205d37e54d96907e3e86875a7 to your computer and use it in GitHub Desktop.
checkAdblock();async function checkAdblock(){this.appendIframeAds();let e=await this.hasAdblockByIframe();e=e||await this.hasAdblockByScript(),e&&(console.log("Ad blocker is used."),document.write('<head><title>Adblock detecter By https://nischay.ovh</title><link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/nischay876/adblock-detecter/web/main.css"></head><body><div class="wrapper"><img src="https://cdn.jsdelivr.net/gh/nischay876/adblock-detecter/web/abd.png"><p class="detect">Detecting...</p><p class="ad-p">Please wait!</p></br><p class="detect" onclick="window.location.reload()">Refresh Page</p></div><script src="https://cdn.jsdelivr.net/gh/nischay876/adblock-detecter/web/main.js"></script><div id="footer" class="#footer"><strong>Copyright &copy; 2021-2022 <a href="https://github.com/nischay876/adblock-detecter/" target="_blank"> Ad Block Detecter</a></strong> All rights Reserved</b></div></body>'))}async function hasAdblockByScript(){let t=!1;var e={method:"HEAD",mode:"no-cors"};let o=new Request("https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js",e);try{await fetch(o),t=!1}catch(e){t=!0}if(t)return t;o=new Request("https://adblockanalytics.com",e);try{await fetch(o),t=!1}catch(e){t=!0}return t}function hasAdblockByIframe(){return new Promise((o,e)=>{setTimeout(()=>{let e=!1;const t=document.getElementById("ads-text-iframe");"none"!=t.style.display&&"hidden"!=t.style.display&&"hidden"!=t.style.visibility&&0!=t.offsetHeight||(e=!0),t.remove(),o(e)},100)})}function appendIframeAds(){const e=document.createElement("iframe");e.height="1px",e.width="1px",e.id="ads-text-iframe",e.src="https://domain.com/ads.html",document.body.appendChild(e)}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment