Here's a discussion about how the screenshot functionality works (which is the part that I think everyone here is impressed with).
http://stackoverflow.com/questions/4912092/using-html5-canva...
tl;dr JavaScript can read the DOM and render a fairly accurate representation of that using canvas
Every one who is interested in that should take a look at the great html2canvas library: