通过Javascript访问我的整个浏览历史记录

时间:2012-11-13 22:16:49

标签: javascript

如果我点击浏览器上的历史记录标签,我可以到达一个文件夹,其中包含我按日期访问的所有链接。

如何使用Javascript以编程方式访问此文件?我还是Javascript的新手但我想要的东西是:

var aListOfDateLinkPairs = window.history.some_get_list_function;

我确定这对于某些任意实体来说是一个很大的隐私问题,但如果我想在我自己的浏览器中以编程方式实现这一点呢?

谢谢!

4 个答案:

答案 0 :(得分:14)

一般来说,历史记录受浏览器保护,不受javascript访问,除非通过后退和前进功能。有some hacks可以查看一定数量的历史记录,但它们只是 - 黑客。

如果要以编程方式查看/修改历史记录,可以通过浏览器插件执行此操作。例如,Chrome插件可以使用this API

修改

Mozilla还提供了一些有关Javascript here可用的历史记录修改的信息。

看起来this question也谈到了你需要的一些东西。

答案 1 :(得分:5)

一旦您的页面控制浏览器,Javascript就会提供基本调用,如:

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

但如果您要编写自己的浏览器,那么您将使用3GL,在这种情况下,您可以完全控制用户在您提供的搜索或地址字段中键入的内容,因此您不应该如果您知道自己在做什么,那么会记录用户的所有问题。

答案 2 :(得分:3)

简短回答否,您无法通过常见的Javascript访问浏览器的历史记录。

您可以使用以下内容创建一个跨浏览器的扩展程序:http://crossrider.com/

用于访问Places存储的文档,可让您访问浏览器的历史记录,可在此处获取:https://developer.mozilla.org/en-US/docs/Using_the_Places_history_service

对于chrome来说,它就在这里:http://developer.chrome.com/extensions/history.html

Places的{​​{1}}文件是一个sqlite数据库,如果您要构建一个从该文件读取的本地应用程序,而不是从浏览器访问它,那么这个文件就更简单了我的看法。

您还可以使用https://addons.mozilla.org/en-us/firefox/addon/sqlite-manager/ sqlite管理器,并根据日期直接从数据库中订购历史记录。这是http://people.mozilla.org/~dietrich/places-erd.png

的ERD

答案 3 :(得分:1)

URI place:架构为下面给出的javascript“仅限”(围绕所需的鼠标)解决方案提供了一点点潜力。

首先注意可以通过Historywindow.history访问的会话历史记录与整体浏览器历史记录之间的区别(在FF中,这称为库的一部分,另一个库部件是书签)没有直接javascript访问接口 参考:

测试:

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)

(遗憾的是,由于在Splashtop系统中由设备虚拟机以QuickWeb的形式发布了严重残缺的 FF,因此非常熟悉这个主题。)

以下是可以做的事情:
注意:

  • 上面确定的FF测试环境 - 一些“惯例” 使用可能是独占的,而不是在其他浏览器中普遍可用 或FF版本

  • 以牺牲一点人工劳动密集型干预为代价   1一个简单的激活点击...
      这里建议的解决方案也需要
      2书签链接点击
      3保存点击
      打开4~6个书签并选择序列
      7结果拖拽&降
      8~10清理并删除书签的结果
      (这不是自动机系统计算机自动化的整个规则的诅咒吗?   js js是js - 只是说JavaScript只是[太]“简单”)

使用javascript构建一个place:方案URI,并使用相应的.some_get_list_function并为其添加书签。

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

单击该链接失败,但右键单击书签,然后单击书签“成功”。因此,也可以解决左键单击以立即重定向到书签。

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

将已加入书签的place: URI“hystryx”拖放到目标<form><textarea>中。请注意,一个重要的限制是,此过程仅检索历史记录的URI,而不检索历史记录的年代,标题等。可以通过打开每个URI来提取它们来恢复某些信息(例如标题,当然这样做也是如此) <历史中的URI“最近访问日期”)将URI呈现为“漂亮”链接。

全部放在一起:

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>