Force Ad-Block Disable

Mixed forum with code snippets, guides and styles
Forum rules
Everything in this forum is for everybody
But support only for Donators!
Post Reply
User avatar
Stoker
Site Admin
Site Admin
Posts: 3540
Joined: 12 May 2008, 23:26
BBCodes: 239
Favourite BBCode: Anipro
Favourite MOD: PrettyPhoto
Location: Denmark
Contact:

Force Ad-Block Disable

Post by Stoker »

Force Ad-Block Disable
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>
Before add:

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()');
(You need to edit the message to suit your need)

Find:

Code: Select all

<a name="start_here"></a>
After add:

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>
Now we have set up the first part. A script that detects if a specified ID height is zero, in the case the ID is named gimli.
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>
Remember only to do this with 1 ad!
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>
Add before:

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()');
Now we need to wrap our ad code in a div with a ID called adsense.
Like this:
Just like this:

Code: Select all

<div id="adsense">
						ad code here
						</div>
Remember only to do this with 1 ad!

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.
Board rules! No PM support
User avatar
martin123456
BBCoder VI
BBCoder VI
Posts: 765
Joined: 25 Jul 2011, 13:29
BBCodes: 34
Favourite MOD: Ban button
Location: Down south!
Contact:

Re: Force Ad-Block Disable

Post by martin123456 »

Sir you updating this for 3.1.X at all ?
User avatar
Stoker
Site Admin
Site Admin
Posts: 3540
Joined: 12 May 2008, 23:26
BBCodes: 239
Favourite BBCode: Anipro
Favourite MOD: PrettyPhoto
Location: Denmark
Contact:

Re: Force Ad-Block Disable

Post by Stoker »

When I get back to my pc I can post what I have done here sir ;)
Board rules! No PM support
User avatar
martin123456
BBCoder VI
BBCoder VI
Posts: 765
Joined: 25 Jul 2011, 13:29
BBCodes: 34
Favourite MOD: Ban button
Location: Down south!
Contact:

Re: Force Ad-Block Disable

Post by martin123456 »

Thank you sir i did look at view source and noticed a change.
User avatar
Stoker
Site Admin
Site Admin
Posts: 3540
Joined: 12 May 2008, 23:26
BBCodes: 239
Favourite BBCode: Anipro
Favourite MOD: PrettyPhoto
Location: Denmark
Contact:

Re: Force Ad-Block Disable

Post by Stoker »

Havent had the time yet, but take a look at this if you are really serious about it: https://www.newsquid.com/
Board rules! No PM support
Post Reply