Access my entire browsing history via Javascript

In general history is protected by the browser against javascript accessing it except through back and forward functionality. There are some hacks that can view some amount of history, but they are just that--hacks.

If you want to view/modify history programatically, you could do so via browser plugins. For example, Chrome plugins can use this API

EDIT

Mozilla also has some info about history modification available to Javascript here.

It also looks like this question talks about some of the same things you need.


Javascript only offers basic calls once your page takes control of the browser like:

history.length
window.history.back()
history.forward()
window.history.go(-3)

But if you were to write your own browser then you'd be using a 3GL in which case you'd be in total control of what the user has typed in the search or address fields you provided so you shouldn't have any problems there keeping a record of what the user did if you know what you're doing.


Short Answer no, you cannot access the history of your browser via common Javascript.

You could create an extension that would be cross browser with something like: http://crossrider.com/

The Docs for accessing the Places storage, which enables you to access the history of the browser is here for firefox: https://developer.mozilla.org/en-US/docs/Using_the_Places_history_service

And for chrome it is here: http://developer.chrome.com/extensions/history.html

There is a file for Places called Places.sqlite is an sqlite database, if you would build a local application that reads from that file, instead of accessing it from your browser, that would be simpler in my opinion.

You could also use the https://addons.mozilla.org/en-us/firefox/addon/sqlite-manager/ sqlite manager and order the history according to dates directly from the database. Here's an ERD for that http://people.mozilla.org/~dietrich/places-erd.png


The URI place: schema provides a modicum of potential for the javascript "only" (mousing around required) solution given below.

First note the distinction between session history, which can be accessed via History and window.history, and the overall browser history (in FF this is known as part of the library and another library part being bookmarks) which has no direct javascript access interfacing.
ref:

  • Places query URIs | MDN
  • History - Web API Interfaces | MDN
  • Window.history - Web API Interfaces | MDN
    on the web: developer.mozilla.org/en-US/docs/Web/API/Window.history

tested with:

window.navigator.userAgent=
      Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.4) Gecko/2008102920 Firefox/3.0.4
                                                                                                                               (Splashtop-v1.2.17.0)

(The intimate familiarity with this subject is unfortunately due to the severely crippled FF released as QuickWeb by Device VM in the Splashtop system.)

Here is what can be done:
Note:

  • the FF test environment identified above - some of the "conventions" used maybe exclusive and not universally available in other browsers or FF versions

  • at the expense of a little more manually labour intensive intervention than
    1 a simple activation click ...
    the solution suggested here also requires
    2 a bookmark link click
    3 save it click
    4 ~ 6 bookmark open and select sequence
    7 results drag & drop
    8 ~ 10 cleanup and delete results from bookmarks
    (is not this anathema to the whole precept of the Order of Automata aka computer automation?
    js js is js - Just Saying JavaScript is Just [too] "Simple")

Using javascript construct a place: scheme URI with the appropriate .some_get_list_function and bookmark it.

<a href="place:queryType=0&sort=8&maxResults=10"                       title="hysterix">extract history</a>

Clicking the link fails but right click bookmarking it and then clicking the bookmark "succeeds". Ergo, might as well resolve left click to redirect immediately to bookmark.

<a href="place:queryType=0&sort=8&maxResults=10" rel="sidebar" title="hystryx">extract history</a>

Drag and drop the now bookmarked place: URI "hystryx" into a target <form><textarea> . Note a significant limitation is that this process retrieves ONLY the history's URI's and none of the history chronology, titles, etc. It is possible to recover some of this information (such as titles by opening each URI to extract them, doing so of course changes the URI "most recent access date" in the history) to render the URI as "nice" links.

Putting it all together:

data:text/html;charset=utf-8,
<html><title >Heuristic History Hysterics scURIple</title>
<!-- 
http://stackoverflow.com/questions/13369829/access-my-entire-browsing-history-via-javascript
                                                                                               /22773361# 22773361                       -->
<!-- 
   - scURIples (scriples) are generic schema (data:, javascript:, place:, ... ) URI that embed script
   - data: scURIples (scriples) are amenable to direct cut & paste URI address bar evaluation
   - generally no particular distinction is made between scURIples of different schema,
       such as this data: schema URI, but ... 
   - javascript: schema specific scURIples are called scriplets or bookmarklets                                -->
<!-- 
   a bookmark of this data: scURIple or its internal javascript: scriplet does the same thing             -->
<!--
  a place[s]: schema URI "works" from a bookmark only and not the address bar or a hyperlink      -->
<!-- for internal use only (by the scURIbbler used to edit this script):  
       javascript: with ( opener . document . forms[0] . JS ) value = 
                                        value . replace(  /\t|\n/g, function(c){ return escape(c) + c } )  ; close();//  
       scURIples are unscURIpulous 
              NB. no raw tabs, % 09 's collapse to null, quote raw %'s w/ non-numerics, };'s ,  ...             -->
<script>
javascript:

String.prototype.HTMLtagWrap   =
    function ( tag,  attrs)  { 
        return  tag[0]=="/" ?
            "<"  +tag+                                ">"  +this+  "<"  +tag.substr(1)+  (attrs?" "+attrs:"") +  ">"    :
            "<"  +tag+ (attrs?" "+attrs:"") + ">"  +this+  "</"  +tag+                                                 ">"
    }  ;

String.prototype.HTMLwrapTags =
   function ( tagRA, atRA) { 
      return tagRA[0] ? this . HTMLtagWrap( tagRA.pop(), atRA.pop()) . HTMLwrapTags( tagRA, atRA)
                                :  this
   }  ;

/* alert */ ( str =
( function(x){return x.HTMLtagWrap('title') + x.HTMLwrapTags(['/pre','center','b'] , [ ] ) }
                               ('Heuristic History Hysterics')+
    '1. '.HTMLtagWrap('b') +
    '<input     id=URIplcQry     type=text    size=120  ' +
                           'value="place:queryType=0&sort=8&maxResults=25" >\n' +
    'suggestions:\t try just a raw place: with no corpus or places: (undocumented with an s)\n' + 
    'auto attribution:\t' + 
    '<input type=button onclick=URIplcQry.value+="&"+this.value  value=sort=4                        >  \t' + 
    '<input type=button onclick=URIplcQry.value+="&"+this.value  value=type=5                       >  \t' + 
    '<input type=button onclick=URIplcQry.value+="&"+this.value  value=queryType=1            >\t  ' + 
    '<input type=button onclick=URIplcQry.value+="&"+this.value  value=domain=""                 >\t  ' + 
    '<input type=button onclick=URIplcQry.value+="&"+this.value  value=includeHidden=true  >\t   ' + 
    '<input type=button onclick=URIplcQry.value+="&"+this.value  value=onlyBookmarked=true >\t' + 
    '\n\n2. '.HTMLtagWrap('b') +
    'This link bookmarks the place: URI from step 1: '  +
    'place: query URI href results' .
        HTMLtagWrap(  'A', 
            ' href="places:"  rel="sidebar"  title="hystryx  " id="hystryx  " ' +
            ' onmouseover ="with(this)title=id+(href=document.forms[0].URIplcQry.value)"  '
        ) +
    '\t(hint: to see the actual link, mouse over it 2x)'  +
    '\n\n3. '.HTMLtagWrap('b',   ' style="vertical-align:top;" '  ) +
  ( '\n\t\t\tINSTRUCTIONS\n\n' +
    '1. make the href place: query for the link in step 2. \n' +
    '2. click the link to create a bookmark that accesses the URI library\n' +
    '3. drag & drop the new bookmark (aka a container) here (replace this content)\n' +
    '4. cleanup and delete the new bookmark if desired\n'  +
    '5. to be done: add a scURIbbler to massage this textarea\n'  +
    '\n\n' +
    'tested with userAgent:\t\t\t\t'  +
    'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.4) Gecko/2008102920 Firefox/3.0.4'  +
                                                                                                         '(Splashtop-v1.2.17.0) \n'  +
    '\twindow.navigator.userAgent =\t\t'  + window.navigator.userAgent +
    '\n ' 
  ) .HTMLtagWrap('textarea', 'id=histURIs  rows=12 cols=120 nowrap') +
   '\n\n4. ...'.HTMLtagWrap('b') +
   '\n\n5. '.HTMLtagWrap('b') +
   'scURIbbler:  <input   type=text    size=120  id=histURIpg ' +
       ' value="javascript:with(opener)with(document.forms[0]) '                                              +
           ' ( URIplcQry.value.HTMLtagWrap(\'b\') + '                                                                  +
              ' histURIs.value.replace(/^.*$/g,function(m){return m.link(m)}) '                              +
          '  ).HTMLwrapTags( \'html pre\'.split(/ +/) , [ ] ) '                                                                     +
    ' "><input type=button value="open histURIs" onclick=window.open(histURIpg.value )>  ' +
    '  '
)  .  HTMLwrapTags ( ["html", "form", "pre"] , [ ] ) 
);

/*
window.open (    "data:text/html;charset=utf-8,"  +  str . replace ( /\n/g,  '%'+'0A ' )        );
*/
document.write ( str );

</script>
</html>