Unfuck google search button order

Reorder Google search tabs to 'Images, Videos, News, Maps'.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name        Unfuck google search button order
// @namespace   Unfuck_google_search_button_order
// @description Reorder Google search tabs to 'Images, Videos, News, Maps'.
// @include     /^https?:\/\/www.google.[a-z.]{1,8}\/search*/
// @version     3.20160202
// @grant       none
// @require     http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// @require     https://greasyfork.org/scripts/5392-waitforkeyelements/code/WaitForKeyElements.js?version=19641
// ==/UserScript==

waitForKeyElements("#hdtb-msb", meh());

function meh()
{
	var buttonInsides = document.getElementsByClassName("hdtb-mitem");

	var lang =
	[
		['Images','Képek'],
		['Videos','Videók'],
		['News','Hírek'],
		['Maps','Térkép'],
		['Books','Könyvek'],
		['Apps','Alkalmazások']
	];

	var buttons = new Array(lang.length);

	for (var i = 0; i<buttonInsides.length; ++i)
	{
		var text;
		
		if (buttonInsides[i].className.indexOf("hdtb-msel") > 0) //this is the active button
			text = buttonInsides[i].innerHTML;
		else
			text = buttonInsides[i].children[0].innerHTML;

		for (var j = 0; j<lang.length; ++j)
		{
			if (lang[j].indexOf(text) != -1)
			{
				buttons[j] = buttonInsides[i];
			}
		}
	}

	var more =  document.getElementById("hdtb-more");

	for (i = buttons.length-1; i>=0; --i)
	{
		if (buttons[i] !== undefined) //in case a button doesn't show up
			$(buttons[i]).insertAfter(buttonInsides[0]);
	}
}