Disabling (Fixing) Google’s New Instant Preview

11-12-10

Google's Instant Preview

UPDATE: It looks like Google just rolled out an update that breaks this fix. The good news is that Google has MOSTLY fixed the problem, in that clicks in blank space will clear the pane, and a second click on the button will toggle it off. The behavior is now inline with every aspect of the revised specification below, except that it is still too aggressive about which locations can open the preview pane (meaning that the panel can still appear unexpectedly.) I’ll post updated code as soon as possible.

I can’t like the search preview feature. I tried, I really did, but less than 72 hours after its release, I found that my sanity was already slipping away. I knew it was bad when I considered switching to Bing just to avoid the problem. In a fit of senility I used Google (again!) to search for a solution to my problem. Among the various obscenities directed at Google’s latest experiment, the words “can’t” and “impossible” seemed to appear more than occasionally, earning the solution a place on a blog of impossible things.

The Fix (A.K.A How to disable Google’s instant preview)

The feature is annoying enough that initially, most people just want to totally disable it. Actually though, if the behavior is just fixed to work sensibly, disabling isn’t needed. You can have access to the preview feature if you ever want it, but there’s no chance it will get in your way.

First, you’ll need Firefox and Greasemonkey; you can install the plugin at https://addons.mozilla.org/en-US/firefox/addon/748/. Supposedly Chrome supports this, but the script seemed to only work intermittently in Chrome, and I don’t use Chrome enough to make it worth the effort to debug twice. If you are still on Internet Explorer, an immediate upgrade to Firefox will add spring to your step, and make you feel 10 years younger.

After installing Greasemonkey, go to Tools->Greasemonkey->New User Script. The only important thing is that you set the namespace to “http://*.google.*” (without quotes). You can use whatever you like for the other fields. Firefox will ask what program you want to use to edit the script. Since you’ll just be pasting it, notepad should be fine (C:\Windows\System32\notepad.exe).

Paste the following as your script, save, and refresh Google:

// ==UserScript==
// @name           Disable Instant Preview
// @namespace      http://*.google.*/*
// @include        http://*.google.*/*
// ==/UserScript==

//*************************************************************************
// Script to make Instant Preview work the way it was designed to.
//
// According to the documentation, it is supposed to show the preview ONLY
// if the preview icon is clicked. In reality, it shows the preview when
// any part of the search result is clicked.
//*************************************************************************

setTimeout(function(){
    unsafeWindow.disable_instant_preview = true;

	var divs = document.getElementsByTagName("div");
	for (var key in divs)
	{
		var e = divs[key];
		if (e.getAttribute('class') == 'vspi' || e.getAttribute('class') == 'vsc')
		{
			// register a listener so that if the BUTTON is clicked (and nothing else) we get the preview
			e.addEventListener('click', function(evt) {
				// Toggle preview if the preview button itself is pressed
				if (evt.target.getAttribute('class') == 'vspib')
				{
					unsafeWindow.disable_instant_preview = !unsafeWindow.disable_instant_preview;
				}
				if (unsafeWindow.disable_instant_preview && evt.target.tagName != 'A' && evt.target.tagName != 'BUTTON')
				{
					evt.stopPropagation(); // don't let google have it
				}
			}, true);
		};
	}

	// And finally, allow ourselves to re-disable it by clicking on the x
	document.getElementById("vspci").addEventListener('click', function() {
		unsafeWindow.disable_instant_preview = true;
	}, true);

	// because the preview is a lot like a bubble, when the relevant area
	// loses focus, we should kill it.
	document.getElementById("res").addEventListener('blur', function() {
		unsafeWindow.disable_instant_preview = true;
	}, true);

}, 10);

The Reason It Is Better

The word “better” nearly always deserves quotes (in a Mark Twainesque sort of way) and usually leaves me with an overwhelming desire to exclaim “Kumtria!” Joking aside though, this really is better, and a short look at the user interface will demonstrate why. Google’s instant preview feature suffers from a few major flaws:

  1. It causes almost the entire page to respond (relatively spectacularly) to clicks, even though 90% of that area does not look clickable. This is a cardinal sin in UI design. The problem is that the spectacular result of the click, no matter how interesting, is unexpected. Unexpected stuff interrupts. Users don’t like interruptions. The users become unhappy.
  2. The feature is highly invasive, but there is no option to disable it. Users would live with #1 if they could disable it. When they can’t, they switch to Bing (literally).
  3. It doesn’t work the way the documentation says it does, and even the documented behavior isn’t 100% the way a user would expect. The documented behavior has two main flaws:
    • The preview is displayed using an interface that users will associate with bubbles, or tooltips. Because it is displayed as a result of a click, it is expected that a click elsewhere (loss of focus) will dismiss it for good, unless summoned again by a similar click. The documentation says that only clicking on the X will do this, but the X is hard to find (I didn’t even notice it until after reading the documentation.)
    • A reasonable number of users will be likely to treat the icon as a toggle (both enables and disables, depending on state) because most interfaces that generate popups can be toggled in the same way.

Since neither the current or documented behaviors is acceptable, a new behavior must be defined that satisfies all needs:

  1. Clicking on the preview icon displays the preview area. No other click will enable it.
  2. If the preview area is visible, clicking the icon again dismisses it.
  3. Clicking on the X dismisses the preview area
  4. Clicking anywhere outside the search results dismisses the preview area

The fix works because it modifies the behavior to conform to this new specification.

Massive credit goes to Arpit at http://www.ghacks.net/2010/11/11/how-to-disable-google-instant-previews/ who first suggested using Greasemonkey to solve the problem. The script he/she linked to didn’t work, and wasn’t designed to solve the real problem, but without this suggestion, a fix would not have been possible.

UPDATE: I’ve posted a fix for the fix. The original version was causing problems with Ctrl+click.

http://*.google.*

This entry was posted on Friday, November 12th, 2010 at 10:38 am and is filed under Impossible Things, Programming, Web Development. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

10 Responses to “Disabling (Fixing) Google’s New Instant Preview”

  1. thanks, this works great!
    Google is becoming more and more annoying with all these useless new “features”

  2. Anyone else having issues with this not working (Nov. 14)?

  3. You could just try

    var spyglass = document.getElementsByTagName(“button”);

    for (var i=0;i<spyglass.length;++i)

    {

    if ( spyglass[i].getAttribute('class') == 'vspib')

    {

    spyglass[i].parentNode.removeChild(spyglass[i])

    }

    }

    or so. This completely nukes the 'feature'. If I find out which script tag to nuke to pull out this nonsense, I'll add it to the nuke list.

  4. @Delila, Are you using FF 3.6 with Greasemonkey installed? Can give more detail about exactly what isn’t working?

  5. @Kits, Removing the button doesn’t eliminate the behavior. Google bound the click event on the main div for each result (vspi). Removing the button doesn’t stop that event from firing when you click in “blank” space.

    Additionally, I wanted the option to still use the preview if I actually wanted it. The purpose was to repair the feature so that it works the way a user would expect.

    My code actually removes the behavior from everything EXCEPT the button, so the button becomes the only way to actually get the preview to show (which is sort of the inverse of your suggestion).

  6. THANK YOU! It works on FF4 with no problem so far. This is the way it should behave. It wouldn’t piss me off so bad it if just WORKED THE WAY IT SHOULD, instead of bringing up the preview whenever you click anywhere and then having to hit the tiny X. THANK YOU!

  7. Thanks Ben. You just made my day.

  8. It works, I love it! Thank you.

  9. what is happening is that this works fine UNTIL you click on the magnifying glass, no random clicks calls the preview UNTIL after you click for a preview with the eyeglass icon, once you click it off by clicking anywhere (a desired feature), then the page is back to ANY random click brings up the preview again. the desired behavior doesn’t ‘stick’ once you use the icon once and turn it off. you must reload the page after each use of the preview magnifying glass icon to turn on one (1) preview and turn it off again. if you hover over a result, that one’s eyeglass icon turns a brighter blue. when you click off a preview, they ALL highlight for a sec before going grey again, and then its like they all (each result’s) are ‘active’ for a click, which results in the google default behavior anyway.

    Is there any way to fix that?

  10. @Jon, I tested that case specifically when I first crafted this code and it worked then. It looks like something that Google changed since then has partially broken #3 and #4 in my revised requirements. In many respects, given that this is really a hack for something not under my control, it is a pleasant surprise that it still works at all.

    I’ll look into this when I get a chance and try to make those last two cases work properly again. Until then, toggling off by clicking the magnifying glass again DOES work, so if you open the preview, click the magnifying glass again to dismiss it. Certainly not ideal, but better than nothing until I can find time to update the code.

Leave a Reply

 
WordPress SEO fine-tune by Meta SEO Pack from Poradnik Webmastera