RJM62
Touchdown! Greaser!
- Joined
- Jun 15, 2007
- Messages
- 13,157
- Location
- Upstate New York
- Display Name
Display name:
Geek on the Hill
I know some people here have Web sites, so I wanted to share my latest way to block and/or annoy Adblock Plus / Adblock Latitude users.
All this is a simple PHP script that opens three nested divs with IDs selected from Adblock's "EasyList" subscription. The script should be included in the PHP code at the beginning of the content you want to protect. You will also need to close the divs at an appropriate place on the page.
For example, if you use a common header and footer for all your pages, you may want to insert the script at the end of the header, and three </div>'s at the beginning of the footer. That would allow the header and footer to display, but nothing in between, as long as Adblock is enabled.
Here's a demo page: http://www.rjmsandbox.com/ABP_Blocker/ . Try it with ABP enabled and disabled to see the difference.
Here's the script:
Here's the code for the demo page:
To make it extra annoying, the three div IDs are randomly selected each time the script runs, so every time the user opens another page, he would have to disable the filters all over again (or disable Adblock altogether) in order to see your content.
The IDs are selected from three text files populated with banned IDs selected from EasyList. Look for the entries beginning with ###, copy three handfuls of them to text files, Remove the ###s, and separate the entries with tildes. Then save them as ab1.txt, ab2.txt, and ab3.txt.
Here's one as an example:
You can see the other two example text files here and here. Any handful of banned div IDs from EasyList can be used, however.
Rich
All this is a simple PHP script that opens three nested divs with IDs selected from Adblock's "EasyList" subscription. The script should be included in the PHP code at the beginning of the content you want to protect. You will also need to close the divs at an appropriate place on the page.
For example, if you use a common header and footer for all your pages, you may want to insert the script at the end of the header, and three </div>'s at the beginning of the footer. That would allow the header and footer to display, but nothing in between, as long as Adblock is enabled.
Here's a demo page: http://www.rjmsandbox.com/ABP_Blocker/ . Try it with ABP enabled and disabled to see the difference.
Here's the script:
PHP:
<?php
// first div
$fcontents = join ('', file ('ab1.txt'));
$s_con = split("~",$fcontents);
$div_id = rand(0,(count($s_con)-1));
$output = "<div id=\"" . $s_con[$div_id] . "\">";
$output = str_replace(array("\r\n", "\r", "\n"), "", $output);
echo $output . PHP_EOL;
// second div
$fcontents = join ('', file ('ab2.txt'));
$s_con = split("~",$fcontents);
$div_id = rand(0,(count($s_con)-1));
$output = "<div id=\"" . $s_con[$div_id] . "\">";
$output = str_replace(array("\r\n", "\r", "\n"), "", $output);
echo $output . PHP_EOL;
// third div
$fcontents = join ('', file ('ab3.txt'));
$s_con = split("~",$fcontents);
$div_id = rand(0,(count($s_con)-1));
$output = "<div id=\"" . $s_con[$div_id] . "\">";
$output = str_replace(array("\r\n", "\r", "\n"), "", $output);
echo $output;
?>
HTML:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>PHP Blocker Demo Page</title>
</head>
<body>
<p><strong>Protected Content Follows</strong></p>
<? include("adblock-div-generator.php"); ?>
<p>Velit ullamcorper ut vestibulum porta eros nam gravida a a velit a integer per vestibulum senectus ipsum a feugiat egestas in condimentum integer suscipit adipiscing a nam. A adipiscing tristique mi nullam velit parturient praesent venenatis dictum a condimentum hac parturient proin lacus malesuada morbi habitant eget a condimentum hac nec eu habitant fames condimentum. Consectetur a cum fusce egestas auctor consectetur tortor vestibulum mi scelerisque pharetra turpis vitae quam eros vestibulum nisl. Per natoque tincidunt eu scelerisque eleifend in pretium mi adipiscing leo proin a sed a laoreet mus potenti taciti mus dis cras convallis elementum sociis elit vestibulum lorem praesent.</p>
<p>A interdum fames ipsum vestibulum ut conubia eu ullamcorper duis magnis imperdiet gravida adipiscing commodo tempor velit a orci ullamcorper nunc adipiscing. Parturient consequat non dis sagittis dapibus accumsan per amet habitasse eu a himenaeos a magna neque platea diam. Eget laoreet aptent varius ornare a tempus velit a ligula diam varius tempor quis consectetur. A vestibulum mus dis consectetur mi ullamcorper in at ullamcorper massa laoreet senectus maecenas platea condimentum posuere. Dapibus at a gravida curae dictumst eget enim sit a purus bibendum habitasse imperdiet parturient cum cras a a parturient quis fringilla ac fermentum lacus litora ut cras. Parturient mus suspendisse elit parturient a parturient parturient a pretium vestibulum dolor a id arcu condimentum phasellus per adipiscing massa dignissim adipiscing eros odio a.</p>
<p>Condimentum urna turpis scelerisque nullam venenatis mi rhoncus id parturient habitant morbi sed conubia quam vivamus vestibulum a amet dignissim adipiscing ad in sociis sociosqu non nam. Fringilla quam suspendisse scelerisque magnis a accumsan himenaeos parturient est a at massa a eros id vestibulum aliquam facilisi libero enim parturient mi hac condimentum. Consectetur nam ipsum scelerisque porttitor placerat et vel montes nostra torquent a suspendisse a scelerisque adipiscing aenean id sapien sodales mus parturient. Vestibulum diam adipiscing a a semper leo turpis scelerisque consequat lectus ornare dis ullamcorper adipiscing. Laoreet at sagittis convallis parturient accumsan integer ridiculus volutpat vestibulum odio ante facilisis parturient nisl.</p>
<p>A vestibulum feugiat adipiscing elit felis parturient ante fermentum tellus condimentum cursus morbi eu metus a id facilisis taciti ad a non lacinia accumsan nec at senectus pharetra nibh. A accumsan odio at condimentum viverra quam convallis platea velit lacinia pharetra suspendisse nascetur dignissim velit a per pharetra euismod curabitur commodo.</p>
</div>
</div>
</div>
<p><strong>End of Protected Content</strong></p>
</body>
</html>
The IDs are selected from three text files populated with banned IDs selected from EasyList. Look for the entries beginning with ###, copy three handfuls of them to text files, Remove the ###s, and separate the entries with tildes. Then save them as ab1.txt, ab2.txt, and ab3.txt.
Here's one as an example:
Code:
ContentAd
~
ContentAd1
~
ContentAd2
~
ContentAdPlaceHolder1
~
ContentAdPlaceHolder2
~
ContentAdView
~
ContentAdXXL
~
ContentAdtagRectangle
~
ContentPlaceHolder1_adds
~
ContentPlaceHolder1_advertControl1_advertLink
~
ContentPlaceHolder1_advertControl3_advertLink
~
ContentPolepositionAds_Result
~
ConversationDivAd
~
CornerAd
~
CountdownAdvert
~
DARTad300x250
~
DFM-adPos-bottomline
~
DFPAD_MR
~
DFP_in_article_mpu
~
DFP_top_leaderboard
~
DartAd300x250
~
DartAd990x90
~
DealsPageSideAd
~
DivAd
~
DivAd1
~
DivAd2
~
DivAd3
~
DivAdA
~
DivAdB
~
DivAdC
Rich