Monday, January 11, 2010

Chrome userscript to hide iGoogle search header


I found it annoying how much screen real-estate the iGoogle search header and footer took up so I created a quick little userscript to solve this. The script which you can install directly by clicking here, hides the search header on page load and puts a small expander [+] icon in the top links bar to show the header to perform searches, looking something like the following:

The source of this script can be expanded below:



iGoogle Tweaks Source
// ==UserScript==
// @name          iGoogle tweaks
// @author        Eric Hoffman
// @description   Toggle showing Search header, hides footer.  Parts based on script by Mikel G√≥mez - http://ikax.net?contact
// @version       1.0.0
// @namespace     electronicrandomness.blogspot.com
// @include       http*://www.google.com/ig*
// ==/UserScript==

// Initially hide header
var hdr = document.getElementById('nhdrwrapinner');
if(hdr) {
  hdr.style.display = 'none';
}

// Top links bar.
var b = document.getElementsByClassName('gb1');
if(b[0] && b[0].parentNode) {
  var w = b[0] ;

  // Create show search link.
  link = document.createElement('a');
  link.title = 'Show Search';
  link.href= 'javascript:void(0)';
  link.className = 'fmaxbox' ;
  w.parentNode.insertBefore(link, w);
  link.setAttribute("onclick", "if (this.className=='fmaxbox') {document.getElementById('nhdrwrapinner').style.display=''; this.className='fminbox'; this.title='Hide Search'} else {document.getElementById('nhdrwrapinner').style.display='none'; this.className='fmaxbox'; this.title='Show Search'}");
}

// Hide Footer
var elm = document.getElementById('footerwrap');
if(elm) elm.style.display = 'none';
var elm = document.getElementById('modules');
if(elm) elm.style.marginBottom = '1em';
if(elm) elm.style.borderBottom = '1px solid silver';


This script also works with any iGoogle theme, the header background will be hidden till you hit the expand button

No comments:

Post a Comment