【问题标题】:Get last 10 user's searches获取最后 10 个用户的搜索
【发布时间】:2012-11-21 06:50:59
【问题描述】:

我正在编写 chrome 扩展程序,它需要从历史记录中获取最后 10 个用户的搜索。这似乎保存在用户配置文件目录中的 sqlite3 文件“历史记录”中。但是表keyword_search_terms 的格式并不明显。而且我不知道如何从扩展的代码中获取 chrome 的配置文件目录。在 Linux 上,该目录位于“~/.config/chromium/Default”,但我不知道它在不同环境中会是什么。

【问题讨论】:

    标签: google-chrome google-chrome-extension google-chrome-devtools google-chrome-app


    【解决方案1】:

    你不需要读取本地文件,

    你可以使用chrome.history api

    一个基本的例子,

    chrome.history.search({maxResults : 10, text: ""}, function(historyItem) {
       console.log(historyItem);
    });
    

    不要忘记在manifest.json 中声明“历史”权限。

    编辑:是的,这仅适用于最后 10 个 URL。 API 不提供该功能。

    如果你想知道历史文件的位置,

    Windows Vista or 7: \Users\_username_\AppData\Local\Google\Chrome\User Data\Default\History
    Windows XP: \Documents and Settings\_username_\Local Settings\Application Data\Google\Chrome\User Data\Default\History
    Mac OS X: ~/Library/Application Support/Google/Chrome/Default/History
    Linux: ~/.config/google-chrome/Default/History
    

    但我不知道您将如何从外部文件中读取数据。

    【讨论】:

    • 但这将返回 10 个上次访问的 URL。我只对搜索感兴趣。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-22
    • 2020-09-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-04
    相关资源
    最近更新 更多