How to remove entries from Firefox Smartbar

I really got to love the Smartbar aka Awesomebar, introduced in Firefox 3. But in some way it annoyed me that there is no really obvious way to remove entries from it. Sure, after a bit of research via Google I found out, that you can press shift+delete while hovering with your mouse over an entry. But this doesn't help much if you want to get rid of all entries for a given domain or containing a specific keyword - so this may get kind of tedious. It also seems, that there isn't even a single Add-on which can deal with this. If I missed something, please drop me a quick note.

Nevertheless, being a part-time hacker I also couldn't overlook, that Firefox is saving lots of the data it stores on your workstation in SQLite databases. And where is SQL, there is rescue!

So, first step - where are those database files? On Mac OS X, they are usually located in

~/Library/Application\ Support/Firefox/Profiles/<some string>.default/

The one you want to hassle with is named

places.sqlite

Note, from now on you have to work while Firefox isn't running. Otherwise, the SQLite database is locked and you can't access it. But let's get to business - we're interested in the following table:

  1. fh$ sqlite3 places.sqlite
  2. SQLite version 3.4.0
  3. Enter ".help" for instructions
  4. sqlite> .schema moz_places
  5. CREATE TABLE moz_places (id INTEGER PRIMARY KEY, url LONGVARCHAR, \
  6. title LONGVARCHAR, rev_host LONGVARCHAR, visit_count INTEGER DEFAULT 0, \
  7. hidden INTEGER DEFAULT 0 NOT NULL, typed INTEGER DEFAULT 0 NOT NULL, \
  8. favicon_id INTEGER, frecency INTEGER DEFAULT -1 NOT NULL, \
  9.  last_visit_date INTEGER);
  10. CREATE INDEX moz_places_faviconindex ON moz_places (favicon_id);
  11. CREATE INDEX moz_places_frecencyindex ON moz_places (frecency);
  12. CREATE INDEX moz_places_hostindex ON moz_places (rev_host);
  13. CREATE INDEX moz_places_lastvisitdateindex ON moz_places (last_visit_date);
  14. CREATE UNIQUE INDEX moz_places_url_uniqueindex ON moz_places (url);
  15. CREATE INDEX moz_places_visitcount ON moz_places (visit_count);
  16. sqlite>

The url column holds the complete URL Firefox shows in the Smartbar, so we can simply write a quick query:

  1. sqlite> SELECT url FROM moz_places WHERE url LIKE '%bbc.co.uk%';
  2.  
  3. http://news.bbc.co.uk/go/rss/-/2/hi/middle_east/8372985.stm
  4.  
  5.  
  6. http://news.bbc.co.uk/go/rss/-/2/hi/asia-pacific/8372795.stm

If I wanted to get rid of them this query would do:

  1. DELETE FROM moz_places WHERE url LIKE '%bbc.co.uk%';

Replace the domain accordingly, backup your places.sqlite before changing anything and you're good.

The location of places.sqlite on other OS:

Windows XP

C:\Documents and Settings\<username>\Application Data\Mozilla\Firefox\
  Profiles\<profile folder>\places.sqlite

Windows Vista

C:\Users\<user>\AppData\Roaming\Mozilla\Firefox\Profiles\
  <profile folder>\places.sqlite

GNU/Linux

/home/<user>/.mozilla/firefox/<profile folder>/places.sqlite

If you're on an OS which doesn't ship with any SQLite interface, go to the SQLite website and download it. Or, if that is to much hassle for you, there is a Firefox Add-on, called SQLite Manager, which can access and change SQLite databases too. But remember: you have to work on a copy of places.sqlite as the file is locked while Firefox itself is running.