Written by Stoker
This is a little tutorial on how to hide content from users using an ad-blocker to block your ads.
Consider carefully if you want to use it. Because it might piss people off.
I use it here, but it not important to me to please people.
My opinion on this is that Im the Boss here and I decide what content I want to present to my users.
If you want to see the content, you also have to see the ads.
If people get offended by this, its okay for me that they leave and never come back.
Some people will do this. Thats why you should consider carefully to use it.
First example is how I have done it here.
Open styles/prosilver/template/overall_header.html
Find:
Code: Select all
// ]]>
</script>
Code: Select all
function gandalf()
{
if(document.getElementById("gimli").offsetHeight==0)
{
document.getElementById("block-body").innerHTML="<div class='navbar bg1' style='margin-bottom:4px;margin-top:4px;'><div class='inner'><span class='corners-top'><span></span></span><strong style='color: red; padding:12px;'><span style='font-size: 36px;'>Oops, looks like you are blocking our ads!</span><br /><br /><span style='font-size: 18px;'>Thats not a nice thing to do...<br />Please note that functions and access has been removed because you block our ads.<br />Also notice that Donators doesnt see ads or this message.<br /><br />Regards Stoker</span></strong></div><span class='corners-bottom'><span></span></span></div>";
}
}
onload_functions.push('gandalf()');
function steve()
{
document.getElementById('block-body').style.display = "inline";
}
onload_functions.push('steve()');
Find:
Code: Select all
<a name="start_here"></a>
Code: Select all
<noscript>
<div class='navbar bg1' style='text-align:center; margin-bottom:4px;margin-top:4px;'><div class='inner'><span class='corners-top'><span></span></span><strong style='color: red; padding:12px;'><span style='font-size: 20px;'>You need to enable javascript to browse this site</span></strong></div><span class='corners-bottom'><span></span></span></div>
</noscript>
This means that you MUST wrap your ad code in a div with the ID gimli.
Just like this:
Code: Select all
<div id="gimli">
ad code here
</div>
The script will now detect if the height of this div is zero which it will be if you block the ad inside it.
Also we have done the first part ensuring that people doesnt bypass our script by disabling javascript in their browser.
Last step is to decide which content we want to hide for ad-block users.
All we need to do is the wrap the content we want to hide in a div with the correct ID and style.
Just like this:
Code: Select all
<div id="block-body" style="display:none;">
the content you want to hide here
</div>
Second example will display a popup if ads are blocked.
Can be bypassed by disabling javascript.
Open styles/prosilver/template/overall_header.html
Find:
Code: Select all
// ]]>
</script>
Code: Select all
function gandalf()
{
if(document.getElementById("adsense").offsetHeight==0)
{alert("You are blocing our ads!\nNot a nice thing to do...\n\nPlease disable your Ad Blocker!");}
}
onload_functions.push('gandalf()');
Like this:
Just like this:
Code: Select all
<div id="adsense">
ad code here
</div>
Last example can be viewed here: http://antiblock.org/
Its configurable and blocks the view totally.
Can be configured.
Not supported by me. Just wanted to show it to you.