views:

25

answers:

0

I got this ad blocking code from http://adblockdetector.com/

(function () {
var _ab = false;
var _af = undefined;
var _am = undefined;

function detect_ab() {
    _af = document.createElement("IFRAME");
    _am = document.createElement("IMG");
    _af.id = '_afd';
    _af.src = '/adimages/';
    _af.style.display = 'block';
    _af.style.border = 'none';
    _am.id = '_amd';
    _am.src = '/adimages/textlink-ads.jpg';
    _am.style.width = _af.style.width = '1px';
    _am.style.height = _af.style.height = '1px';
    _am.style.top = _af.style.top = '-1000px';
    _am.style.left = _af.style.left = '-1000px';
    document.body.appendChild(_af);
    document.body.appendChild(_am);
    setTimeout(_ss, 100)
};

function _ss() {
    if (document.getElementById('_amd').style.display.indexOf('none') > -1) _ab = true;
    else if (document.getElementById('_afd').style.visibility == 'hidden') _ab = true;
    else if (document.getElementById('_afd').clientHeight == 0) _ab = true;
    _af.parentNode.removeChild(_af);
    _am.parentNode.removeChild(_am);
    if (typeof(_abdStatusFnc) != 'undefined') eval(_abdStatusFnc + '(' + _ab + ');');
    else {
        if ((_ab == true) && (typeof(_abdDetectedFnc) != 'undefined')) eval(_abdDetectedFnc + '();');
        if ((_ab == false) && (typeof(_abdNotDetectedFnc) != 'undefined')) eval(_abdNotDetectedFnc + '();')
    }
};
detect_ab()})();

I have attempted to convert it to jQuery but I'm guessing there is more I should be doing

$(document).ready(function() {
var _ab = false;
var _af = undefined;
var _am = undefined;

function detect_ab() {
    $(document.body).append('<IFRAME/>')
      .attr({'id':'_afd','src':'/adimages/'})
      .css({'display':'block','border':'none','top':'-1000px','left':'-1000px'};
    $(document.body).append('<IFRAME/>')
      .attr({'id':'_amd','src':'/adimages/textlink-ads.jpg')
      .css({'width':'1px','height':'1px','top':'-1000px','left':'-1000px'};
    setTimeout(_ss, 100)
};

function _ss() {
    if ($('#_amd').style.display.indexOf('none') > -1) _ab = true;
    else if ($('#_afd').style.visibility == 'hidden') _ab = true;
    else if ($('#_afd').clientHeight == 0) _ab = true;
    $('#_afd').remove();
    $('#_amd').remove();
    if (typeof(_abdStatusFnc) != 'undefined') eval(_abdStatusFnc + '(' + _ab + ');');
    else {
        if ((_ab == true) && (typeof(_abdDetectedFnc) != 'undefined')) eval(_abdDetectedFnc + '();');
        if ((_ab == false) && (typeof(_abdNotDetectedFnc) != 'undefined')) eval(_abdNotDetectedFnc + '();')
    }
};
detect_ab()})();

I'm just planning on using this because I'm curious who is using adblock and not actually do anything on the detection