How to Disable Google Page Preview

by

Google has added a rather distracting feature to their search result pages: A preview of the page you’re about to visit is shown on the right of the results.

I never found any use for the feature, so I wrote a Javascript extension to disable the distracting previews entirely. The source code is provided below for you to modify.

Install
on userscripts.org; works with Greasemonkey on Firefox or Tampermonkey on Chrome or Chromium

google-page-preview.user.js:

// ==UserScript==
// @name          Disable Google Page Preview
// @description   Disables the page preview feature in Google search results.
// @include       http://www.google.tld/*
// @include       https://www.google.tld/*
// @include       https://encrypted.google.tld/*
// @require       http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js
// ==/UserScript==

(function() {
    var resultElem = "div.vsc";
    var previewClass = "vsc";
    var previewButton = ".vspib";
    var previewElem = "div.vspi";

    function processNode(node) {
        if (node.nodeType != 1 || node.hasAttribute("previewHandled"))
            return;

        node.setAttribute("previewHandled", "yes");

        $(resultElem, node).each(function() {
            $(this).removeClass(previewClass);
            $(previewButton, this).remove();
            $(previewElem, this).remove();
        });
    }

    function deploy() {
        document.addEventListener("DOMNodeInserted", function(e) {
            processNode(e.target);
        }, false);

        $(function() {
            processNode(document.body);
        });
    }

    deploy();
})();

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>