GC - Scratchcard Keyboard Controls

Adds keyboard controls to GC scratchcards.

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 or Violentmonkey 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         GC - Scratchcard Keyboard Controls
// @namespace    https://greasyfork.org/en/users/1175371
// @version      0.8
// @description  Adds keyboard controls to GC scratchcards.
// @author       sanjix
// @match        https://www.grundos.cafe/*/scratchcard/*
// @match        https://www.grundos.cafe/*/kiosk/*
// @match        https://www.grundos.cafe/*/purchase-scratchcard/
// @icon         https://www.google.com/s2/favicons?sz=64&domain=grundos.cafe
// @grant        none
// @license      MIT
// ==/UserScript==

var spots = document.querySelectorAll('.scratchcard a, .scratchcard img[onclick], .scratchcard .ldsc_blank');
var back = document.querySelector('#scratchcard ~ .button-group button:first-child');
var cards = document.querySelector('select[name="card"]');
var select = document.querySelector('select[name="card"] option:last-child');
var goscratch = document.querySelector('input[value="Scratch!"]');
var buyscratch = document.querySelector('input[value="Yes, I will have one please"], #page_content main button.form-control');document.addEventListener("keydown", ((event) => {
    switch (event.keyCode) {
        case 97:
        case 49: //1
            {
                spots[0].click();
            }
            break;
        case 98:
        case 50: //2
            {
                spots[1].click();
            }
            break;
        case 99:
        case 51: //3
            {
                spots[2].click();
            }
            break;
        case 100:
        case 52: //4
            {
                spots[3].click();
            }
            break;
        case 101:
        case 53: //5
            {
                spots[4].click();
            }
            break;
        case 102:
        case 54: //6
            {
                spots[5].click();
            }
            break;
        case 103:
        case 55: //7
            {
                spots[6].click();
            }
            break;
        case 104:
        case 56: //8
            {
                spots[7].click();
            }
            break;
        case 105:
        case 57: //9
            {
                spots[8].click();
            }
            break;
        case 13: //enter
            {
                if (back != null) {
                    back.click();
                } else if (cards != null && !select.selected) {
                    select.selected = true;
                } else if (cards != null && select.selected) {
                    goscratch.click();
                } else if (buyscratch != null) {
                    buyscratch.click();
                }
            }
            break;
    }
}));