10

I want to remove a large number of specific items from the Chrome history.

I can search for my term, but then I have to click a lot of checkboxes just to remove every item. Is there a way to make this process faster?

2
  • 1
    Open the sqlite database C:\Users\username\AppData\Local\Google\Chrome\User Data\Default\History with your favorite sqlite database browser while Chrome isn't running. Use SQL queries to remove records.
    – Zoredache
    Jan 31, 2014 at 0:34
  • @Zoredache You should post that as an answer. Jan 31, 2014 at 9:04

4 Answers 4

17

You can also Shift+Click to select multiple items in history and remove them at once.

This works as of Chrome version 33, and possibly earlier versions.

  1. Perform a search to bring up the relevant history items
  2. Click the first result
  3. Shift+Click the last result
  4. Click Remove Selected Items
9
  1. Perform a search to bring up the items you want to remove the history.

    enter image description here

  2. Open the Chrome Developer Tools console by pressing Ctrl+Shift+J.

  3. Make sure to select the history-frame frame as the target frame for the console.

    enter image description here

  4. Execute the following snippet in the console (by pasting it and pressing Enter) to mark all checkboxes in the history.

    var checkboxes = $$( "input[type='checkbox']" );
    for( var i = 0; i < checkboxes.length; ++i ) {
      checkboxes[ i ].checked = true;
    }
    

    Don't forget to double-check the selection and uncheck items which you don't actually want to remove!

  5. Clear the selected items from your history by pressing the Remove selected items.

    enter image description here

1
  • You should accept your own answer, it's better :)
    – user
    Jan 10, 2015 at 19:22
3

Here's something I wrote in JavaScript.. It works through the Console Debugger.. I tried using it in a bookmark but I get no response from the page..

** // UPDATE (07.28.15)
I added a shorter approach provided by @Denis Gorbachev to the checkbox targeting, which helped shorten some of this code. I also added "auto-stop" functionality, meaning the loop will stop once it has finally cleared the list.

** // UPDATE (08.20.14)
I made a few changes to the code, to make it more user friendly. Other users may not be code-savvy, and others may simply prefer convenience. Therefore, I whipped up a couple buttons (start/stop) to control the usage; as well as address some "ASSERTION FAILED" exceptions/errors that were being thrown when attempted to run the script loop.. Enjoy!!


Step 1) In your address bar, type in the following address to to the meat of the history page.. It's normally loaded in an iframe, with the left-side menu loaded in another frame..

chrome://history-frame/

Step 2) Load your Console Debugger/Viewer by pressing Ctrl+Shift+J
(For Mac users, ++J)
                Note: You can also press F12 and select the "Console" tab.

Step 3) In the Console Debugger/Viewer, copy & paste the following code:

function removeItems() {
removeButton = document.getElementById('remove-selected');
overlayWindow = document.getElementById('overlay');
    //revision (07.28.15): Replaced the For Loop targeting the checkboxes, thanks to Denis Gorbachev via comments (02.19.15)
Array.prototype.forEach.call(document.querySelectorAll("input[type=checkbox]"), function(node) {node.checked = "checked"});
setTimeout(function () {
    if (removeButton.getAttribute("disabled") !== null) {
        removeButton.removeAttribute("disabled")
    }
    /* revision (08.20.14): no longer binding to that condition, button should no longer be disabled, so click! */
    if ((overlayWindow.hasAttribute("hidden")) && (overlayWindow.getAttribute("hidden") !== false)) {
        removeButton.click();
    }
    /* revision (08.20.14): new Interval, to check against the overlay DIV containing the confirmation "Remove" button */
    /* Attempting to click the button while the DIV's "hidden" attribute is in effect will cause FAILED ASSERTION */
    stopButton = setInterval(function () {
        if (overlayWindow.hasAttribute("hidden")) {
            if (overlayWindow.getAttribute("hidden") == "false") {
                hidden = false
            } else {
                hidden = true
            }
        } else {
            hidden = false
        }
        if (!hidden) {
            document.getElementById("alertOverlayOk").click();
            clearInterval(stopButton)
        }
    }, 250)
}, 250)
}
//revision (08.20.14): Lets build our buttons to control this so we no longer need the console
//stop button (08.20.14)
var stopButton = document.createElement('button');
stopButton.setAttribute('id', "stopButton");
stopButton.innerHTML = "Stop";
stopButton.style.background = "#800";
stopButton.style.color = "#fff";
stopButton.style.display = "none";
stopButton.onclick = function () {
    clearInterval(window.clearAllFiltered);
    document.getElementById("stopButton").style.display = "none";
    document.getElementById("startButton").style.display = ""
};
//start button (08.20.14)
var startButton = document.createElement('button');
startButton.setAttribute('id', "startButton");
startButton.innerHTML = "Start";
startButton.style.background = "#090";
startButton.style.color = "#fff";
startButton.onclick = function () {
    window.clearAllFiltered = setInterval(function () {
/* revision (07.28.15): Stop the Loop automatically if there are no more items to remove */
        if(document.getElementById("results-header").innerText=="No search results found."){
            document.getElementById("stopButton").click();
            }
        if (document.getElementById("loading-spinner").getAttribute("hidden") !== null) {
            removeItems()
        }
    }, 250); //adjust Time Here (1500 [millisec] = 1.5sec)
    document.getElementById("stopButton").style.display = "";
    document.getElementById("startButton").style.display = "none"
};
/* revision (08.20.14): Now we add our buttons, and we're ready to go! */
editingControls = document.getElementById('editing-controls');
editingControls.appendChild(stopButton);
editingControls.appendChild(startButton);

This removeItems function will select loop through all form inputs and check all checkboxes, enable the "Remove Selected Items" button and click it. After a half-second, it'll check if the "Are You Sure" prompt is displayed and, if so, click the "Yes/Remove" button automatically for you so that it will load a new list of items to do this process all over again..

The item is looped using the variable "clearAllFiltered", which is a setInterval loop, which is checking for the status of the "Loading" screen..

To start erasing your filtered history items, you can now click the green Start button.

** // UPDATE (07.28.2015) It will now stop on ITS OWN.

To stop the loop manually, you can now click the red Stop button. Simple as that!

4
  • I actually just posted an update I wrote for it back last August, if you wanted to try the new code out
    – Jacob Cruz
    Jul 16, 2015 at 23:26
  • The new code doesn't seem to work. I click the start button and the modal window pops up, but before I have a chance to click it, it flashes again with a reload. Nothing gets deleted.
    – Rebecca
    Jul 21, 2015 at 8:22
  • 1
    Thanks for bringing that to my attention @junto I just updated it again, cleaned up some of the text also to clear some confusion
    – Jacob Cruz
    Jul 23, 2015 at 17:23
  • Works brilliantly :)
    – Rebecca
    Jul 24, 2015 at 9:38
1

You can take the hacker shortcut injecting JavaScript code.

Step 1 Since Chrome history is queried inside a iFrame, we have to visit: chrome://history-frame/ (copy and paste URL)

Step 2 Do the search query.

Step 3 Open the Chrome console(F12 or CtrlShifti or i) and execute:

var inputs = document.getElementsByTagName('input');
for (var i = 0; i < inputs.length; ++i) {
  if (inputs[i].type == "checkbox"){
    inputs[i].checked = true;
  }
}
document.getElementById("remove-selected").disabled = false

Step 4 Hit the 'Remove selected items' button.

1
  • 1
    @OliverSalzburg actually if you look carefully is necessary to enable the remove-selected button. Nobody was doing that in the previous answers. Aug 5, 2014 at 15:55

Not the answer you're looking for? Browse other questions tagged .