focusSearch

focus search input

Du musst eine Erweiterung wie Tampermonkey, Greasemonkey oder Violentmonkey installieren, um dieses Skript zu installieren.

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

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

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

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

Sie müssten eine Skript Manager Erweiterung installieren damit sie dieses Skript installieren können

(Ich habe schon ein Skript Manager, Lass mich es installieren!)

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.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @license MIT
// @name         focusSearch
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  focus search input
// @author       Chris
// @match        *://*/*
// @icon         https://img1.imgtp.com/2023/06/06/b6fHuJNi.ico
// @grant        none
// ==/UserScript==

(function(){
    var key = 's'
    var only = false

    var searchInputDom = document.querySelector(`input`)
    var focus = function(event){
        event.key === key?searchInputDom.focus():false;
    }
    var removeFocus = function(){
        window.removeEventListener('keyup', focus)
    }

    searchInputDom.addEventListener('focus', removeFocus);
    searchInputDom.addEventListener('blur', function(){
        only?false:window.addEventListener('keyup', focus);
    });
    window.addEventListener('keyup', focus)
})()