title: Reverse Engineering the DOM, Javascript events & "what's going on"?
body: <p>I'm trying to figure out what's going on in the javascript of Google's live page preview. </p>
  
  <p><a href="https://stackoverflow.com/questions/4239792/why-arent-the-links-im-adding-to-the-dom-with-javascript-clickable">Why aren&#39;t the links I&#39;m adding to the DOM with Javascript clickable?</a> (for a bit more context) </p>
  
  <p><a href="http://chesser.ca/2010/11/google-visual-image-search-hack-marklet/" rel="nofollow noreferrer">http://chesser.ca/2010/11/google-visual-image-search-hack-marklet/</a> for the "latest demo" </p>
  
  <p>If you search on google, the results come up on page via live search.  Then, if you mouseover one of the magnifying glasses in your result set, a number of things happen.</p>
  
  <ol>
  <li>the mousover event for the magnifying glass fires</li>
  <li>this calls an (as of yet) unknown function with unknown parameters</li>
  <li>the function makes a cross-site call to google's image results query server</li>
  <li>those results are stored in google's VS class memory `google.vs.ha`</li>
  </ol>
  
  <p>I've copied the code from google's library and run it through an un-minifier so it's slightly more readable.  I've also installed breakpoints in the code through firebug so I can inspect the dom &amp; memory space before during and after I load the page.</p>
  
  <p>My end goal is to be able to replicate the <code>mousover</code> event in code by calling the same function that is called - but - I'm stuck in trying to find the right function. (i'm sure it involves <code>google.vs.Ga(a, b, c)</code> but I'm just not quite there yet.</p>
  
  <p>I know this is pretty much the craziest obsession ever - but - I dunno.  Maybe if you're also reading stack on a Sunday you understand :)</p>
  
  <p>What function is being called "On Hover" that sends out the command to get the image requests?</p>
  
  <p>EDIT:
  There are a few upvotes on this so far tho I thought I'd add a bit more background to anyone wanting to catch up in firebug, you can follow what's happening in javascript at any time.</p>
  
  <p><img src="https://imgur.com/fODwR.png"/></p>
  
  <p>Is a picture of what google looks like "in memory" you can look at all of the functions and calls and the current state of variables.</p>
  
  <p>You can also actually access and call those variables by putting links in your bookmarks bar.  for example <code>javascript:alert(google.base_href)</code> after a search will tell you the URL you're at... and it gets way more exciting from there.</p>
  
  <p><strong>EDIT NUMER 2:</strong></p>
  
  <p>a huge thanks to Matt who managed to crack this in one go :) </p>
  
  <pre><code> &lt;a href="javascript:
       (function(){
           var all_divs = document.getElementsByTagName('div');
           for (i=0;i &lt; all_divs.length; i++) {
               if (all_divs[i].className == 'vsc') {
                   google.vs.ea(all_divs[i]);
               }
           }
       })();"&gt;test all vsc&lt;/a&gt;
  </code></pre>