您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
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.
- // ==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);