// ==UserScript==
// @name          Google Heading Adjuster
// @description   Customize Google search headings
// @namespace     http://www.gozer.org/mozilla/greasemonkey/
// @include       http://*.google.com/*
// ==/UserScript==

if (!document.getElementById('gbar'))
  return;

// headings as of 05-16-2007
var list = [
            ['w', 'Web', 'http://www.google.com/search', 1],
            ['i', 'Images', 'http://images.google.com/images', 1],
            ['v', 'Video', 'http://video.google.com/videosearch', 1],
            ['n', 'News', 'http://news.google.com/news', 1],
            ['l', 'Maps', 'http://maps.google.com/maps', 1],
            ['m', 'Gmail', 'http://mail.google.com/mail', 1],
            ['', 'more', '#', 3],
            ['b', 'Blog Search', 'http://blogsearch.google.com/blogsearch', 2],
            ['j', 'Blogger', 'http://www.blogger.com/', 2],
            ['p', 'Books', 'http://books.google.com/books', 2],
            ['c', 'Calendar', 'http://www.google.com/calendar', 2],
            ['o', 'Documents', 'http://docs.google.com/', 2],
            ['e', 'Finance', 'http://finance.google.com/finance', 2],
            ['g', 'Groups', 'http://groups.google.com/groups', 2],
            ['z', 'Labs', 'http://labs.google.com/', 2],
            ['0', 'Orkut', 'http://www.orkut.com/', 2],
            ['t', 'Patents', 'http://www.google.com/patents', 2],
            ['q', 'Photos', 'http://picasaweb.google.com/lh/searchbrowse', 2],
            ['f', 'Products', 'http://www.google.com/products', 2],
            ['y', 'Reader', 'http://www.google.com/reader', 2],
            ['s', 'Scholar', 'http://scholar.google.com/scholar', 2]
           ];

var match = document.location.href.match(/^([^?&#]+)/);

var href = (match) ? match[1] : document.location.href;

for (var i = 0; i < list.length; i++)
  if (list[i][2].indexOf(href) != -1)
    list[i][2] = '';

var js = '';

for (var i = 0; i < list.length; i++)
  js += "['"+list[i][0]+"','"+list[i][1]+"','"+list[i][2]+"',"+list[i][3]+"],";

var s = document.createElement('script');
s.innerHTML = "document.getElementById('gbar').innerHTML=window.gbar.getHtml([" + js + "]);";
document.body.appendChild(s);
