I'm learning some interesting stuff at FluentConf and I'll talk more about that when the conference wraps, but I want to share something I found yesterday that I thought was really freaking cool. It is a Chrome extension called Momentum. Apparently this was all over the place a few weeks ago so I'm late to the party, but it replaces your "New Tab" screen with an absolutely beautiful (and somewhat useful) design:

nt1

You can customize it a bit, but really, it's just that - a beautiful picture and a greeting. The text, "Patience", comes from the app prompting you the first time you open a a new tab in the morning:

nt2

Which - ok - maybe it is a bit dorky - but I like it. I was also a bit curious about how it worked. Chrome extensions are built with web standards, so I decided to take a quick look at the code.

To find your Chrome extensions, you first need to find where your profile is. Open up chrome://version and you'll see a "Profile Path" folder. Get to that directory and then enter the Extensions folder. Here you'll see this wonderfully helpful list of directories (obviously different for each user):

shot1

Ok, wow, so, now what? Well next go to your Chrome extensions tag (chrome://extensions/), and find the extension. Make note of the ID value:

shot2

You would then enter the directory with the same ID as the extension. At this point, you can dig through the assets and see how they do - well - what they do.

shot3

What I found out about Momentum is that the background images are stored locally, which makes sense because you could be offline, and they ship quite a few of them. I also took a look at their JavaScript libraries to see how they built it. It is a Backbone app which is cool, but not a framework I'm really interested in anymore.

The core logic was minified, but that doesn't really slow you down. I opened a new tab, and then opened dev tools. I went to the minified file and clicked Pretty Print:

shot4

Which then gave me nice, readable text:

shot5

I then selected all and copied into an editor so I could go through it in a proper tool. For me, the real interesting tidbit I found was how they handle weather. They use YQL, a Yahoo API I've blogged about before, but I really don't see many people using. It is a very cool API so I'm happy to see it in action. If your curious how they use it, this is the block that grabs your current weather:

function n(e) {
    var t = "https://query.yahooapis.com/v1/public/yql?q=" + encodeURIComponent("select * from weather.forecast where woeid=" + e + ' and u="' + s.model.get("unit") + '"') + "&format=json&callback=?";
    $.getJSON(t, function(e) {
        if (e && e.query && 1 == e.query.count) {
            var t = e.query.results.channel.item.condition;
            t && s.model.save({temperature: t.temp,code: t.code,condition: t.text,updated: new Date})
        } else
            console.log("Error getting weather data: Result count not equal to one")
    }).error(function(e) {
        console.log("Error getting weather data: " + e)
    })
}

Yes - the YQL API is SQL like for data. Very cool stuff. Anyway, check out the extension, and don't forget you can dig into the code and learn from them as well!