Greasy Fork is available in English.

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.

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==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);