GC - Pick Your Own - Keyboard Controls

Add keyboard navigation to GC's Pick Your Own.

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

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

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name         GC - Pick Your Own - Keyboard Controls
// @namespace    https://greasyfork.org/en/users/1175371
// @version      0.4
// @description  Add keyboard navigation to GC's Pick Your Own.
// @author       sanjix
// @match        https://www.grundos.cafe/medieval/pickyourown/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=grundos.cafe
// @grant        none
// @license      MIT
// ==/UserScript==

var start = document.querySelector('input[value="Click to Play!"]');
var left = document.querySelector('input#pyo-left-arrow');
var right = document.querySelector('input#pyo-right-arrow');
var up = document.querySelector('input#pyo-up-arrow');
var down = document.querySelector('input#pyo-down-arrow');
var map = document.querySelector('form[action="/medieval/process_pickyourown/?pick=1"] input[type="image"]');
var collect = document.querySelector('input[value="Collect Berries and Leave Farm"]');

document.addEventListener("keydown", ((event) => {
    switch (event.keyCode) {
        case 38: //up-arrow
        case 87: //w
            {
                if (up != null) {
                    event.preventDefault();
                    up.click();
                }
            }
            break;
        case 37: //left-arrow
        case 65: //a
            {
                if (left != null) {
                    event.preventDefault();
                    left.click();
                }
            }
            break;
        case 40: //down-arrow
        case 83: //s
            {
                if (down != null) {
                    event.preventDefault();
                    down.click();
                }
            }
            break;
        case 39: //right-arrow
        case 68: //d
            {
                if (right != null) {
                    event.preventDefault();
                    right.click();
                }
            }
            break;
        case 13: //enter
            {
                if (start != null) {
                    start.click();
                } else if (map != null) {
                    map.click();
                } else if (collect != null) {
                    collect.click();
                }
            }
            break;
	}
}));