Tay Ray Chuan home archive

Mozilla Firefox: how to restore deleted site/thumbnail on New Tab

Sun, 5 Aug 2012 01:06:46 +0800 | Filed under howto

Firefox now features a nifty "new tab page". You can drag around the thumbnails, remove them...oops, I accidentally removed one, how do I get it back?

The options according to Mozilla don't sit well with me. There must be a better way to do it!

Read the source, Luke

From http://www.codinghorror.com/blog/2012/04/learn-to-read-the-source-luke.html

Read the source, I did. Reading through the XUL script and its relevant dependency, I was pleasantly surprised by the well-documented code. I was also surprised to see some cutting-edge JS like const and let.

Back to the code: the term in the code for removing links from the new tab is to "block" them. These are "saved" too so the removal persists between browser sessions. At this point the API to block/unblock links was fairly obvious. The procedure below illustrates the API in action:

  1. Go to Tools -> Web Developer -> Web Console, or hit Ctrl-Shift-K.

  2. Type gBlockedLinks.links (should autocomplete as you type) hit Enter. A mass of URLs should show up on the console.

  3. You'll need to have the URL you want to restore handy - character-for-character. You may look for it like this:

    gLinks.getLinks().filter(function(link) { return link.url.match(new RegExp("faceBOOK","i")); });

    where the i in the RegExp(...) on the first line says to "search case-insensitively" (so facebook would match).

    I didn't have much luck selecting the URL from the output in the previous step, so you'll most probably be typing it character for character.

    Keep tuning the search string till you've whittled it down to one or two. Then press UP and add this in front of the line:

    var links = ...

    Check that the URL is indeed blocked with


    where the 1 is for the second link (count from 0) - it should return true.

  4. drum-roll Press UP and replace isBlocked with unblock, so the command looks like gBlockedLinks.unblock(...). VoilĂ ! Refresh your new tab page.

blog comments powered by Disqus