GC Bilge Dice Keyboard Controls

Binds each die to a number and "keep" to Enter so you can play without a mouse.

当前为 2023-12-27 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         GC Bilge Dice Keyboard Controls
// @namespace    https://greasyfork.org/en/users/1175371/
// @version      0.1
// @description  Binds each die to a number and "keep" to Enter so you can play without a mouse.
// @author       sanjix
// @match        https://www.grundos.cafe/games/bilgedice/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=grundos.cafe
// @grant        none
// ==/UserScript==

var dice = document.querySelectorAll("#bilge-dice-user-wrapper form .spacing-horizontal-dice label input");
var keep = document.querySelector(".bilge-dice-col input[value='Keep']");
var checkForWin = document.querySelector("input[value='See if you defeated those scallywags!!']");
var restart = document.querySelector("#bilge-dice-wrapper form input[type='submit']");
var newGame = document.querySelectorAll('form.mt-1 input.form-control[type="submit"]');
newGame = newGame[newGame.length - 1];
document.addEventListener("keydown", ((event) => {
	switch (event.keyCode) {
	case 49: //1
		{
			dice[0].click();
		}
		break;
	case 50: //2
		{
			if (dice.length >= 2) {
				dice[1].click();
			}
		}
		break;
	case 51: //3
		{
			if (dice.length >= 3) {
				dice[2].click();
			}
		}
		break;
	case 52: //4
		{
			if (dice.length >= 4) {
				dice[3].click();
			}
		}
		break;
	case 53: //5
		{
			if (dice.length >= 5) {
				dice[4].click();
			}
		}
		break;
	case 54: //6
		{
			if (dice.length == 6) {
				dice[5].click();
			}
		}
		break;
	case 13: //enter
		{
			if (keep != null) {
				keep.click();
			} else if (checkForWin != null) {
				checkForWin.click();
			} else if (newGame != null) {
				newGame.click();
			} else if (restart != null) {
                restart.click();
            }
		}
		break;
	}
}));