How can I delete all web history that matches a specific query in Google Chrome

84

32

In Google Chrome, is it possible to delete all search history that matches a specific query (for example, en.wikipedia.org)?

Anderson Green

Posted 2012-09-27T19:33:06.550

Reputation: 5 214

3

@AndersonGreen Could you please update the accepted answer to http://superuser.com/a/791728/84229 from Fabricio PH. That's the original correct answer. The currently accepted one had simply copied the right answer without attributing any credit. Now it has been reverted back to its original version.

– user – 2015-01-10T19:19:01.077

3

@AndersonGreen You should choose Pooya's as the correct answer, it's the simplest, fastest way to do it. Plus, Fabricio's doing some self advertising on his answer, which isn't complete.

– LasagnaAndroid – 2015-07-15T14:36:15.183

To make it quick: search and then hit "ctrl + a" to select all results – wuppi – 2019-01-07T12:40:59.647

It is possible to select all items in a search from Google Web History. I wonder if it's possible to synchronize Google Web History with Chrome's web history. – Anderson Green – 2012-10-22T18:44:07.150

There's an extension called "Updater for Google Web History" - it appears that this extension allows Google Web History to work in Google Chrome. – Anderson Green – 2012-10-22T18:53:18.060

Answers

64

Update Jan 2019

Now Chrome supports the keyboard shortcut CtrlA or A


Original answer

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.

Actually this deletes the elements in the current page. I might try to extend it, but it's a good starting point. Read the full article in my blog.

Fabricio PH

Posted 2012-09-27T19:33:06.550

Reputation: 818

3This is not working anymore. document.getElementsByTagName('input') is returning empty array. – dinesh ygv – 2016-01-14T07:07:47.140

2@FabricioPH I ran the script in chrome://history instead of "chrome://history-frame, which is why it didn't work for me. It works well inside the frame. – dinesh ygv – 2016-02-21T16:08:11.813

2This is great! At first I ran it in a different tab, which didn't work (in hindsight, for logically attainable reasons.) So I reopend the Console in the same tab as chrome://history-frame, and it all worked. – Jameson – 2016-08-30T05:35:57.610

1very clean and easy solution – danboh – 2017-08-03T19:47:19.087

It says xxxxx:x Uncaught TypeError: Cannot set property 'disabled' of null at <anonymous>:x:xxx – Black Thunder – 2018-09-21T17:31:16.573

2This solution is outdated: simply hit "ctrl + a" – wuppi – 2019-01-12T10:39:11.067

@wuppi You just saved me this should be the correct answer – Pouya Samie – 2019-01-23T18:25:24.047

128

That’s simple & easy.

Search for what you want to remove. Select the first one. Now scroll to the latest result. Press shift & choose the latest one. Now all matches are selected and you can remove them together.


In some cases, removing an address from history results is not enough for stoping that address from appearing in url bar auto suggestions.

In that case visit here : https://superuser.com/a/273280/121184

Pooya Estakhri

Posted 2012-09-27T19:33:06.550

Reputation: 1 516

1

Further information is here: http://superuser.com/a/747816/85129

– Anderson Green – 2014-08-03T03:30:22.367

2Or you can take a hacker shortcut, see my answer below ;) – Fabricio PH – 2014-08-04T14:23:25.523

5@AndersonGreen This is the correct answer, not Fabricio's. – LasagnaAndroid – 2015-07-15T14:38:15.020

This one is not obvious. I expect the text to get selected. – dinesh ygv – 2016-01-14T07:07:06.240

@AdriánSalgado Meh, too much scrolling :P – Matt – 2016-04-07T19:23:14.707

This should be the accepted answer. – Fabian Zeindl – 2017-03-23T21:37:29.497

1"ctrl + a" does select all visible elements – wuppi – 2019-01-07T12:38:15.283

Hmmm Great @wuppi didn't know about that. btw it is fn + Command in mac. you can add your comment as an answer and i'd link to it or if you dont want to do so i can update my answer – Pooya Estakhri – 2019-01-07T15:48:46.113

1one of the answers further down covers that too (found that out after placing my comment) – wuppi – 2019-01-08T17:28:41.530

15

For literal values of "query"...

You can even query your Chrome history using SQL. (Firefox too: see below. Of course, the appropriate file path will have to be changed).

First of all, you need to locate the Chrome History file. This is, on my system, in

C:\Documents and Settings\Leonardo Serni\Impostazioni locali\Dati applicazioni\Google\Chrome\User Data\Default

which ought to translate in a more general

<USER FOLDER>\Local Settings\Application Data\Google\Chrome\User Data\Default

In there, you will find a "History" file. It is a SQLite3 file, and to manipulate it, Chrome has to be closed. If you make a mess of it, delete the History file and start anew - it's just as if you had cleared the whole Chrome history.

Then, rename the file to History.sqlite3 and install SQLiteMan (or any other SQLite3 editor - in Windows, double-clicking on the file might be enough to trigger a suggestion), then open the file (n.b. some utilities might not need the renaming thing. Maybe try without renaming first, to save work).

In the URLS table, you will find the URLs you have visited. For example I can run the query:

SELECT * FROM urls WHERE url LIKE '%meetup%';

to view all occurrences of 'meetup' in either the host or pathname part of the URLs I visited. Or I could search for pr0n, or... anything at all, as long as I adhere to SQL syntax.

You can even use the other information to run the query, for example the time of last visit. Only remember that you need to convert the dates to Chrome time, which is the number of microseconds elapsed from January 1st, year of our Lord 1601. On a Unix box, typing date +%s will tell you the number of seconds; multiply by one million, add 11644473600 and you're done.

For example, select visits after October 1st, 2013:

SELECT * FROM urls WHERE ((last_visit_time/1000000)-11644473600) - 
    strftime('%s', '2013-10-01 00:00:00') > 0;

To delete, just replace SELECT * with DELETE and press F9 to execute the query.

You can use NOW() instead of the current date, and any other SQLite syntax.

(In case, the "Archive History" file holds the last history archived by Chrome).

When you're done, if needed, rename back the file to "History".

Automating it: one-click sanitization

You need a command-line SQLite utility such as sqlite3 or sql3tool. Then you write a script or batch file, modifying the code below with the appropriate paths (you don't want to clear my history leaving yours untouched, do you?):

# ENSURE CHROME IS CLOSED (pskill by SysInternals might be useful)
echo "DELETE * FROM urls WHERE url LIKE '%facebook%' OR url LIKE '%twitter%';" | sql3tool "C:\Documents and Settings\Leonardo Serni\Impostazioni locali\Dati applicazioni\Google\Chrome\User Data\Default\History"
echo "DELETE * FROM urls WHERE url LIKE '%porn%' OR url LIKE '%my-employer-is-a-moron%';" | sql3tool "C:\Documents and Settings\Leonardo Serni\Impostazioni locali\Dati applicazioni\Google\Chrome\User Data\Default\History"
echo "DELETE * FROM urls WHERE url LIKE ..."

Only remember that this erases your history on your instance of Chrome. If, for example, you use a proxy, and that proxy keeps logs, all those URLs will be still available in the logs.

UPDATE: Also, if you're using some brain-dead SQL tool that requires the file to have an explicit and known extension, you will have to perform an appropriate RENAME before starting operations, and another to put things back in order when you've finished:

REN "C:\Documents and Settings\Leonardo Serni\Impostazioni locali\Dati applicazioni\Google\Chrome\User Data\Default\History" "C:\Documents and Settings\Leonardo Serni\Impostazioni locali\Dati applicazioni\Google\Chrome\User Data\Default\History.sqlite3"
echo "DELETE * FROM urls WHERE url LIKE '%facebook%' OR url LIKE '%twitter%';" | sql3tool "C:\Documents and Settings\Leonardo Serni\Impostazioni locali\Dati applicazioni\Google\Chrome\User Data\Default\History.sqlite3"
REN "C:\Documents and Settings\Leonardo Serni\Impostazioni locali\Dati applicazioni\Google\Chrome\User Data\Default\History.sqlite3" "C:\Documents and Settings\Leonardo Serni\Impostazioni locali\Dati applicazioni\Google\Chrome\User Data\Default\History"

Anyway, once this is done, doubleclick on the script icon and hey presto!, your Chrome history is sanitized. It works with Firefox too; its timestamps might be in some other time reference frame, though (possibly plain Unix), so check the water before jumping in.

How about cleaning cookies?

You might want to do the same thing to cookies instead of History.

But you'll have noticed, in the Chrome data directory, other files than History, one of which is named Cookies... :-)

Advanced track covering

The SQL trick above is not limited to deletions. You can modify entries with the UPDATE command; and after deleting unneeded entries, you can use INSERT with the appropriate time and date macros to have Chrome believe that you visited some URLs you did not actually visit, or did not visit at some time and date.

This may come in handy in those cases when sanitizing a browser session would result in an unlikely picture of someone staring glazedly at an empty browser window for a very long time, and some kind of idle navigation is preferable. Of course, this assumes that no one notices that each day there is exactly the same navigation 'template'.

LSerni

Posted 2012-09-27T19:33:06.550

Reputation: 7 306

The command would be "DELETE from URL ..." – Anwar – 2017-12-27T18:58:36.743

3

By holding shift and clicking at the first url checkbox and then scrolling down to the last one. This tells google to select all posts in between. You then hit "delete" and Voila history gone for that specific URL

Meron

Posted 2012-09-27T19:33:06.550

Reputation: 31

Welcome to SuperUser Meron. While this may be valid, it duplicates information posted in at least two other answers. – bertieb – 2017-02-19T21:37:46.773

2

To add to Fabricio PH's awnser, this should be clear all pages of results for a given search on the chrome://history-frame page when pasted into the devtools console:

var clearHistoryPage, historyInterval;

historyInterval = null;

clearHistoryPage = function() {
  var i, input, inputs, len, spinner;

  // If spinner is visible a new page is still loading
  spinner = document.getElementById('loading-spinner');
  if (!spinner.hasAttribute('hidden')) {
    console.log("Waiting on load");
    return;
  }

  inputs = document.getElementsByTagName('input');
  // When no history is present 5 inputs are still present on the history frame page
  if (inputs.length <= 5) {
    console.log("Found 5 or less inputs, stopping");
    clearInterval(historyInterval);
    return;
  }

  console.log("FOUND " + inputs.length + " results, clearing");
  for (i = 0, len = inputs.length; i < len; i++) {
    input = inputs[i];
    if (input.type === 'checkbox') {
      input.checked = true;
    }
  }
  document.getElementById('remove-selected').disabled = false;
  document.getElementById('remove-selected').click();
  document.getElementById('alertOverlayOk').click();
};

historyInterval = window.setInterval(clearHistoryPage, 5000);

Thom

Posted 2012-09-27T19:33:06.550

Reputation: 21

2

You can either visit chrome://history or chrome://history-frame. On the page you can start searching and when all results are listed simply hit CTRL + A to select all visible items. Pressing it again deselects all items.

With the selected items simply delete them via DEL key.

Ralph Segi

Posted 2012-09-27T19:33:06.550

Reputation: 21

1

If you come across this topic from google, there is an easier way to delete multiple items now.

Gwendal

Posted 2012-09-27T19:33:06.550

Reputation: 111

this method doesnt work – Woeitg – 2016-12-23T09:34:41.083

1

Type the url you want to remove in the history tab as in the screenshot below, toggle the developer console(mac: opt+cms+i) and select the <iron-list element. Then toggle the js console(esc), and type the following code in the console:

$0.querySelectorAll('history-item').forEach(_ => _.root.querySelectorAll('cr-checkbox').forEach(_ => _.click()))

It should select all the visible elements. Click on delete, and repeat until the list is empty or chrome gives a strange error.

history tab

yesil

Posted 2012-09-27T19:33:06.550

Reputation: 111

1

You can open the Chrome menu - then move to the history - if you need to delete all visits to the particular site so you put the name of the domain in the required filed or press three dots on the right from the required domain if you found it manually and choose all inputs related to this domain - press clean history. Maybe you can find more information relevant to your question here freewindows10.download

Lisa Philips

Posted 2012-09-27T19:33:06.550

Reputation: 19

1

No, that is currently not supported by Chrome itself.

Though, extensions can request access to your history data. So it would be possible for an extension to fulfill your needs. I do not know of such an extension myself, but a small search, made me find this one:

https://chrome.google.com/webstore/detail/gjieilkfnnjoihjjonajndjldjoagffm

Possibly that extension can do what you request.

Steven Roose

Posted 2012-09-27T19:33:06.550

Reputation: 166

No extension needed, check my answer :) – Fabricio PH – 2014-08-03T02:38:50.743

2

This answer is outdated - see this one or this one

– Garrulinae – 2014-04-30T06:32:49.050

I cannot delete it either, sorry – Steven Roose – 2014-05-06T07:23:39.110

That's fine - I'm just pointing it out for future viewers. – Garrulinae – 2014-05-06T08:33:02.123

The sad thing is that I lose rep for this :p – Steven Roose – 2014-05-07T11:59:32.580

1

Just use Chrome with the url : chrome://history/#e=1&p=0

You may have to copy/paste it into your url bar.

Hugolpz

Posted 2012-09-27T19:33:06.550

Reputation: 129

1

In the Chrome bar try searching for the history item you want deleted. Once it appears in the results, scroll down to it using arrow keys (even if it is the first item in the list) and press Shift + Delete.

Dejan Milosevic

Posted 2012-09-27T19:33:06.550

Reputation: 111

0

  • open chrome:history and search for the website(s) that you want to delete.
  • open your chrome console with ctrl-shift-j.

  • if applicable, ensure that the dropdown right above the console reads history (history-frame) and not top, etc.

  • run the following code in the console:

$$('input[type=checkbox]').forEach(el => el.checked = true); $("remove-selected").disabled = false;

Sethicus

Posted 2012-09-27T19:33:06.550

Reputation: 1

0

If Fabricio's code doesn't work for you I found that this code is working and additionally clicking the "remove selected" button for me so the only thing i have to do is to click confirmation dialog.

document.querySelectorAll('.entry-box input[type="checkbox"]').forEach(function(input) {
  input.checked = true;
});

document.getElementById("remove-selected").disabled = false
document.getElementById("remove-selected").click()

Pavelloz

Posted 2012-09-27T19:33:06.550

Reputation: 101

0

  1. Click on the first checkbox.
  2. Scroll down to bottom of page.
  3. Hold shift and click on the last checkbox.
  4. All checkbox will be selected; Scroll to top, where "Remove Selected Items" button is present.
  5. Click on button. Selected items will be deleted :)

Nikhil Shukla

Posted 2012-09-27T19:33:06.550

Reputation: 11

Welcome to super user. I would suggest that questions like these are not the best to answer! Other answers already have the options on how to do this including your method. – Lister – 2016-08-04T09:57:06.443

0

Use the following:

function hasText(a){
    if(a.innerText){
        return true}
    else{
        return false}
}

function isCheckbox(element){
    if(element.type=='checkbox'){
        return true
    }
}

function removeItemsofQuery(query){
    var element=document.getElementsByClassName('entry-box')
    var checkbox=[]
    var titles=[]
    for(i=0; i<element.length; i++){
        var children=element[i].children
        for(j=0; j<children.length; j++){
            if(hasText(element[i].children[j])==true && element[i].children[j].className!="time" ){
                var ds=element[i].children[j].innerText
                titles.push(ds)
            }
            if (isCheckbox(element[i].children[j])==true){
                var hg=element[i].children[j]
                checkbox.push(hg)
            }
        }
        }

    for(g=0; g<element.length; g++){
        var queries=titles[g].indexOf(query)
        if(queries>0){
            checkbox[g].checked=true
        }
    }
    var RS=document.getElementById('remove-selected')
    RS.disabled=false
    RS.click()
}

Put it into the chrome browser console one the history FRAME page. Not regular history, but the history FRAME. Then, call the function removeItemsofQuery, and input the term you want to search for and remove as the argument. Press enter, and press the final remove button. Then, you're done. Congratulations.

Damphair

Posted 2012-09-27T19:33:06.550

Reputation: 1

0

Start writing the term that you want to search for, when the unwanted term appears use the up and down arrow to go to that term and press Shift + Delete.

Nikolaos Mallios

Posted 2012-09-27T19:33:06.550

Reputation: 1

0

function sleep(ms) {
    return new Promise(resolve => setTimeout(resolve, ms));
}
async function selectAll() {
    var count = 0;
    var inputs = document.getElementById("history-app").shadowRoot.getElementById("history").shadowRoot.getElementById("infinite-list").children;

    for (var i = 1; i < inputs.length; ++i) {

        if (inputs[i].shadowRoot.getElementById("checkbox").getAttribute('aria-checked') == "false") {
            inputs[i].shadowRoot.getElementById("checkbox").click();
            count++;
            await sleep(20);
        }
    }
    if (c > 0) selectAll()
}
selectAll()

konstruktor

Posted 2012-09-27T19:33:06.550

Reputation: 9

1Please explain (in English words) how this answers the question. – G-Man Says 'Reinstate Monica' – 2018-04-30T22:25:54.310

Go to chrome://history , search what you want, open Chrome Console, copy & paste the code above to select all – konstruktor – 2018-08-06T09:24:12.643

0

// Tested on Chrome Version 72.0.3626.119 (Official Build) (64-bit)
// 1) Open Chrome browser history.
// 2) Search for specific history you want to delete.
// 3) Cut-and-paste the code below in the Chrome Browser console.
// Enjoy!

(function (){
let historyApp = document.getElementById("history-app");
historyApp.items[0].selectAllItems();

// Delete history with a popup confirmation prompt
historyApp.deleteSelected();

// Delete with no prompt
// historyApp.items[0].deleteSelected_()  

})();

Mark Code

Posted 2012-09-27T19:33:06.550

Reputation: 1

0

Use this extension in Google Chrome: History Calendar

Its exactly what I was searching for... it makes history deleting etc just like firefox i.e. fast and smooth. If you have over 2000 history marks for sites like amazon.com, google chrome history viewer will take ages (go page by page), but in firefox history window (or using the above mentioned chrome extn), you can select all 2000 and delete in one go

Jatin Grover

Posted 2012-09-27T19:33:06.550

Reputation: 1

It shows 404 on that link – Anwar – 2017-12-27T19:03:42.177