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 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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;
	}
}));