Home > Blockchain >  How to delete all history of specific website in google chrome
How to delete all history of specific website in google chrome

Time:09-30

In google chrome in history section, I want to delete all the histories related to a specific website for example: facebook.com, I can search facebook.com and then select all checkboxes and delete but its a time-consuming work.

Is there any easy way to clear the history of specific websites? even by writing code or script?

CodePudding user response:

open the history manager, search for facebook.com... do not click all the checkboxes individually. Click the first box, scroll to the bottom of the page and hold shift while clicking the last box, it will select all of them at once.

protip: if you want to visit a website without leaving a history entry, go into incognito mode (control-shift-p).

or, Control-A keyboard shortcut will select all of the checkboxes as well! https://techdows.com/2018/02/chrome-history-page-ctrl-a-now-selects-all-history-items.html#:~:text=Chrome history Page: Ctrl+A now selects all items&text=Now the addition of Ctrl,or unselect multiple history items.&text=The thing is, only 150,page has more history items.

CodePudding user response:

You can use some scripting in the console to click checkboxes for entries with hrefs containing a substring.

This answer uses this other SO answer on a querySelectorAll that works for things inside open shadow DOMs:

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());

This will click all the matching entries on the current page, and then you can just click the button to delete the checked entries.

  • Related