GC - Scratchcard Keyboard Controls

Adds keyboard controls to GC scratchcards.

Verze ze dne 30. 01. 2025. Zobrazit nejnovější verzi.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==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;
    }
}));