GC Keyboard Shop Browser

Allows ArrowKey, WASD, and NumPad shop browsing. The first shop item will automatically be focused, then the arrow keys, WASD, or 8426 (for NumPads) will navigate between items.

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği yüklemek için Tampermonkey gibi bir uzantı yüklemeniz gerekir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

Bu stili yüklemek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için Stylus gibi bir uzantı kurmanız gerekir.

Bu stili yükleyebilmek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı kurmanız gerekir.

Bu stili yükleyebilmek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name         GC Keyboard Shop Browser
// @namespace    https://www.grundos.cafe/userlookup/?user=hazr
// @version      1.0
// @description  Allows ArrowKey, WASD, and NumPad shop browsing. The first shop item will automatically be focused, then the arrow keys, WASD, or 8426 (for NumPads) will navigate between items.
// @author       hazr
// @license      MIT
// @match        https://www.grundos.cafe/viewshop/*
// @match        https://www.grundos.cafe/market/browseshop/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=grundos.cafe
// @grant        none
// @run-at       document-start
// ==/UserScript==

var items = [];
var selectedItem = 0;
var maxIndex = 0;
var loaded = false;

new MutationObserver(function(mutations)
                     {
    items = document.querySelectorAll('#searchedItem form > input[type="image"], #shopInventory form > input[type="image"]');
    if (items)
    {
        items[0].focus();
        selectedItem = 0;
        maxIndex = items.length - 1;
        loaded = true;

        this.disconnect();
    }
}).observe(document, {childList: true, subtree: true});

(function() {
    'use strict';

    // Listen for keydown events
    document.addEventListener('keydown', function(event) {
        if (!loaded || maxIndex < 0 || document.activeElement.attributes.getNamedItem("type")?.value == "text") return;
        switch(event.key) {
            case "ArrowLeft":
            case "a":
            case "4":
                if ((selectedItem -= 1) < 0) selectedItem = 0;
                items[selectedItem].focus();
                break;
            case "ArrowRight":
            case "d":
            case "6":
                if ((selectedItem += 1) > maxIndex) selectedItem = maxIndex;
                items[selectedItem].focus();
                break;
            case "ArrowUp":
            case "w":
            case "8":
                if ((selectedItem -= 4) < 0) selectedItem = 0;
                items[selectedItem].focus();
                break;
            case "ArrowDown":
            case "s":
            case "2":
                if ((selectedItem += 4) > maxIndex) selectedItem = maxIndex;
                items[selectedItem].focus();
                break;
        }
    });
})();