Google Search Fixed Topbar

By SourNote Last update Nov 5, 2008 — Installed 1,576 times.

There are 22 previous versions of this script.

// ==UserScript==
// @name           Google Search Fixed Topbar
// @namespace      http://sournote.org/scripts
// @description    Keep Google's top bar at the top instead of scrolling
// @include        http*://*.google.tld/search?*
// @include        http*://news.google.tld/news?*
// @include        http*://images.google.tld/images?*
// @include        http*://www.google.tld/products?*
// @date           2008-10-30
// @version        1.1.2
// @GM_version     0.5.3
// ==/UserScript==

Array.prototype.sconcat = function(sep)
{
	if( !sep ) sep = "";
	var x = '';
	for( var i=0; i < this.length; i++ )
	{
		if( x != '' ) x += sep;
		x += this[i];
	}
	return x;
};


Rules = {

"web" : 
[
	{s:['html body#gsr'],
	r:[	'margin: 161px 0px 0px;',
		'padding: 0px 5px;']},

	{s:['html #gsr #header'],
	r:[	'position: fixed;',
		'z-index: 1006;',
		'top: 0px;',
		'left: 0px;',
		'height: 97px;',
		'width: 100%;',
		'background-color: #fff;']},

	{s:['html #gsr #header #gbar'],
	r:[	'background-color: #fff !important;',
		'font-size:10pt !important;']},

	{s:['html #gsr #header #gbar *'],
	r:[	'background-color: #fff !important;',
		'font-size:10pt !important;']},

	{s:['html #gsr #sft'],
	r:[	'position: relative;',
		'top: 1px;']},

	{s:['html #gsr #gbi'],
	r:[	'position:fixed;']},

	{s:['html #gsr #header #gbi a'],
	r:[	'color: #00C !important;']},

	{s:['html #gsr #header #gb b',
	'html #gsr #header #gbar b.gb1'],
	r:[	'color: #000 !important;']},

	{s:['html #gsr #ssb'],
	r:[	'position: fixed !important;',
		'z-index: 1005;',
		'top: 97px;',
		'left: 0px;',
		'width: 100%;',
		'padding: 0px 0px;',
		'background-color: #EBEFF9 !important;',
		'color: #000 !important;',
		'-moz-border-radius: 0px !important;']},

	{s:['html #gsr #ssb *'],
	r:[	'font-size: 8pt !important;',
		'color: #000 !important;']},

	{s:['html #gsr #nav.origin'],
	r:[	'position: fixed;',
		'display: block !important;',
		'z-index: 1005;',
		'top: 118px;',
		'left: 0px;',
		'height: 21px;',
		'width: 100%;',
		'padding-left: 3px;',
		'border-top: 1px solid #CDE;',
		'border-bottom: 2px solid #6B90DA;',
		'background-color: #EBEFF9;']},

	{s:['html #gsr #nav.origin span'],
	r:[	'display: none;']},

	{s:['html #gsr table#nav.origin a',
		'html #gsr table#nav .cur'],
	r:[	'margin: 0px 3px;',
		'font-size: 10pt !important;']},

	{s:['#header+noscript+div.std'],
	r:[	'position: fixed;',
		'display: block !important;',
		'top: 119px;',
		'right: 2px;',
		'width: 350px !important;',
		'margin: 0px !important;',
		'z-index: 10;',
		'background-color: transparent;',
		'font-size: 10pt;']},

	{s:['div[style="padding: 4px 0pt 0pt; font-size: small;"]'],
	r:[	'position: fixed;',
		'display: block;',
		'z-index: 1004;',
		'top: 138px;',
		'left: 0px;',
		'width: 100%;',
		'margin: 0px !important;',
		'padding: 4px !important;',
		'border-bottom: 2px solid #6B90DA;',
		'background-color: #EBEFF9;',
		'font-size: 8pt !important;']},

	{s:['html body#gsr table.gac_m'],
	r:[	'position: fixed;',
		'z-index: 1011;']},

	{s:['html #gsr #gb'],
	r:[	'position: fixed !important;',
		'top: 0px !important;',
		'right: 0px !important;']},

	{s:['html #gsr table#sft table td.nobr.xsm br + a + br'],
	r:[	'display: none;']}
],

"images" : 
[
	{s:['html body'],
	r:[	'margin: 159px 0px 0px;',
		'padding: 0px 5px;']},

	{s:['html body #gbar'],
	r:[	'position: fixed !important;',
		'z-index: 10;',
		'top: 0px;',
		'background-color: #fff !important;',
		'font-size: 10pt !important;']},

	{s:['html body #gbar *'],
	r:[	'background-color: #fff !important;',
		'font-size: 10pt !important;']},

	{s:['html body div.gbh'],
	r:[	'position: fixed !important;']},

	{s:['html body #guser'],
	r:[	'position: fixed !important;',
		'top: 0px !important;',
		'right: 0px;',
		'width: 100%;',
		'background: #fff;',
		'text-align: right;']},

	{s:['html body #sft'],
	r:[	'position: fixed !important;',
		'top: 25px;',
		'left: 0px;',
		'width: 100%;',
		'margin: 0px;',
		'padding: 0px;',
		'background: #fff;']},

	{s:['html body #sft + table.t.bt'],
	r:[	'position: fixed;',
		'top: 97px;',
		'left: 0px;',
		'padding: 0px;',
		'background-color: #EBEFF9 !important;',
		'border-top: 1px solid #6B90DA;',
		'font-size: 10pt;']},

	{s:['html body #sft + table.t.bt select'],
	r:[	'font-size: 8pt;']},

	{s:['html body #sft + table.t.bt td'],
	r:[	'white-space: nowrap;']},

	{s:['html body #sft + table.t.bt td *'],
	r:[	'font-size: 8pt !important;']},


	{s:['html body #navbar'],
	r:[	'position: fixed;',
		'display: block !important;',
		'z-index: 5;',
		'top: 118px;',
		'left: 0px;',
		'height: 18px;',
		'width: 100%;',
		'margin: 0px;',
		'padding-left: 3px;',
		'border-top: 1px solid #CDE;',
		'border-bottom: 2px solid #6B90DA;',
		'background-color: #EBEFF9;',
		'text-align: left;']},

	{s:['html body #navbar td div'],
	r:[	'display: none;']},

	{s:['html body div#navbar a', 'html #gsr table#nav .cur'],
	r:[	'margin: 0px 3px;',
		'font-size: 10pt !important;']},

	{s:['div[style="padding: 4px 0pt 0pt; font-size: small;"]'],
	r:[	'position: fixed;',
		'display: block;',
		'z-index: 6;',
		'top: 138px;',
		'left: 0px;',
		'width: 100%;',
		'margin: 0px !important;',
		'padding-left: 5px !important;',
		'border-bottom: 2px solid #6B90DA;',
		'background-color: #EBEFF9;',
		'font-size: 8pt !important;',
		'white-space: nowrap;']}
],

"news" :
[
	{s:['html body'],
	r:[	'margin: 159px 0px 0px;',
		'padding: 0px 5px;']},

	{s:['html #gsr #header'],
	r:[	'position: fixed;',
		'z-index: 6;',
		'top: 0px;',
		'left: 0px;',
		'width: 100%;',
		'background-color: #fff;']},

	{s:['html body #gbar'],
	r:[	'position: fixed !important;',
		'z-index: 10;',
		'top: 0px;',
		'background-color: #fff !important;',
		'font-size: 10pt !important;']},

	{s:['html body #gbar *'],
	r:[	'background-color: #fff !important;',
		'font-size: 10pt !important;']},

	{s:['html body div.gbh'],
	r:[	'position: fixed !important;',
		'z-index: 10;']},

	{s:['html body #guser'],
	r:[	'position: fixed !important;',
		'top: 0px !important;',
		'right: 0px;',
		'width: 100%;',
		'background: #fff;',
		'text-align: right;']},

	{s:['html body #guser + table'],
	r:[	'position: fixed !important;',
		'top: 23px;',
		'left: 0px;',
		'width: 100%;',
		'margin: 0px;',
		'padding: 0px;',
		'background: #fff;']},

	{s:['html body #guser + table > tbody > tr > td:first-child'],
	r:[	'width: 158px;',
		'padding-top: 3px;']},

	{s:['html body #guser + table > tbody > tr > td:first-child + td'],
	r:[	'display: none;']},

	{s:['html body #guser + table + table'],
	r:[	'position: fixed;',
		'top: 97px;',
		'left: 0px;',
		'height: 21px;',
		'padding: 0px;',
		'border-top: 1px solid #aa0033;']},

	{s:['html body #guser + table + table td'],
	r:[	'background-color: #EFEFEF !important;',
		'white-space: nowrap;',
		'font-size: 8pt !important;']},


	{s:['html body #navbar'],
	r:[	'position: fixed;',
		'display: block !important;',
		'z-index: 5;',
		'top: 118px;',
		'left: 0px;',
		'height: 18px;',
		'width: 100%;',
		'margin: 0px;',
		'padding-left: 3px;',
		'border-top: 1px solid #EDC;',
		'border-bottom: 2px solid #aa0033;',
		'background-color: #EFEFEF;',
		'text-align: left;']},

	{s:['html body #navbar td img, html body #navbar td br'],
	r:[	'display: none;']},

	{s:['html body div#navbar a, html #gsr table#nav .cur'],
	r:[	'font-size: 10pt !important;',
		'margin: 0px 3px;']},

	{s:['html body div#navbar td:first-child'],
	r:[	'display: none;']},

	{s:['div[style="padding: 4px 0pt 4px 5px; font-size: small;"]'],
	r:[	'position: fixed;',
		'top: 138px;',
		'left: 0px;',
		'background-color: #EFEFEF;',
		'display: block;',
		'width: 100%;',
		'margin: 0px !important;',
		'border-bottom: 2px solid #aa0033;',
		'font-size: 8pt !important;',
		'z-index: 6;',
		'padding-left: 5px !important;',
		'white-space: nowrap;']},
	
	{s:['html body #guser + table table td:first-child'],
	r:[	'vertical-align: middle;']},

	{s:['html body #guser + table table td:first-child + td *'],
	r:[	'font-size: x-small !important;']},

	{s:['html body #guser + table table tr:first-child td'],
	r:[	'height: 11px !important;']}
],

"products" : 
[
	{s:['html body'],
	r:[	'margin: 159px 0px 0px;',
		'padding: 0px 5px;']},

	{s:['html body #gbar'],
	r:[	'position: fixed !important;',
		'z-index: 10;',
		'top: 0px;',
		'background-color: #fff !important;',
		'font-size: 10pt !important;']},


	{s:['html body #gbar *'],
	r:[	'background-color: #fff !important;',
		'font-size: 10pt !important;']},

	{s:['html body div.gbh'],
	r:[	'position: fixed !important;',
		'z-index:4;']},

	{s:['html body #guser'],
	r:[	'position: fixed !important;',
		'z-index: 3;',
		'top: 0px !important;',
		'right: 0px;',
		'width: 100%;',
		'background: #fff;',
		'text-align: right;']},

	{s:['html body form[name="f"]'],
	r:[	'position: fixed !important;',
		'z-index: 4;',
		'top: 25px;',
		'left: 0px;',
		'width: 100%;',
		'margin: 0px;',
		'padding: 0px;',
		'background: #fff;']},

	{s:['html body #ps-titlebar'],
	r:[	'position: fixed;',
		'z-index: 4;',
		'top: 97px;',
		'left: 0px;',
		'height: 21px;',
		'padding: 0px;',
		'background-color: #EBEFF9 !important;',
		'font-size: 10pt;']},

	{s:['html body #ps-titlebar *'],
	r:[	'font-size:8pt;']},

	{s:['html body #ps-titlebar td'],
	r:[	'white-space: nowrap;',
		'padding-top: 3px;']},

	{s:['html body #ps-navbar'],
	r:[	'position: fixed;',
		'display: block !important;',
		'z-index: 5;',
		'top: 118px;',
		'left: 0px;',
		'height: 18px;',
		'width: 100%;',
		'margin: 0px;',
		'padding-left: 3px;',
		'border-top: 1px solid #CDE;',
		'border-bottom: 2px solid #6B90DA;',
		'background-color: #EBEFF9;',
		'text-align: left;']},

	{s:['html body #ps-navbar td div'],
	r:[	'display: none;']},

	{s:['html body div#ps-navbar *'],
	r:[	'margin: 0px 3px 0px 0px;',
		'font-size: 10pt !important;']},

	{s:['html body #ps-navbar > table > tbody > tr > td:first-child'],
	r:[	'display: none;']},

	{s:['div[style="padding: 4px 0pt 4px 5px; font-size: small;"]'],
	r:[	'position: fixed;',
		'display: block;',
		'z-index: 6;',
		'top: 138px;',
		'left: 0px;',
		'width: 100%;',
		'margin: 0px !important;',
		'padding-left: 5px !important;',
		'border-bottom: 2px solid #6B90DA;',
		'background-color: #EBEFF9;',
		'font-size: 8pt !important;',
		'white-space: nowrap;']}
]
};


(function()
{
	var prl, srl, sl = (unsafeWindow.location+"").split("/"), ss = sl[2].split("."), su = sl[3].split("?");

	if( su[0] == "search" )
	{
		prl = "web";

		//Change the news link to not include the "um" parameter.
		//When um is included, the News layout is slightly different (for whatever reason)
		var x = document.getElementById("gbar").getElementsByTagName("a");
		for( var i=0; x[i].innerHTML != "News" && i < x.length; i++ );
		x[i].href = x[i].href.replace(/\&um\=?/,"");

		setTimeout(function(){
			//odd fix for the AutoPager extension; it works, but not like I thought it would
			document.getElementById("nav").className = "origin";
		},0);
	}
	else if( ss[0] == "images" && su[0] == "images" )
	{
		prl = "images";

		document.getElementById("navbar").firstChild.setAttribute("align","");
	}
	else if( ss[0] == "news" && su[0] == "news" )
	{
		prl = "news";

		document.getElementById("navbar").firstChild.setAttribute("align","");
		document.getElementById("guser").nextSibling.firstChild.firstChild.firstChild.nextSibling.nextSibling.setAttribute("valign","");
		var x = document.getElementsByTagName("font");
		for(var i=0; i < x.length; i++ )
		{
			x[i].size = "";
		}
	}
	else if( su[0] == "products" )
	{

		prl = "products";

		document.getElementById("ps-navbar").getElementsByTagName("table")[0].setAttribute("align","");
	}

	for( var i=0; i<Rules[prl].length; i++ )
	{
		srl = Rules[prl][i].s + "{" + Rules[prl][i].r.sconcat() + "}";
		GM_addStyle(srl);
	}
})();



//Check for updates, slowed down to once every 3 days instead of every day

var version_scriptNum = 8536; // Change this to the number given to the script by userscripts.org (check the address bar)
var version_timestamp = 1225896157444; // Used to differentiate one version of the script from an older one. Use the Date.getTime() function to get a value for this.
function updateCheck(forced) {if((forced)||(parseInt(GM_getValue("lastUpdate", "0")) + 259200000 <= (new Date().getTime()))) {try {GM_xmlhttpRequest({method: "GET",url: "http://userscripts.org/scripts/review/" + version_scriptNum + "?" + new Date().getTime(),headers: {'Cache-Control': 'no-cache'},onload: function(xhrResponse) {GM_setValue("lastUpdate", new Date().getTime() + ""); var rt = xhrResponse.responseText.replace(/&nbsp;?/gm, " ").replace(/<li>/gm, "\n").replace(/<[^>]*>/gm, ""); var scriptName = (/@name\s*(.*?)\s*$/m.exec(rt))[1]; GM_setValue("targetScriptName", scriptName); if (parseInt(/version_timestamp\s*=\s*([0-9]+)/.exec(rt)[1]) > version_timestamp) {if (confirm("There is an update available for the Greasemonkey script \"" + scriptName + ".\"\nWould you like to go to the install page now?")) {GM_openInTab("http://userscripts.org/scripts/show/" + version_scriptNum);}} else if (forced) {alert("No update is available for \"" + scriptName + ".\"");}}});} catch (err) {if (forced) {alert("An error occurred while checking for updates:\n" + err);}}}} GM_registerMenuCommand(GM_getValue("targetScriptName", "???") + " - Manual Update Check", function() {updateCheck(true);}); updateCheck(false);