chrome.history.search() 不 return 所有历史记录
chrome.history.search() doesn't return all history
所以在过去的几周里,我一直在努力让自己成为一个 chrome 自动删除历史记录的扩展程序,我以为我快完成了,但后来我意识到 chrome.history.search( ) 不是 return 所有历史记录,只有一些历史记录,我不明白为什么某些历史记录会被删除,而有些则不会。我目前有
`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)
所以在过去的几周里,我一直在努力让自己成为一个 chrome 自动删除历史记录的扩展程序,我以为我快完成了,但后来我意识到 chrome.history.search( ) 不是 return 所有历史记录,只有一些历史记录,我不明白为什么某些历史记录会被删除,而有些则不会。我目前有
`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)