
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 条左右的数据,且无法判断是否执行完毕会一直执行下去。但是会自动化执行,所以无需担心多次操作的问题,只需要在删除完记录后 刷新一次页面 或 手动将任务清除 即可。
1 icebay OP 如果网络比较慢,可以在 ` clearHistory(delay) ` 执行之前追加一段 ` setTimeout ` 来减慢速度。 |