GC - BD Enhancements. Keyboard control and skill autoselector

Adds keyboard control to BD. Also autofills skills in preferred order (up to 3). Replace var numeric values with preferred skills.

// ==UserScript==
// @name         GC - BD Enhancements. Keyboard control and skill autoselector
// @namespace    http://tampermonkey.net/
// @version      1
// @description  Adds keyboard control to BD. Also autofills skills in preferred order (up to 3). Replace var numeric values with preferred skills.
// @author       spiderpool1855
// @match        https://www.grundos.cafe/dome/1p/battle/*
// @match        https://www.grundos.cafe/dome/1p/endbattle/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=grundos.cafe
// @license      MIT
// @grant        none
// ==/UserScript==

// change var for different skills. Skill numeric IDs can be found by checking page source during battle
var firstSkill="112"; // Meteor Shower
var secondSkill="104"; // Shadow Health
var lastSkill="-1"; // Defend

// Adds Enter keypress to Go button
var btn = document.querySelector('div input[type="submit"][class="form-control"]');

    document.addEventListener('keydown', (event) => {
        if (event.keyCode == '13') {
            btn.click();
        }
    });

// Auto selects skills from dropdown in order. Find value in source

const skillDropdown = document.querySelector('select[id="ability"]');
if (skillDropdown) {
    // Check for the presence of '112' and '104'
    const optionExists112 = Array.from(skillDropdown.options).some(option => option.value === '112');
    const optionExists104 = Array.from(skillDropdown.options).some(option => option.value === '104');

    if (optionExists112) {
        skillDropdown.value = (firstSkill);
    } else if (optionExists104) {
        skillDropdown.value = (secondSkill);
    } else {
        skillDropdown.value = (lastSkill);
    }
   }