Hacking Gmail

(Grace) #1

How Gmail Works


B


y now you’ve learned how to use Gmail with some flair, and
you can change the way it looks to a certain extent. Now
you have to look into exactly how it works. You already
know that the majority of the Gmail functionality is enacted
client-side — that is, on the browser, rather than at the server —
and is done with JavaScript. This chapter describes exactly how
this works and how you can exploit it.

What the Devil Is Going On?


Before revealing just what’s happening, let’s recap. In Chapter 4
you used the DOM inspector inside Firefox to help you dissect
the HTML, and this will help you again. So, as before, open up
Gmail in Firefox, and open the DOM inspector.

You already know that the main document is made of two frames,
the first made of many subframes and the second one with noth-
ing but a huge chunk of JavaScript. Figure 5-1 shows you that in
the DOM inspector.

Using the DOM inspector’s right-click menu Copy as XML
function, you can grab the text of the script and copy it to a text
editor. Ordinarily, I would include this code as a listing right
here, but when I cut and pasted it into the manuscript of this
book, it added another 120 pages in a single keystroke. This does
not bode well, especially as Google has tried as hard as it can to
format the JavaScript as tightly as possible. This saves bandwidth
but doesn’t help anyone else read what Google is doing. We’ll
reach that problem in a page or two.

̨Getting at the code


̨The interface


̨XMLHttpRequest


̨Packet sniffing


The Basics


interface

̨Decoding the data


chapter


in this chapter

Free download pdf