1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to make this pop under rotating?

Discussion in 'HTML & JavaScript' started by Chicilikit, Oct 23, 2014.

  1. Chicilikit

    Chicilikit Senior Member

    Joined:
    Dec 21, 2010
    Messages:
    873
    Likes Received:
    153
    Hello, I use this pop under script and works as I need, but I need it to rotate urls, can anyone help me with it?
    Code:
    <script>
    var puShown = false;
    var PopWidth = 1400;
    var PopHeight = 900;
    var PopFocus = 0;
    var _Top = null;
    
    function GetWindowHeight() {
    var myHeight = 0;
    if( typeof( _Top.window.innerHeight ) == 'number' ) {
    myHeight = _Top.window.innerHeight;
    } else if( _Top.document.documentElement && _Top.document.documentElement.clientHeight ) {
    myHeight = _Top.document.documentElement.clientHeight;
    } else if( _Top.document.body && _Top.document.body.clientHeight ) {
    myHeight = _Top.document.body.clientHeight;
    }
    return myHeight;
    }
    
    function GetWindowWidth() {
    var myWidth = 0;
    if( typeof( _Top.window.innerWidth ) == 'number' ) {
    myWidth = _Top.window.innerWidth;
    } else if( _Top.document.documentElement && _Top.document.documentElement.clientWidth ) {
    myWidth = _Top.document.documentElement.clientWidth;
    } else if( _Top.document.body && _Top.document.body.clientWidth ) {
    myWidth = _Top.document.body.clientWidth;
    }
    return myWidth;
    }
    
    function GetWindowTop() {
    return (_Top.window.screenTop != undefined) ? _Top.window.screenTop : _Top.window.screenY;
    }
    
    function GetWindowLeft() {
    return (_Top.window.screenLeft != undefined) ? _Top.window.screenLeft : _Top.window.screenX;
    }
    
    function doOpen(url)
    {
    var popURL = "about:blank"
    var popID = "ad_" + Math.floor(89999999*Math.random()+10000000);
    var pxLeft = 0;
    var pxTop = 0;
    pxLeft = (GetWindowLeft() + (GetWindowWidth() / 2) - (PopWidth / 2));
    pxTop = (GetWindowTop() + (GetWindowHeight() / 2) - (PopHeight / 2));
    
    if ( puShown == true )
    {
    return true;
    }
    
    var PopWin=_Top.window.open(popURL,popID,'toolbar=0,scrollbars=1,location=1,statusbar=1,menubar=0,resizable=1,top=' + pxTop + ',left=' + pxLeft + ',width=' + PopWidth + ',height=' + PopHeight);
    
    if (PopWin)
    {
    puShown = true;
    
    if (PopFocus == 0)
    {
    PopWin.blur();
    
    if (navigator.userAgent.toLowerCase().indexOf("applewebkit") > -1)
    {
    _Top.window.blur();
    _Top.window.focus();
    }
    }
    
    PopWin.Init = function(e) {
    
    with (e) {
    
    Params = e.Params;
    Main = function(){
    
    if (typeof window.mozPaintCount != "undefined") {
    var x = window.open("about:blank");
    x.close();
    
    }
    
    var popURL = Params.PopURL;
    
    try { opener.window.focus(); }
    catch (err) { }
    
    window.location = popURL;
    }
    
    Main();
    }
    };
    
    PopWin.Params = {
    PopURL: url
    }
    
    PopWin.Init(PopWin);
    }
    
    return PopWin;
    }
    
    function setCookie(name, value, time)
    {
    var expires = new Date();
    
    expires.setTime( expires.getTime() + time );
    
    document.cookie = name + '=' + value + '; path=/;' + '; expires=' + expires.toGMTString() ;
    }
    
    function getCookie(name) {
    var cookies = document.cookie.toString().split('; ');
    var cookie, c_name, c_value;
    
    for (var n=0; n<cookies.length; n++) {
    cookie  = cookies[n].split('=');
    c_name  = cookie[0];
    c_value = cookie[1];
    
    if ( c_name == name ) {
    return c_value;
    }
    }
    
    return null;
    }
    
    function initPu()
    {
    
    _Top = self;
    
    if (top != self)
    {
    try
    {
    if (top.document.location.toString())
    _Top = top;
    }
    catch(err) { }
    }
    
    if ( document.attachEvent )
    {
    document.attachEvent( 'onclick', checkTarget );
    }
    else if ( document.addEventListener )
    {
    document.addEventListener( 'click', checkTarget, false );
    }
    }
    
    function checkTarget(e)
    {
    if ( !getCookie('popundr') ) {
    var e = e || window.event;
    var win = doOpen('http://google.com');
    
    setCookie('popundr', 1, 1*60*60*1000);
    }
    }
    
    initPu();
    </script>
     
  2. Chicilikit

    Chicilikit Senior Member

    Joined:
    Dec 21, 2010
    Messages:
    873
    Likes Received:
    153
    No one? If you know any other script that can rotate urls, than let me know. I guess it could be done with some kind of rotating redirector also.
     
  3. butterbutter

    butterbutter Newbie

    Joined:
    Jun 9, 2014
    Messages:
    2
    Likes Received:
    2
    Hi,
    As I am not very familiar with that technique, I interpreted your question in two differents ways.

    If you mean rotating the url AFTER your pop under is opened (like switching from urls to urls every 30sec while it's still open), you can't do that unless you control the content of the page that was opened in the pop under. If you do control, then you would need to add your own javascript that would redirect the page every 30secs. I doubt that's what you meant so I'm not going to go further down that route.

    If your goal is to open a random pop under each time, then it is quite easy to do! I'll show you.
    I am going to assume that you didn't write this code since if found it posted elsewhere on blackhat forums and maybe explain what
    I'm doing with much more details than you need/are interested in, but here we go.

    First thing, I want to point out that your pop under will only be opened once per hour as it is set right now (cookies will prevent it).

    Now, there are severals ways you could do that, but it all depends on what is the final product you want. Do you want a random url, a differenturl each time, cycle throught each url that you have? I'll assume you just want a random url, but it should be easy enough to modify for the diffrent cases.

    This is the code that we are interrested in
    Code:
    function checkTarget(e)
    {
        if ( !getCookie('popundr') ) {
            var e = e || window.event;
            var win = doOpen('google');
            setCookie('popundr', 1, 1*60*60*1000) //the line that set the cookie to limit the pop under;
        }
    }
    
    The URL to open is passed to the doOpen function. All we have to do is generate/get a random url to load. I suggest to create a new function that would do just that.

    Code:
    function generateURL() {
        var URLs = ["google", "yahoo", "duckduckgo", "bing"] //change the strings for you URLs;
        return URLs[Math.floor(Math.random() * URLs.length)]; //4 is the number of URLs in your array
    }
    
    Now, your checkTarget function would become

    Code:
    function checkTarget(e)
    {
        if ( !getCookie('popundr') ) {
            var e = e || window.event;
            var win = doOpen(generateURL());
            setCookie('popundr', 1, 1*60*60*1000);
        }
    }
    

    Just add the generateURL in your code (before checkTarget) and modify checkTarget.

    It's as simple as that. If you want to cycle throught your URLs and not just get a random one, you could track wich URL was seen
    by your user using a cookie. Start your cookie at 0 then increment by one each time the user gets a new pop uner. If you don't
    know how to do that exacly, send me a private message. I'll respond as soon as I can.

    Hope this helps you a bit.
     
    • Thanks Thanks x 2