在谷歌浏览器的history部分,我想删除与特定网站相关的所有历史记录,例如:
facebook.com
,我可以搜索facebook.com
,然后选择所有复选框并删除,但这是一项耗时的工作。
有什么简单的方法可以清除特定网站的历史记录吗? 甚至通过编写代码或脚本?
打开历史记录管理器,搜索 facebook.com...不要单独单击所有复选框。单击第一个框,滚动到页面底部并按住 Shift 键,同时单击最后一个框,它将一次选择所有框。
专业提示:如果您想访问网站而不留下历史记录条目,请进入隐身模式(control-shift-p)。
您可以在控制台中使用一些脚本来单击包含子字符串的
href
条目的复选框。
这个答案使用这个其他SO答案在
querySelectorAll
上,适用于开放影子DOM中的东西:
function $$$(selector, rootNode=document.body) {
const arr = []
const traverser = node => {
// 1. decline all nodes that are not elements
if(node.nodeType !== Node.ELEMENT_NODE) {
return
}
// 2. add the node to the array, if it matches the selector
if(node.matches(selector)) {
arr.push(node)
}
// 3. loop through the children
const children = node.children
if (children.length) {
for(const child of children) {
traverser(child)
}
}
// 4. check for shadow DOM, and loop through it's children
const shadowRoot = node.shadowRoot
if (shadowRoot) {
const shadowChildren = shadowRoot.children
for(const shadowChild of shadowChildren) {
traverser(shadowChild)
}
}
}
traverser(rootNode)
return arr
}
arr = $$$('[href*="example.com"]');
// this code will need to be updated if the source code for the chrome history browser changes.
arr.map(e => e.closest("#item-info")
.previousElementSibling
.previousElementSibling
).forEach(e=>e.click());
这将点击当前页面上所有匹配的条目,然后您只需点击按钮即可删除选中的条目。
这是一个非常简单的方法。只需要按照以下步骤操作:
====================================================== =========================