3

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?

Mustafa Poya
  • 2,615
  • 5
  • 22
  • 36

3 Answers3

4

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%20history%20Page%3A%20Ctrl%2BA%20now%20selects%20all%20items&text=Now%20the%20addition%20of%20Ctrl,or%20unselect%20multiple%20history%20items.&text=The%20thing%20is%2C%20only%20150,page%20has%20more%20history%20items.

1

It's a very easy approach. Only need to follow these steps:

  1. Open history section, no matter with shortcut which ctrl+h or using the three dot on the right section of chrome.
  2. Then, search for the website you want to delete the history like ww.facebook.com'.
  3. Next, use the ctrl+a shortcut. All the check-boxes must be checked.
  4. Finally there is a delete button on the top section. press it.
  5. You are done.

========================================================================

Abdu4
  • 1,269
  • 2
  • 11
  • 19
0

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.

starball
  • 20,030
  • 7
  • 43
  • 238