To begin with, here is the code that executes the bookmarklet:
(function(){ EN_CLIP_HOST = 'http://www.evernote.com'; try{ var x = document.createElement('SCRIPT'); x.type='text/javascript'; x.src = EN_CLIP_HOST + '/public/bookmarkClipper.js?' + (new Date().getTime()/100000); document.getElementsByTagName('head')[0].appendChild(x); } catch(e) { location.href = EN_CLIP_HOST + '/clip.action?url=' + encodeURIComponent(location.href) + '&title=' + encodeURIComponent(document.title); }
}) ();
What he does is relatively simple. It tries to grab the script from the Evernote website and adds a timestamp to the request so that it always retrieves a new copy. If this succeeds, a bunch of JavaScript is added to the page, which builds an iframe from which all Evernote functionality is called, and the iframe can then use standard cookies, etc., to make sure you are logged in and then process the request.
The catch block, just in case a dynamic script download fails, as a result of which you are redirected to the Evernote website, therefore (I assume) that it can clip the content from there.
To answer a specific question about how you are still logged in, you are still logged in because your browser now has session cookies for the Evernote website (www.evernote.com), so when the iframe opens on the second site, these cookies come with it, and Evernote acknowledges that you are logged in. The use of cookies is pretty much the standard for sessions on the web, so they don't do anything special here, and I'm sure you can look for SOs for security issues related to cookie sessions.
The main thing is that the iframe is essentially like opening a separate window, except that it allows you to transfer some limited data to the base page in the iframe so that it knows which website you are on.
Hope this helps.
source share