// ==UserScript==
// @name Highlight Active Input
// @description アクティブなインプットフィールドをハイライト
// @include *
// ==/UserScript==


var HIGHLIGHT_STYLE = 'border:2px solid #88C2E9;background-color:#FFEEDD; color:#000000'; // Highlighting style

var curActRef = false;var curActClass = false;
function initInputHighlightScript() {
var tags = ['INPUT', 'TEXTAREA' ];
for (tagCounter = 0; tagCounter < tags.length; tagCounter++) {
var inputs = document.getElementsByTagName(tags[tagCounter]);
for (var no = 0; no < inputs.length; no++) {
if (inputs[no].tagName.toLowerCase()=='textarea' || (inputs[no].tagName.toLowerCase()=='input' && inputs[no].type.toLowerCase()=='text') || (inputs[no].tagName.toLowerCase()=='input' && inputs[no].type.toLowerCase()=='password')) {
inputs[no].attachEvent('onfocus',
function() {
var elm = event.srcElement;
if (curActRef) curActRef.className = curActClass;
curActClass = elm.className; elm.className += ' inputHighlighted'; curActRef = elm;
});
inputs[no].attachEvent('onblur', function() { event.srcElement.className = curActClass; });
}
}
}
}
document.createStyleSheet().addRule('.inputHighlighted', HIGHLIGHT_STYLE);
initInputHighlightScript();// Initialize the input highlight script