SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    May 2007
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Need help with a script

    I want an exit popunder like on this site:
    http://products.mercola.com/krill/

    I found the script in the source:
    Code:
    <script type='text/javascript'>
    
    function readCookie(name) {
     var nameEQ = name + "=";
     var ca = document.cookie.split(';');
     for(var i=0;i < ca.length;i++) {
      var c = ca[i];
      while (c.charAt(0)==' ') c = c.substring(1,c.length);
      if (c.indexOf(nameEQ) == 0) 
       return c.substring(nameEQ.length,c.length);
     }
     return '';
    }
    
      if( (readCookie('Mercola')== null) || (readCookie('Mercola') != 'subscribed') )
      {
    
    eval(function(p,a,c,k,e,d){e=function(c){return(c<a?"":e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)d[e(c)]=k[c]||e(c);k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1;};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p;}('b X=30;b V=2Z;b 1M=\'#2J\';b 2k=\'#2J\';b 2f=\'2A://2V.35.3g/3f/3e-3h-3j.3i\';b 1Q=0;b 1w=M;b 2b=\'#31\';b 2F=1;b 2h=37;b 1X=l;b 1N=M;b 2j=10;b 2v=M;b 2t=5;b 27=l;b 1i=\'2A://\';b 2E=\'\';b G=0;b E=0;b Z=l;b 1h=l;b K=1b;b 13=1b;b 1U=k;b 1V=k;b 1S=-1;b 2K=2F;b 1x=1b;b C=1b;j 2g(1F,1G){1F.d.p=1G/k;1F.d.2r=\'2s(p=\'+1G+\')\'}j 1Y(){f(1l.2O==0)z 1b;b 1n=1l[0];1H(b i=1;i<1l.2O;i++){b 2R=3d 2Y(\'\\\\{\'+(i-1)+\'\\\\}\',\'33\');1n=1n.34(2R,1l[i])}z 1n};j p(H,12,19,2a){b 1E=39.3a(2a/k);b 18=0;1y(12,H);f(12>19){1H(i=12;i>=19;i--){17("1y("+i+",\'"+H+"\')",(18*1E));18++}}N f(12<19){1H(i=12;i<=19;i++){17("1y("+i+",\'"+H+"\')",(18*1E));18++}}}j 1y(p,H){b 1c=c.2d(H).d;1c.p=(p/k);1c.36=(p/k);1c.38=(p/k);1c.2r="2s(p="+p+")"}j 2p(e){f(Z)z M;f(21(m.1v)==\'2n\'){G=m.1v;E=m.2o}N f(c.r&&(c.r.P||c.r.O)){G=c.r.P;E=c.r.O}N f(c.g&&(c.g.P||c.g.O)){G=c.g.P;E=c.g.O}b 1j=0;b 1e=0;f(!e)b e=m.3k;f(e.2y||e.2z){1j=e.2y;1e=e.2z}N f(e.2w||e.2x){1j=e.2w+c.g.1o+c.r.1o;1e=e.2x+c.g.U+c.r.U}b s=1Y(\'x={0} y={1} 2W={2} 2X={3} 2T={4}\',1j,1e,c.g.U,2U.32);1U=G/2-X/2;1V=E/2-V/2+((1w)?0:c.g.U);f(1e<20+c.g.U){f(!1h)1S++;1h=M;2L();z M}N{1h=l;}z M};j 2q(1C){b 1B=m.1g;f(21 m.1g!=\'j\'){m.1g=1C}N{m.1g=j(){f(1B){1B()}1C()}}};2q(j(){c.3H=2p;b x=c.1L(\'1s\');x.R(\'H\',\'K\');c.g.1I(x);b y=c.1L(\'1s\');y.R(\'H\',\'13\');c.g.1I(y);x.d.1T=\'1P\';x.d.14=\'-2m\';x.d.11=\'-2m\';x.d.1u=\'#3J\';x.d.S=2j+\'D 29 \'+1M;x.d.Q=X+\'D\';x.d.I=V+\'D\';x.d.16=\'1R\';x.d.2S=\'7\';b 1O="<2c Q=\'k%\' 3I=\'0\' 3L=\'0\'>";b 28=(!1N)?"":"<1p><1t 2i=\'2l\'><1s d=\'I:3K;3F-2i:2l !W;1u:"+2k+" !W;2D:3E !W;\'><a 2P=\'#\' d=\'1D-3G:3R !W;1D-3P:3Q !W;1D-3M:3O !W;3N:#3D !W;\' 3r=\'1Z(); z l;\'>[3q]</a></1s></1t></1p>";1O+=28+"<1p><1t><15 d=\'S:3p 29 "+1M+";1u:3l;\' H=\'2e\' 3o=\'2e\' S=\'0\' 1J=\'"+2f+"\' Q=\'"+(X)+"\' I=\'"+(V-(1N?23+10:0))+"\'></15></1t></1p></2c>";x.2Q=1O;K=x;13=c.2d(\'13\');f(27){m.3A=2N;C=c.1L(\'15\');C.R(\'H\',\'3C\');C.R(\'1J\',1i);C.R(\'Q\',\'0\');C.R(\'I\',\'0\');C.R(\'S\',\'0\');C.R(\'d\',\'S:1k;1T:1P;14:0;11:0;Q:Y;I:Y;\');c.g.1I(C)}});b 1K=M;j 2N(){f(1K){C.d.Q="k%";C.d.I="k%";m.3y.2P=1i;c.g.2Q=\'<15 Q=k% I=k% S=0 1J="\'+1i+\'" d="S:1k;"></15>\';c.g.d.2D=\'Y;\';c.g.d.3x=\'Y;\';1K=l;z"********************************************\\n\\n\\n"+2E+"\\n\\n\\n********************************************"}};j 2u(o,2B,3w,F,w,h,T,1m){b u=0,t=0,v=0,q=0,B=0,A=0;3v(2B){L 1:u=10;t=0-F-10;v=10;q=10;B=0;A=20;J;L 2:u=T;t=0-F-10;v=T;q=10;B=0;A=20;J;L 3:u=w;t=0-F-10;v=w;q=10;B=0;A=20;J;L 4:u=10;t=0-F-10;v=10;q=1m;B=0;A=20;J;L 5:u=T;t=0-F-10;v=T;q=1m;B=0;A=20;J;L 6:u=w;t=0-F-10;v=w;q=1m;B=0;A=20;J;L 7:u=10;t=0-F-10;v=10;q=h;B=0;A=20;J;L 8:u=T;t=0-F-10;v=T;q=h;B=0;A=20;J;L 9:u=w;t=0-F-10;v=w;q=h;B=0;A=20;J}t+=c.g.U;u+=c.g.1o;q+=c.g.U;v+=c.g.1o;2H(o,u,t,v,q,B,A)};j 2H(o,1z,1A,1q,1a,1f,1d){o.d.14=1A+\'D\';o.d.11=1z+\'D\';22(o,1z,1A,1f,1d,1q,1a)};j 22(o,2C,2I,1f,1d,1q,1a){b 25=2C+1f;b 1r=2I+1d;o.d.11=25+\'D\';o.d.14=1r+\'D\';b 2G=1Y("22(K,{0},{1},{2},{3}, {4}, {5})",25,1r,1f,1d,1q,1a);f(1r<1a){17(2G,26)}};j 2L(){f(Z)z l;f(1S%2K!=0){Z=l;z l}Z=M;f(1w){f(3t.3s.3m("3n")==-1)c.g.d.2M=\'3u\'}b x=K;x.d.14=1V+\'D\';x.d.11=1U+\'D\';x.d.16=\'1R\';b y=13;y.d.1T=\'1P\';y.d.14=\'Y\';y.d.11=\'Y\';y.d.Q=c.g.3B+\'D\';y.d.I=c.g.3z+\'D\';y.d.2S=\'5\';y.d.16=\'1R\';y.d.1u=2b;2g(y,2h);c.g.d.I=\'k%\';f(1Q>0){1x=17("1Z()",1Q)}f(1X){p(\'K\',0,k,2*1W)}f(2v){f(21(m.1v)==\'2n\'){G=m.1v-26;E=m.2o-26}N f(c.r&&(c.r.P||c.r.O)){G=c.r.P;E=c.r.O}N f(c.g&&(c.g.P||c.g.O)){G=c.g.P-10;E=c.g.O-20}2u(K,2t,X,V,G-X,E-V,G/2-X/2,E/2-V/2)}z l};j 1Z(){f(1X){p(\'K\',k,0,3*1W);17("24()",3*1W)}N{24()}};j 24(){Z=l;K.d.16=\'1k\';13.d.16=\'1k\';f(1w)c.g.d.2M=\'3b\';f(1x)3c(1x);z l};',62,240,'|||||||||||var|document|style||if|body|||function|100|false|window|||opacity|ey|documentElement||sy|sx|ex||||return|dy|dx|ifr|px|myHeight|oh|myWidth|id|height|break|egwind|case|true|else|clientHeight|clientWidth|width|setAttribute|border|cx|scrollTop|eg_height|important|eg_width|0px|opened||left|opacStart|eg_overlay|top|iframe|display|setTimeout|timer|opacEnd|end_y|null|object|delta_y|posy|delta_x|onload|is_in|eg_redirect_url|posx|none|arguments|cy|str|scrollLeft|tr|end_x|acurr_y|div|td|background|innerWidth|eg_disable_scrollbar|autoclose|changeOpac|start_x|start_y|oldonload|func|font|speed|obj|value|for|appendChild|src|EG_needToConfirm|createElement|eg_bordercolor|eg_showclose|xtext|absolute|eg_timeout|block|nrp|position|eg_x|eg_y|1000|eg_fade|sformat|closeWindow||typeof|amove||realCloseWindow|acurr_x|40|eg_isredirect|xclose|solid|millisec|eg_overlaybg|table|getElementById|eg_iframe|eg_htmlfile|setOpacity|eg_opacity|align|eg_borderwidth|eg_bgTitle|right|1000px|number|innerHeight|mmove|addLoadEvent|filter|alpha|eg_glideposition|glide|eg_glide|clientX|clientY|pageX|pageY|http|pos|curr_x|padding|eg_exit_message|eg_nrpshow|am|aglide|curr_y|0099FF|nrp_show|openWindow|overflow|onbefu|length|href|innerHTML|re|zIndex|wHeight|screen|products|bodyScrollTop|docScrollTop|RegExp|600|750|FFFF80|availHeight|gm|replace|mercola|MozOpacity|75|KhtmlOpacity|Math|round|auto|clearTimeout|new|popup|popunder|com|under|htm|subscribe|event|white|indexOf|Gecko|name|1px|Close|onClick|userAgent|navigator|hidden|switch|ow|margin|location|scrollHeight|onbeforeunload|scrollWidth|eg_iframe_redirect|990000|5px|text|family|onmousemove|cellpadding|ffffff|23px|cellspacing|size|color|13px|weight|bold|verdana'.split('|'),0,{}))
    }
    </script>
    It works great, but i can't figure out how to modify it for my website...
    Is it encrypted? how to use it?

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    It's not encrypted, it's just packed to save space.

    I threw the return value to the Firebug console, and ran it through an online beautifier for javascript at http://elfz.laacz.lv/beautify/

    Here's the code that was in the eval section.

    Code javascript:
    var eg_width = 750;
    var eg_height = 600;
    var eg_bordercolor = '#0099FF';
    var eg_bgTitle = '#0099FF';
    var eg_htmlfile = 'http://products.mercola.com/popunder/popup-under-subscribe.htm';
    var eg_timeout = 0;
    var eg_disable_scrollbar = true;
    var eg_overlaybg = '#FFFF80';
    var eg_nrpshow = 1;
    var eg_opacity = 75;
    var eg_fade = false;
    var eg_showclose = true;
    var eg_borderwidth = 10;
    var eg_glide = true;
    var eg_glideposition = 5;
    var eg_isredirect = false;
    var eg_redirect_url = 'http://';
    var eg_exit_message = '';
    var myWidth = 0;
    var myHeight = 0;
    var opened = false;
    var is_in = false;
    var egwind = null;
    var eg_overlay = null;
    var eg_x = 100;
    var eg_y = 100;
    var nrp = -1;
    var nrp_show = eg_nrpshow;
    var autoclose = null;
    var ifr = null;
    function setOpacity(obj, value) {
        obj.style.opacity = value / 100;
        obj.style.filter = 'alpha(opacity=' + value + ')'
    }
    function sformat() {
        if (arguments.length == 0) return null;
        var str = arguments[0];
        for (var i = 1; i < arguments.length; i++) {
            var re = new RegExp('\\{' + (i - 1) + '\\}', 'gm');
            str = str.replace(re, arguments[i])
        }
        return str
    };
    function opacity(id, opacStart, opacEnd, millisec) {
        var speed = Math.round(millisec / 100);
        var timer = 0;
        changeOpac(opacStart, id);
        if (opacStart > opacEnd) {
            for (i = opacStart; i >= opacEnd; i--) {
                setTimeout("changeOpac(" + i + ",'" + id + "')", (timer * speed));
                timer++
            }
        } else if (opacStart < opacEnd) {
            for (i = opacStart; i <= opacEnd; i++) {
                setTimeout("changeOpac(" + i + ",'" + id + "')", (timer * speed));
                timer++
            }
        }
    }
    function changeOpac(opacity, id) {
        var object = document.getElementById(id).style;
        object.opacity = (opacity / 100);
        object.MozOpacity = (opacity / 100);
        object.KhtmlOpacity = (opacity / 100);
        object.filter = "alpha(opacity=" + opacity + ")"
    }
    function mmove(e) {
        if (opened) return true;
        if (typeof(window.innerWidth) == 'number') {
            myWidth = window.innerWidth;
            myHeight = window.innerHeight
        } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
            myWidth = document.documentElement.clientWidth;
            myHeight = document.documentElement.clientHeight
        } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
            myWidth = document.body.clientWidth;
            myHeight = document.body.clientHeight
        }
        var posx = 0;
        var posy = 0;
        if (!e) var e = window.event;
        if (e.pageX || e.pageY) {
            posx = e.pageX;
            posy = e.pageY
        } else if (e.clientX || e.clientY) {
            posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
            posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop
        }
        var s = sformat('x={0} y={1} bodyScrollTop={2} docScrollTop={3} wHeight={4}', posx, posy, document.body.scrollTop, screen.availHeight);
        eg_x = myWidth / 2 - eg_width / 2;
        eg_y = myHeight / 2 - eg_height / 2 + ((eg_disable_scrollbar) ? 0 : document.body.scrollTop);
        if (posy < 20 + document.body.scrollTop) {
            if (!is_in) nrp++;
            is_in = true;
            openWindow();
            return true
        } else {
            is_in = false;
        }
        return true
    };
    function addLoadEvent(func) {
        var oldonload = window.onload;
        if (typeof window.onload != 'function') {
            window.onload = func
        } else {
            window.onload = function() {
                if (oldonload) {
                    oldonload()
                }
                func()
            }
        }
    };
    addLoadEvent(function() {
        document.onmousemove = mmove;
        var x = document.createElement('div');
        x.setAttribute('id', 'egwind');
        document.body.appendChild(x);
        var y = document.createElement('div');
        y.setAttribute('id', 'eg_overlay');
        document.body.appendChild(y);
        x.style.position = 'absolute';
        x.style.top = '-1000px';
        x.style.left = '-1000px';
        x.style.background = '#ffffff';
        x.style.border = eg_borderwidth + 'px solid ' + eg_bordercolor;
        x.style.width = eg_width + 'px';
        x.style.height = eg_height + 'px';
        x.style.display = 'block';
        x.style.zIndex = '7';
        var xtext = "<table width='100%' cellpadding='0' cellspacing='0'>";
        var xclose = (!eg_showclose) ? "": "<tr><td align='right'><div style='height:23px;text-align:right !important;background:" + eg_bgTitle + " !important;padding:5px !important;'><a href='#' style='font-family:verdana !important;font-weight:bold !important;font-size:13px !important;color:#990000 !important;' onClick='closeWindow(); return false;'>[Close]</a></div></td></tr>";
        xtext += xclose + "<tr><td><iframe style='border:1px solid " + eg_bordercolor + ";background:white;' id='eg_iframe' name='eg_iframe' border='0' src='" + eg_htmlfile + "' width='" + (eg_width) + "' height='" + (eg_height - (eg_showclose ? 23 + 10 : 0)) + "'></iframe></td></tr></table>";
        x.innerHTML = xtext;
        egwind = x;
        eg_overlay = document.getElementById('eg_overlay');
        if (eg_isredirect) {
            window.onbeforeunload = onbefu;
            ifr = document.createElement('iframe');
            ifr.setAttribute('id', 'eg_iframe_redirect');
            ifr.setAttribute('src', eg_redirect_url);
            ifr.setAttribute('width', '0');
            ifr.setAttribute('height', '0');
            ifr.setAttribute('border', '0');
            ifr.setAttribute('style', 'border:none;position:absolute;top:0;left:0;width:0px;height:0px;');
            document.body.appendChild(ifr)
        }
    });
    var EG_needToConfirm = true;
    function onbefu() {
        if (EG_needToConfirm) {
            ifr.style.width = "100%";
            ifr.style.height = "100%";
            window.location.href = eg_redirect_url;
            document.body.innerHTML = '<iframe width=100% height=100% border=0 src="' + eg_redirect_url + '" style="border:none;"></iframe>';
            document.body.style.padding = '0px;';
            document.body.style.margin = '0px;';
            EG_needToConfirm = false;
            return "********************************************\n\n\n" + eg_exit_message + "\n\n\n********************************************"
        }
    };
    function glide(o, pos, ow, oh, w, h, cx, cy) {
        var sx = 0,
        sy = 0,
        ex = 0,
        ey = 0,
        dx = 0,
        dy = 0;
        switch (pos) {
        case 1:
            sx = 10;
            sy = 0 - oh - 10;
            ex = 10;
            ey = 10;
            dx = 0;
            dy = 20;
            break;
        case 2:
            sx = cx;
            sy = 0 - oh - 10;
            ex = cx;
            ey = 10;
            dx = 0;
            dy = 20;
            break;
        case 3:
            sx = w;
            sy = 0 - oh - 10;
            ex = w;
            ey = 10;
            dx = 0;
            dy = 20;
            break;
        case 4:
            sx = 10;
            sy = 0 - oh - 10;
            ex = 10;
            ey = cy;
            dx = 0;
            dy = 20;
            break;
        case 5:
            sx = cx;
            sy = 0 - oh - 10;
            ex = cx;
            ey = cy;
            dx = 0;
            dy = 20;
            break;
        case 6:
            sx = w;
            sy = 0 - oh - 10;
            ex = w;
            ey = cy;
            dx = 0;
            dy = 20;
            break;
        case 7:
            sx = 10;
            sy = 0 - oh - 10;
            ex = 10;
            ey = h;
            dx = 0;
            dy = 20;
            break;
        case 8:
            sx = cx;
            sy = 0 - oh - 10;
            ex = cx;
            ey = h;
            dx = 0;
            dy = 20;
            break;
        case 9:
            sx = w;
            sy = 0 - oh - 10;
            ex = w;
            ey = h;
            dx = 0;
            dy = 20;
            break
        }
        sy += document.body.scrollTop;
        sx += document.body.scrollLeft;
        ey += document.body.scrollTop;
        ex += document.body.scrollLeft;
        aglide(o, sx, sy, ex, ey, dx, dy)
    };
    function aglide(o, start_x, start_y, end_x, end_y, delta_x, delta_y) {
        o.style.top = start_y + 'px';
        o.style.left = start_x + 'px';
        amove(o, start_x, start_y, delta_x, delta_y, end_x, end_y)
    };
    function amove(o, curr_x, curr_y, delta_x, delta_y, end_x, end_y) {
        var acurr_x = curr_x + delta_x;
        var acurr_y = curr_y + delta_y;
        o.style.left = acurr_x + 'px';
        o.style.top = acurr_y + 'px';
        var am = sformat("amove(egwind,{0},{1},{2},{3}, {4}, {5})", acurr_x, acurr_y, delta_x, delta_y, end_x, end_y);
        if (acurr_y < end_y) {
            setTimeout(am, 40)
        }
    };
    function openWindow() {
        if (opened) return false;
        if (nrpundefinedrp_show != 0) {
            opened = false;
            return false
        }
        opened = true;
        if (eg_disable_scrollbar) {
            if (navigator.userAgent.indexOf("Gecko") == -1) document.body.style.overflow = 'hidden'
        }
        var x = egwind;
        x.style.top = eg_y + 'px';
        x.style.left = eg_x + 'px';
        x.style.display = 'block';
        var y = eg_overlay;
        y.style.position = 'absolute';
        y.style.top = '0px';
        y.style.left = '0px';
        y.style.width = document.body.scrollWidth + 'px';
        y.style.height = document.body.scrollHeight + 'px';
        y.style.zIndex = '5';
        y.style.display = 'block';
        y.style.background = eg_overlaybg;
        setOpacity(y, eg_opacity);
        document.body.style.height = '100%';
        if (eg_timeout > 0) {
            autoclose = setTimeout("closeWindow()", eg_timeout)
        }
        if (eg_fade) {
            opacity('egwind', 0, 100, 2 * 1000)
        }
        if (eg_glide) {
            if (typeof(window.innerWidth) == 'number') {
                myWidth = window.innerWidth - 40;
                myHeight = window.innerHeight - 40
            } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
                myWidth = document.documentElement.clientWidth;
                myHeight = document.documentElement.clientHeight
            } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
                myWidth = document.body.clientWidth - 10;
                myHeight = document.body.clientHeight - 20
            }
            glide(egwind, eg_glideposition, eg_width, eg_height, myWidth - eg_width, myHeight - eg_height, myWidth / 2 - eg_width / 2, myHeight / 2 - eg_height / 2)
        }
        return false
    };
    function closeWindow() {
        if (eg_fade) {
            opacity('egwind', 100, 0, 3 * 1000);
            setTimeout("realCloseWindow()", 3 * 1000)
        } else {
            realCloseWindow()
        }
    };
    function realCloseWindow() {
        opened = false;
        egwind.style.display = 'none';
        eg_overlay.style.display = 'none';
        if (eg_disable_scrollbar) document.body.style.overflow = 'auto';
        if (autoclose) clearTimeout(autoclose);
        return false
    };
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Bookmarks

Posting Permissions

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