Auto Focus Username Field

Attempts to locate the username input box and change focus to it, will briefly change the background color of the field green when it activates.

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

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

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        Auto Focus Username Field
// @namespace   ClintPriest.com
// @description Attempts to locate the username input box and change focus to it, will briefly change the background color of the field green when it activates.
// @include     http://*
// @include     https://*
// @version     1
// @grant       none
// ==/UserScript==

var names = new Set([ 'username','login_name','user','login' ]);

function findFocus(e) {
	console.log('load %o', e);
	for(var x of names.values()) {
		var elem = document.querySelector('INPUT[name*=' + x + ']');
		if(elem) {
			elem.origbackgroundColor= elem.style.backgroundColor;
			elem.style.backgroundColor = '#A0FFA0';
			elem.focus();
			elem.selectionStart = 0;
			elem.selectionEnd = 999;

			setTimeout(function() {
				elem.style.backgroundColor = elem.origbackgroundColor;
				delete elem.origbackgroundColor;
			}, 2000);
			break;
		}
	}
	window.removeEventListener('DOMContentLoaded', findFocus);
};

window.addEventListener('DOMContentLoaded', findFocus);