Results 1 to 3 of 3
  1. #1
    Join Date
    January 17th, 2005
    I just recently became aware that there are software products like NIS that can actually modify the content of my web pages. I have been researching the issue on and have made a few changes to their AdBlock Detection Script so that it can log to a file all page views on your site that have had ads stripped.

    Here's how to do it:

    1. Get the AdBlock Detection Script here.

    2. Use this modified version of their HTML code:
     <!-- start ad-block check -->
    <img src="/banner.gif" width=1 height=1>
    <iframe id="foo" name="foo" style="height: 0px; width: 0px; border: 0px;"></iframe>
    <script language="Javascript">
    // This script is provided by, the full code must accompany the usage of this script.
    // You may change the look and behavior as long
    // as the link to remains intact.
    // uncomment the following line to test. Don't forget to comment the line again before use.
    var AdBlockTest = 0;
    <script language="Javascript" src="/adblock.js"></script>
    <center><span style="font-size: .8em;">This site is supported by advertising. Learn how <a href="">AdBlock software</a> harms webmasters.</span></center>
    <!-- end ad-block check -->

    3. Create a file named foo.php with this as the contents:
    //Code provided by Joe Ernst of
    //Feel free to modify and distribute, but please give credit.
    $timestamp = getdate();
    $handle = fopen("./adblockers.txt", "a"); //MAKE SURE PHP CAN WRITE TO THIS DIRECTORY!!
    fwrite($handle, $timestamp["year"] . "-" . $timestamp["mon"] . "-" . $timestamp["mday"] . " " . $_SERVER["REMOTE_ADDR"]."\n");

    4. Use this modified version of their javascript:
     // File: adblock.js
    // Version: 1.0
    // Distributed by:
    // This file is provided AS-IS and without warranty and is distributed under the GPL.
    // This code may be freely used as long as it remains intact.

    var chip = document.cookie;

    function getCookie(name) {
    var index = chip.indexOf(name + "=");
    if (index == -1) return null;
    index = chip.indexOf("=", index) + 1; // first character
    var endstr = chip.indexOf(";", index);
    if (endstr == -1) endstr = chip.length; // last character
    return unescape(chip.substring(index, endstr));

    function hidediv() {
    if (document.getElementById) {
    document.getElementById('warning').style.visibility = 'hidden';
    document.cookie = "warned=true; PATH=/";

    function clear_cookie(){
    document.cookie = "warned=; PATH=/";

    if (document.getElementById) {
    if (!getCookie("warned")) {
    document.write("<div id=\"warning\" style=\"visibility:hidden; position:absolute; background: #FF6; width:80%; left: 10%; top:50px; padding: 10px 10px 10px 10px; border: 1px solid black; \">");
    document.write("<p>Important: <b>It appears that you are using AdBlocking software.</b></p>");
    document.write("<p>This site is supported by advertising revenue. If you are reading this site without the accompanying advertisments, you are harming the owner who provides this information at signifcant expense. You may, without your knowledge, have software on your computer that deletes ads.");
    document.write(" Or, if you have installed AdBlocking software, you should know that it may block much more than banner ads, rendering some sites unusable.</p>");
    document.write("<p>For more information, <a href=\"\">visit</a>.</p>");
    document.write("<p><div align=center><a href=\"javascript:hidediv()\">Click here to close this notice</a>.<br>");
    document.write("You will not recieve it again during this session (cookies required.)</p></div></div>");

    if (document.images) {
    var currImg;
    var ImgFound = 0;
    var LinkFound = 0;

    //Added by Joe Ernst
    //Use iFrame to send a logging message to the server
    var iFrame = document.getElementById("foo");
    //alert("checking images..");
    for (var d=0; d < document.images.length; ++d) {
    currImg = document.images[d];
    if (currImg.src.indexOf("banner") > -1) {
    ImgFound = 1;

    if (!ImgFound || AdBlockTest) {
    //location = "sorry.html";
    iFrame.src = "foo.php" //Added by Joe Ernst - foo.php logs this request on the server
    document.getElementById('warning').style.visibility = 'visible';


    Let the code run for a while and check the log file to see how many page views you have had stripped. I'll post my results here after it runs for a few days.

  2. #2
    Member Azam's Avatar
    Join Date
    January 18th, 2005
    Bloomsbury, London
    "I'll post my results here after it runs for a few days."

    Do you have any results yet?

    Thanks very much

  3. #3
    Join Date
    January 17th, 2005
    Things don't seem to be as bad as I had feared. For the week of September 5-11, I had a total of 249 page views with ads removed. That is less than 1% of my total traffic.

    I would be interested to hear from others.


  4. Newsletter Signup

+ Reply to Thread

Similar Threads

  1. Ad Blocker Detection Script
    By Kellie aka Ms. B in forum Midnight Cafe'
    Replies: 0
    Last Post: September 10th, 2003, 12:47 PM
  2. Detection script + Aluria Spware Eliminator?
    By Dynamoo in forum Suspicious Activity!
    Replies: 9
    Last Post: August 22nd, 2003, 11:05 AM
  3. Is there a When U detection Script
    By canfree in forum WhenU
    Replies: 12
    Last Post: August 26th, 2002, 09:04 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts