Removing Bad Autocompletes from Firefox's Location Bar (Shallow Thoughts)

Akkana's Musings on Open Source Computing and Technology, Science, and Nature.

Mon, 15 Nov 2021

Removing Bad Autocompletes from Firefox's Location Bar

A priest, a minister, and a rabbit walk into a bar.
The bartender asks the rabbit what he'll have to drink.
"How should I know?" says the rabbit. "I'm only here because of autocomplete."

Firefox folks like to call the location bar/URL bar the "awesomebar" because of the suggestions it makes. Sometimes, those suggestions are pretty great; there are a lot of sites I don't bother to bookmark because I know they will show up as the first suggestion.

Other times, the "awesomebar" not so awesome. It gets stuck on some site I never use, and there's seemingly no way to make Firefox forget that site.

[Bogus firefox urlbar autocomplete] For instance, when I type "feed" into the URL bar, wanting to check on my RSS feeds, the default choice -- the one that's already in the URL bar rather than the drop-down menu, so it's what I get if I just hit return rather than using the menu -- is always feeds.washingtonpost.com.

I haven't visited the Washington Post's feeds page in years (at least not intentionally, as opposed to accidentally going there because Firefox wants me to). I definitely don't have it bookmarked. For one thing, I mostly use RSS feeds from my RSS reader and seldom visit them in Firefox. Also, nothing against the Washington Post -- they publish some good stories -- but their RSS feeds aren't so hot. Their national news feed tends to be heavy on stories like "First she faced her fear of heights, then she took on something even scarier: Remarriage" (actual headline from today's WaPo national feed) and light on actual breaking news.

Firefox is so insistent on getting me to visit the WaPo RSS page that I have often wondered if maybe Mozilla was getting funding from the Washington Post -- but no, I tried a new profile and the WaPo URL didn't appear. So something in my profile was causing it. I have no bookmarks with "washington" in them. Where could it be coming from?

There are scads of discussions all over the web where people ask how to remove URL bar autocomplete entries. The replies always address a different question: how to remove entries from the dropdown menu below the urlbar. Supposedly, you highlight an entry in that menu and press Shift+Delete. I haven't found that to be terribly reliable -- sometimes it works, sometimes the item comes back. But in any case, the highlighted autocomplete that appears in the URL bar apparently comes from a completely different list, and Shift+Delete has no effect on it.

I've searched many times for hints on how to remove an unwanted autocomplete entry, with no success. I decided I needed to go to a lower level, find out where that URL was coming from in my profile, and delete it from my profile without Firefox's help.

The "Places" Database

Firefox profiles are normally in ~/.mozilla/firefox/randomstring.profilename, e.g. ~/.mozilla/firefox/asdf7a6g.default. If you look in your firefox profile, you'll see a file called places.sqlite. That's where Firefox stores your bookmarks and browsing history.

I knew that places.sqlite was often related to this sort of urlbar malfunction: many years ago I cured a similar problem by deleting places.sqlite entirely. But that removes all bookmarks, history, etc. I didn't know back then how easy it is to examine an sqlite file. This time, I wanted a more targeted fix.

You can examine the places database by typing sqlite3 /path/to/places.sqlite. You won't be able to list anything, let alone change anything, while Firefox is running, so either exit Firefox, or make a copy of the file and run sqlite3 on the copy.

You can list all the tables in an sqlite database with .tables:

sqlite> .tables
moz_anno_attributes                    
moz_annos                              
moz_bookmarks                          
moz_bookmarks_deleted                  
moz_historyvisits                      
moz_hosts                              
moz_inputhistory                       
moz_items_annos                        
moz_keywords                           
moz_meta                               
moz_origins                            
moz_places                             
moz_places_metadata                    
moz_places_metadata_groups_to_snapshots
moz_places_metadata_search_queries     
moz_places_metadata_snapshots          
moz_places_metadata_snapshots_extra    
moz_places_metadata_snapshots_groups   
moz_session_metadata                   
moz_session_to_places                  

According to this Mozilla support thread, the two important tables for things like urlbar completion are these:

moz_places => look in the URL column
moz_origins => look in the host column

Searching for Entries

To see if you have any places entries matching a particular pattern:

SELECT * FROM moz_places WHERE url LIKE '%feeds.washingtonpost%';
SELECT * FROM moz_origins WHERE host LIKE '%feeds.washingtonpost%';

Sure enough, I had several matches in both tables.

Deleting Entries

So you've found matches and you want to delete them.

Make a backup of places.sqlite in case you mess up, then run sqlite3:

cp places.sqlite places.sqlite.bak
sqlite3 places.sqlite

Then inside sqlite3, run

DELETE from moz_places where url LIKE '%feeds.washingtonpost%';
DELETE from moz_origins where host LIKE '%feeds.washingtonpost%';
substituting the pattern you're trying to remove. SQL uses % rather than * as a wildcard character.

In my case, that removed the errant washingtonpost suggestion from the list. Now, when I type feeds, the URLbar contains only what I type -- so if I hit return without arrowing down into the suggestion menu, I get a search for feeds in my chosen search engine.

I'm still a bit puzzled about what does control autocomplete entries. I did some more exploring in sqlite3, and it turned out that it was the single entry in moz_origins that controlled the errant autocomplete entry; I didn't actually need to delete the entries in moz_places. But I haven't yet figured out how to add an entry, in case I want an autocomplete when I type "feeds". I'll continue exploring, and will follow up with what I discover.

Tags: , ,
[ 16:54 Nov 15, 2021    More tech/web | permalink to this entry | ]

Comments via Disqus:

blog comments powered by Disqus