no-mouse-google

hjkl google

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==
// @name         no-mouse-google
// @namespace    http://tampermonkey.net/
// @version      2026-01-27-2
// @description  hjkl google
// @author       yabeenico
// @include      https://www.google.com/search?*
// @include      https://www.google.co.*/search?*
// @icon         data:image/gif;base64,R0lGODlhgACAAPMAAOtwoOtxoOtwoetxoexwoOxxoOxwoe1woexxoe1xoexxogAAAAAAAAAAAAAAAAAAACH5BAEAAAsALAAAAACAAIAAAAT+cMlJq11kjLCv/1ZAjCBWFEqpLsoYvOkqq4Fityg5gzVxB56e4hTbTTK34ShjxIySN4LHhqoObQPezVqoUK8ooAV1vTVZXOu3DG7HlgTyLTt2u3lc86SmvloGSWQEYjIiX2R9RHmHMYpgVRY+eZMfhls2FD5tVVITgJNDM5+boJumXQulBZ0TjKBkQS1rrDWnLZmvCnQqjmqTuVYSq6SYR7agQU9qYkS2b65grCDHqsfFI4vFwsBu0ntPZavCQ6Wd0GoqmtVp1igSmtCe58cXfI8KQOqngxLtJyXcqvhq9y6OqSLzctVbJI5bMYe76rULR27itoMxBiCaGKyCvWX+CwzlSiHJWpEL+oANHDkOVJxUFQOWCbGIhMxUDr1R2OhQoMVUJfPA4DlR27egShLe83fSC0eGBJ2M9ClTDwURBmXmidOTkJeq7Li9S7iy6K2rKTlWTFvKayuHSc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zg2Iracl79czBpa48Zj5u88dIwSI6dZy7Kjwd3i+ub+Ws3Mh6vzgduB5iuSWM8E3c0HRFd9YUD7949WsNB76mboByOQs1Qg7mAb7d/DbKEkgnMlpfn7uwY64q6bDnRziUHkUBO0uexZrqnbiejm2KfDqy7loyujx1g7OtOdSYKtIWwmEl4GyLvGpCUsTblg83rW9yi1sQ8dFO/6YNkllktjYAztY7s3x9UOcgaAQ2cVRAAAOw==
// @grant        none
// @license MIT
// ==/UserScript==
/* eslint-disable no-multi-spaces */
/* eslint-disable no-return-assign */

let selectedIndex = -1;
let selectedColumn = 0;

const itemQuery = '' +
      '#search div[data-hveid][data-ved][lang],' +
      '#search div[data-hveid]:has(>div[data-cid]),' +
      '#search div[data-hveid]:has(>div > div[data-cid]),' +
      '#nevermatch';
const cards = Array.from(document.querySelectorAll(itemQuery));
const columns = Array.from(document.querySelectorAll('div[role=listitem]'));

function refresh(){
    console.log('selectedColumn:', selectedColumn);
    console.log('columns:', columns);
    console.log('selectedIndex:', selectedIndex);
    console.log('cards:', cards);
    columns.map(x=>x.style.backgroundColor = null);
    cards.map(x=>x.style.backgroundColor = null);
    if(selectedIndex == -1){
        columns[selectedColumn].style.backgroundColor = '#333';
        columns[selectedColumn].querySelector('a').focus();
    }else{
        cards[selectedIndex].style.backgroundColor = '#333';
        cards[selectedIndex ].querySelector('a').focus();
        cards[selectedIndex].scrollIntoView({
            block: 'center'
        });
    }
}
refresh();

document.addEventListener('keydown', (e) => {
    if(
        e.isComposing ||
        e.target instanceof HTMLInputElement ||
        e.target instanceof HTMLTextAreaElement ||
        e.target.isContentEditable
    ){
        return;
    }
    switch(e.key){
        case 'j':
            if(selectedIndex == -1){
                selectedIndex = 0;
                refresh(-1);
            }else if(selectedIndex < cards.length - 1){
                selectedIndex++;
                refresh();
            }
            break;
        case 'k':
            if(selectedIndex <= -1){
            }else{
                selectedIndex--;
                refresh();
            }
            break;
        case 'h':
            if(selectedIndex == -1){
                if(0 < selectedColumn){
                    selectedColumn--;
                    refresh();
                }
            }
            break;
        case 'l':
            if(selectedIndex == -1){
                if(selectedColumn < columns.length - 2){
                    selectedColumn++;
                    refresh();
                }
            }else{
                window.open(cards[selectedIndex].querySelector('a').href);
            }
            break;
    }
});