I'm trying to figure out what's going on in the javascript of Google's live page preview.
Why aren't the links I'm adding to the DOM with Javascript clickable? (for a bit more context)
http://chesser.ca/2010/11/google-visual-image-search-hack-marklet/ for the "latest demo"
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.
- the mousover event for the magnifying glass fires
- this calls an (as of yet) unknown function with unknown parameters
- the function makes a cross-site call to google's image results query server
- those results are stored in google's VS class memory `google.vs.ha`
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 & memory space before during and after I load the page.
My end goal is to be able to replicate the mousover
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 google.vs.Ga(a, b, c)
but I'm just not quite there yet.
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 :)
What function is being called "On Hover" that sends out the command to get the image requests?
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.
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.
You can also actually access and call those variables by putting links in your bookmarks bar. for example javascript:alert(google.base_href)
after a search will tell you the URL you're at... and it gets way more exciting from there.
EDIT NUMER 2:
a huge thanks to Matt who managed to crack this in one go :)
<a href="javascript:
(function(){
var all_divs = document.getElementsByTagName('div');
for (i=0;i < all_divs.length; i++) {
if (all_divs[i].className == 'vsc') {
google.vs.ea(all_divs[i]);
}
}
})();">test all vsc</a>