javascript - chrome.history.search() 不会返回所有历史记录
问题描述
所以在过去的几周里,我一直在尝试让自己成为一个自动删除历史的 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 天的子字符串,我以为我会把它放在那里我不确定这是否意味着什么。我将不胜感激任何有关问题可能的见解。谢谢!
解决方案
也许是因为开始时间,找到chrome如何计算它的时间。如果它不起作用,请尝试 API
chrome.history.deleteRange(object range, function callback)
推荐阅读
- javascript - 默认 Rails 5.2.1.1 内容安全策略(CSP)“style-src 'unsafe-inline'”被违反
- postgresql - 多边形搜索中的点太慢
- python - 如何创建包含数字范围的矩阵?
- c++ - 什么时候允许推导 initializer_list?
- python - 我应该如何在这个类的函数之间传递变量?
- php - Cloudflare $_SERVER["HTTP_CF_IPCOUNTRY"] 从未发送
- c++ - 如何在 cpp 中读取 .dat 文件?
- c# - 强制密封类
- mysql - MySQL - 百分比计算并在同一张表的其他列中更新它
- hyperledger-fabric - 我可以查询 Hyperledger Fabric 分类帐或更新对等节点中没有链码的分类帐吗?