Google search box auto-focus

Always set input focus to the search textbox

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         Google search box auto-focus
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Always set input focus to the search textbox
// @author       Matt Blais
// @include     http*://www.google.*/*
// @exclude     http*://www.google.com/recaptcha/*
// @include     http*://www.google.co*.*/*
// @include     http*://news.google.*/*
// @include     http*://encrypted.google.*/*
// @grant        none
// ==/UserScript==

// Focus the search box whenever the page becomes active/focused
(function() {
    'use strict'
	var fo = function ()
    {
		var inp = document.getElementsByTagName("input")
		if( inp && inp.length > 2 ) {
			inp[2].focus()
            // Select all text in box
            inp[2].select()
			// Collapse the search combobox
		    var cbdd = document.getElementsByClassName('UUbT9')
            if (cbdd.length) {
		    	window.setTimeout(function() { cbdd[0].style.display = 'none' }, 20)
            }
		}
	}

	window.addEventListener('focus', fo)
	fo()

}() )