从新标签中访问最多的部分删除网站

Delete website from Most Visited section in New Tab

我正在创建一个删除历史记录的扩展程序。我设法使用 Chrome:

提供的这个功能删除了历史记录
var millisecondsPerWeek = 1000 * 60 * 60 * 24 * 7;
var oneWeekAgo = (new Date()).getTime() - millisecondsPerWeek;
chrome.browsingData.remove({
  "since": oneWeekAgo
}, {
  "appcache": true,
  "cache": true,
  "cookies": true,
  "downloads": true,
  "fileSystems": true,
  "formData": true,
  "history": true,
  "indexedDB": true,
  "localStorage": true,
  "pluginData": true,
  "passwords": true,
  "webSQL": true
}, callback);

但是在此期间访问过的网站出现在 Chrome 中新标签的“访问最多”部分。

很遗憾,这似乎是不可能的。

这不是您可以选择的选项specify for browsingData, and corresponding API, chrome.topSites,它是只读的。

如果 chrome.history API 适合您的情况,请尝试使用它。通过使用它,您可以在浏览器的历史记录中添加、删除和查询 URL。

要从历史记录中删除给定 URL 的所有出现,请使用 deleteUrl

chrome.history.deleteUrl(object details, function callback)

有关更多信息,请查看此 SO 问题:

  • GoogleChrome extension that deletes browsing history with one click from an icon

  • Cannot delete URLs with Chrome's history API

另一种选择是在新标签页中使用 css。通过检查 Google 上的其他问题,我发现了这个 one that is related to your problem. By checking the last answer in the post, He recommended to tweak the UI by using CSS file。如果它对你有用,你也可以试试。