Skip to content

Instantly share code, notes, and snippets.

@wichaksono
Created March 8, 2019 12:51
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save wichaksono/ce7d020c11df12dcf876827e7aa7232e to your computer and use it in GitHub Desktop.
<script>
document.addEventListener('DOMContentLoaded', init, false);
function init(){
adsBlocked(function(blocked){
if(blocked){
var adblocker = document.getElementById('adblocker-detected');
adblocker.classList.add('show');
}
})
}
function adsBlocked(callback){
var testURL = 'https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js'
var myInit = {
method: 'HEAD',
mode: 'no-cors'
};
var myRequest = new Request(testURL, myInit);
fetch(myRequest).then(function(response) {
return response;
}).then(function(response) {
//console.log(response);
callback(false)
}).catch(function(e){
//console.log(e)
callback(true)
});
}
</script>
<style>
#adblocker-detected {display:none;position: fixed;top: 0px;padding: 10px;background: #2196F3;right: 0;left: 0;text-align: center; color: #fff;font-size: 0.9rem;z-index:9999}
#adblocker-detected.show{display:block; line-height: 50px;}
</style>
<div id="adblocker-detected"><strong>Adblocker Detected : </strong>Dukung ONPHPID dengan menonaktifkan Adblock-mu (^_^) Terima Kasih.
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment