Greasy Fork

auto focus on first <input>

auto foucs on first input box

当前为 2022-05-01 提交的版本,查看 最新版本

// ==UserScript==
// @name             auto focus on first <input>
// @name:zh          自动聚焦第一个输入框
// @namespace        @Vinsea
// @version          0.2.1
// @description      auto foucs on first input box
// @description:zh   默认聚焦到第一个搜索框中
// @author           Vinsea
// @match            *
// @match            http*://*/*
// @license          MIT
// ==/UserScript==

(function() {
    'use strict';
    var firstInput = document.querySelector('input:not([type=hidden])');
    if(firstInput){
        var val = firstInput.value;
        firstInput.value = '';
        firstInput.focus();
        firstInput.value = val;
    }
})();