Created
July 13, 2018 11:17
-
-
Save hub33k/ffa301ece0e311c5c0bba980bbf13e0c to your computer and use it in GitHub Desktop.
Blocks access to your site until you enable an ad blocker. https://gitgud.io/billyo/Pesky-Adblock
This file contains hidden or 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
// Source: https://gitgud.io/billyo/Pesky-Adblock | |
//Licence: GPL3+ https://www.gnu.org/licenses/gpl.txt | |
//add something to your page that looks like an ad | |
document.body.innerHTML += "<div id='adTeaser' style='width:10px;'></div>" | |
//block usage of the site if the preceeding ad is detected | |
window.setTimeout(function(){ | |
if (document.querySelector('#adTeaser').clientWidth === 10) { | |
plsblock= '<div style="text-align:center;"><span style="font-size: 20px;width: 300px;margin-top: 10%;display: inline-block;">Please turn on your <a href="https://github.com/gorhill/uBlock#ublock-origin">ad blocker</a> to continue browsing this site</span></div>'; | |
document.body.innerHTML=plsblock; | |
} | |
}, 1000) | |
/** just drop this snippet into your web page to get the same effect | |
<div id="adTeaser" style="width:10px;"></div> | |
<script> | |
window.setTimeout(function(){ | |
if (document.querySelector('#adTeaser').clientWidth === 10) { | |
plsblock= '<div style="text-align:center;"><span style="font-size: 20px;width: 300px;margin-top: 10%;display: inline-block;">Please turn on your <a href="https://github.com/gorhill/uBlock#ublock-origin">ad blocker</a> to continue browsing this site</span></div>'; | |
document.body.innerHTML=plsblock; | |
} | |
}, 1000) | |
</script> | |
**/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment