[GC] - Scorchy Slots Keyboard Mapping

Keyboard controls for Scorchy Slots. See beginning of script for settings.

// ==UserScript==
// @name        [GC] - Scorchy Slots Keyboard Mapping
// @namespace   https://greasyfork.org/en/users/1225524-kaitlin
// @match       https://www.grundos.cafe/games/slots/*
// @match       https://www.grundos.cafe/games/play_slots/
// @grant       none
// @version     1.0
// @icon				https://i.imgur.com/4Hm2e6z.png
// @author      Cupkait
// @description Keyboard controls for Scorchy Slots. See beginning of script for settings.
// ==/UserScript==

// Change this to false to stop ALL pop-ups when you can hold. 
// To keep alerst when maps and/or jackpot bags are present, 
// leave this true and change the preference below.
const holdReminders = true; 

// To be notified of all pages with hold values, leave this as: "all" 
// To only get an alert when you can hold a map or jackpot square, change this to: "maps" 
// To only get an alert when you can hold a jackpot square, change this to: "jackpot"
const holdPreference = "all";





const beforeSlots = $('#scorchy-rules');
const mainSlots = $('#scorchy-wrapper');
const ingameSlots = $('#scorchy-outer-wrapper')
const holdSlots = $('#scorchy-hold');

if (beforeSlots.length === 1) {
console.log("Begin Page");
document.addEventListener('keydown', function(event) {
    if (event.key === 'Enter') {
        const submitButton = document.querySelector('input[type="submit"][value="Click Here to Play"]');
        if (submitButton) {
            submitButton.click();
        }
    }
});
} else if (ingameSlots.length === 1){
    console.log("Game Ongoing.")
    console.log(holdSlots.length);
const winningRow = document.querySelectorAll('.scorchy-row')[1];

if (holdSlots.length === 1 && holdReminders === true && holdPreference === "jackpot") {
	if (winningRow && winningRow.innerHTML.includes('baggold_0.gif')) {


    alert("Don't forget to hold!\n Number keys 1-4 can be used to toggle checkboxes.");
document.addEventListener('keydown', function(event) {
    if (event.key >= '1' && event.key <= '4') {
        const index = parseInt(event.key) - 1;
        const checkbox = document.querySelector(`#scorchy-hold input[type="checkbox"][name="scorchy_hold_${index}"]`);

        if (checkbox) {
            checkbox.checked = !checkbox.checked;
        }
    }
});

};
    } else if (holdSlots.length === 1 && holdReminders === true && holdPreference === "maps") {
	if (winningRow && winningRow.innerHTML.includes('mappiece_0.gif')) {

window.onload = function() {
    alert("Don't forget to hold!\n Number keys 1-4 can be used to toggle checkboxes.");
document.addEventListener('keydown', function(event) {
    if (event.key >= '1' && event.key <= '4') {
        const index = parseInt(event.key) - 1;
        const checkbox = document.querySelector(`#scorchy-hold input[type="checkbox"][name="scorchy_hold_${index}"]`);

        if (checkbox) {
            checkbox.checked = !checkbox.checked;
        }
    }
});}

};
    } else if (holdSlots.length === 1 && holdReminders === true) {
window.onload = function() {
    alert("Don't forget to hold!\n Number keys 1-4 can be used to toggle checkboxes.");
document.addEventListener('keydown', function(event) {
    if (event.key >= '1' && event.key <= '4') {
        const index = parseInt(event.key) - 1;
        const checkbox = document.querySelector(`#scorchy-hold input[type="checkbox"][name="scorchy_hold_${index}"]`);

        if (checkbox) {
            checkbox.checked = !checkbox.checked;
        }
    }
});

};
    }

    document.addEventListener('keydown', function(event) {
    if (event.key === 'Enter') {
        const submitButton = document.querySelector('input[type="submit"][value="Play Again"], input[type="submit"][value="Collect Winnings"]');
        if (submitButton) {
            submitButton.click();
        }
    }
});
}