【问题标题】:chrome.history.search() doesn't return all historychrome.history.search() 不会返回所有历史记录
【发布时间】:2020-10-06 21:12:15
【问题描述】:

所以在过去的几周里,我一直在尝试让自己成为一个自动删除历史记录的 chrome 扩展程序,我以为我快完成了,但后来我意识到 chrome.history.search() 并没有返回所有在历史中,只有一些,我无法弄清楚为什么某些历史记录会被删除,而有些则不会。我目前有

`chrome.storage.sync.get({ // Retrieving the stored array of words
    list: []
},
function(data) {
    for (i = 0; i < data.list.length; i++) {
        let searchString = data.list[i].toString(); //String that is searched for
        chrome.history.search({ // History search function
          text: searchString, // String to search for
          startTime: 2678400000,
          maxResults: 5000,
      }, checkHistory)
  }
});`

我的回调函数是

`function checkHistory(historyItems) {
    for (let item of historyItems) { // Deleting items that were found in the search
        chrome.history.deleteUrl({
            url: item.url
        });
    }
}`

我的目标是,例如,如果我搜索“Google”,它将删除所有带有子字符串“Google”的搜索。我 100% 确定该列表不是问题,因为它打印得很好,我注意到的一件事是,当我尝试删除时,它总是删除所有超过 2-3 天的子字符串,我以为我会把它放在那里我不确定这是否意味着什么。 我将不胜感激任何有关问题可能的见解。谢谢!

【问题讨论】:

    标签: javascript google-chrome browser-history


    【解决方案1】:

    可能是因为开始时间的原因,看看chrome是如何计算它的时间的。如果它不起作用,请尝试 API

    chrome.history.deleteRange(object range, function callback)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-10-28
      • 2023-03-31
      • 2013-05-22
      • 2022-10-23
      • 1970-01-01
      • 2019-05-26
      • 1970-01-01
      • 2013-02-13
      相关资源
      最近更新 更多