1

I'm creating an extension which deletes history. I managed to delete history using this function provided from 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);

But sites visited during this period appear in that Most Visited section of New Tab in Chrome.

Xan
  • 74,770
  • 16
  • 179
  • 206
kecman
  • 813
  • 3
  • 14
  • 34

2 Answers2

1

Unfortunately, it doesn't seem to be possible.

It's not an option you can specify for browsingData, and corresponding API, chrome.topSites, is read-only.

Xan
  • 74,770
  • 16
  • 179
  • 206
  • Yeah, they definitely did a bad job with this History Sync option... makes everything unpredictable.. – kecman May 14 '16 at 22:49
1

Try to use the chrome.history API if it can work in your case. By using this you can add, remove, and query for URLs in the browser's history.

To remove all occurence of the given URL from the history, use deleteUrl

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

For more information check this SO question:

Another option is maybe by using css in your new tab. By checking other issue on Google, I found this 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. You can also try that if it can work for you.

Community
  • 1
  • 1
KENdi
  • 7,576
  • 2
  • 16
  • 31
  • 1
    `browsingData` nukes history just as well as `history` API (_maybe_ even better [in case History Sync is on](http://stackoverflow.com/questions/27130828/history-not-fully-deleted-using-chrome-history-deleterange), but don't quote me on that). New Tab page is a privileged page that cannot be injected into (but can be [replaced](https://developer.chrome.com/extensions/override)), so the last part is false. – Xan May 13 '16 at 08:56
  • Sorry but overriding New Tab is not option for me. – kecman May 14 '16 at 22:50