I wrote a script to delete URLs containing a string from Chrome’s history. It works for me. I don’t understand everything that it does, though, so it may have serious flaws. Use at your own risk.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# Removing history entries from Chrome that contain a search phrase
# Exit out of Chrome first
# Back up files and do this at your own risk
 
# gem install sqlite3 && gem install sequel
 
require 'sequel'
 
search_string = 'reddit'
 
# Delete history cache files
path = File.expand_path('~/Library/Application Support/Google/Chrome/Default')
cache_dirs = Dir.entries(path).select {|dir| dir != 'History' && dir.index('History') == 0}.map {|dir| File.join path, dir}
cache_dirs.each {|dir| File.delete dir}
 
# Delete matching history from sqlite3
DB = Sequel.sqlite File.join(path, 'History')
matching_urls = DB[:urls].filter(:url.like("%#{search_string}%"))
puts %Q[Deleting #{matching_urls.count} urls matching "#{search_string}"]
matching_urls.delete

I really like sqlite and Sequel.