Block your ad blockers
October 7, 2009Josh Brown View CommentsSome people place ads on their site to get some unneeded revenue from their visitors. Some cover their site in ads with no reputable content. Some just need to cover their expenses, and in return provide some decent content you may need. That last one is me. I block visitors who block my ads, because I can’t afford to give away my bandwidth for free. It really is a small price to pay… you know, being nothing and all.
Adblock Plus for Firefox has some 58 million downloads with over a half million new downloads per week. That is scary to someone who needs the ad revenue. Now, there are times to block ads. Like when they are over-abundant, intrusive or misleading. Fake Facebook buttons or flashing winner, anyone? But Google’s ads for example, are under strict guidelines to prevent abuse. And some jackass add-on developers even block Google analytics by default. Which, invaluably has helped my clients to target their content and sales to people actually visiting their site. There is a single ad block at the bottom of content pages on this blog, how can that be hurting anyone?
Now, I will tell you how I protect myself from the leeches.
I prefer Google AdSense, it is the most reputable system with the least amount of setup. That is what this system protects, but it can be adapted. Basically, it kicks off a fraction of a second after the page loads and checks to make sure the ad’s iframe is still there. If it isn’t, it temporarily replaces the page’s contents with a notice. If the ad does appear (due to a slow load time), the page contents will reappear. It stores the contents in a JavaScript variable so most power users can’t just unhide the contents. It monitors the ad for about 6 seconds after the page is loaded, just incase. But I can’t take all of the credit, it is based on a post by Sumeet. Instead of redirecting, which can be easily stopped with a mouse click, my method requires disabling JavaScript, hacking the JavaScript or white-listing the site in ad blocker. If they don’t want to pay for my content, they can’t have it. If they hack their way around it, and plan to for each page, hell, they’ve earned it as the vast majority won’t bother.
It is important to note that ad-blocker software may wise up to this. I suggest rearranging the code, changing variable names and nixing mention of “ad” or “block”. This code is open to all, so if you want to protect your content from leeches, feel free to nab it. It is provided AS IS with NO WARRANTY, et cetera.
To use this, place the most valuable block of content into a <div id=”subcontent”> tag. Make sure that the ad is not within that block. Then, paste this code somewhere in your page outside of the div tag as well. I place mine right above the ad. To see this in action, visit this site with an ad blocker. If your ad blocker gets around this, let me know.
<script type="text/javascript">
var checks = 0;
var content = null;
function show_content( show )
{
var content_area = document.getElementById('subcontent')
if ( content_area == null )
return;
if ( show && content != null )
{
content_area.innerHTML = content;
content = null;
}
else if ( !show && content == null )
{
content = content_area.innerHTML;
content_area.innerHTML = "<h2>Ad-blockers</h2><p>This website is supported by ads. If you can not support that, you may " +
"not view the content on this site.<br/><br/>To view the content on this site, please disable your ad-blocker and press the refresh button " +
"on your browser.</p>";
}
}
function check_ads()
{
var blocked = false;
var e = document.getElementsByTagName('iframe');
for (var i = 0; i < e.length; i++)
if ((e[i].src.indexOf("googlesyndication.com") > -1) && (e[i].setAttribute && (e[i].style.visibility == 'hidden' || e[i].style.display == 'none')))
blocked = true;
show_content( e.length > 0 && !blocked );
if ( checks++ < 4 )
setTimeout( 'check_ads()', 100 );
else if ( checks < 30 )
setTimeout( 'check_ads()', 1000 );
}
setTimeout( 'check_ads()', 200 );
</script>
Tags: Advertising, Tricks