Chrome 历史记录自动化删除

2018-04-13 10:50:52 +08:00
 IceBay

Chrome 历史记录自动化删除

  1. 打开历史记录页面,输入关键词搜索需要删除的页面。
  2. 得到结果页面之后刷新一次页面。
  3. 执行下面这段 javascript 代码。

function clearHistory(delay = 300) {
    let historyList = document.querySelectorAll('#history-app /deep/ #content /deep/ #history /deep/ #infinite-list /deep/ history-item /deep/ #checkbox');

    console.log(historyList.length);

    if (historyList.length > 0) {
        for (let i = 0; i < historyList.length; i++) {
            let item = historyList[i];

            item.click();
        }

        setTimeout(function () {
            document.querySelector('#history-app /deep/ #toolbar /deep/ cr-toolbar-selection-overlay /deep/ #delete').click();
            setTimeout(function(){
                document.querySelector('#history-app /deep/ #content /deep/ #history /deep/ dialog /deep/ .action-button').click();
                clearHistory(delay);
            }, delay);
        }, delay);
    } else {
        location.href = location;
    }
}

clearHistory();

美中不足:一次最多删除 50 条左右的数据,且无法判断是否执行完毕会一直执行下去。但是会自动化执行,所以无需担心多次操作的问题,只需要在删除完记录后 刷新一次页面 或 手动将任务清除 即可。

2582 次点击
所在节点    浏览器
1 条回复
IceBay
2018-04-13 10:54:54 +08:00
如果网络比较慢,可以在 ` clearHistory(delay) ` 执行之前追加一段 ` setTimeout ` 来减慢速度。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/446468

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX