[GC] Add HST link to Games Room

Adds a HST link to most games in the games room. Games with non-traditional scoreboards may not be updated to the HST-inclusive format.

// ==UserScript==
// @name        [GC] Add HST link to Games Room
// @namespace   https://greasyfork.org/en/users/1225524-kaitlin
// @match       https://www.grundos.cafe/games/*
// @grant       none
// @license     MIT
// @version     1.0
// @author      Cupkait
// @icon        https://i.imgur.com/4Hm2e6z.png
// @description Adds a HST link to most games in the games room. Games with non-traditional scoreboards may not be updated to the HST-inclusive format.


// ==/UserScript==
const gameDivs = document.querySelectorAll('.game');
const resultArray = [];


function gameButtons() {


const resultArray = [];
document.querySelectorAll('.game_img').forEach(link => {
    const href = link.getAttribute('href');
    const gameDiv = link.closest('.game');
    const buttonDiv = gameDiv.querySelector('div');

    const gameNameElement = gameDiv.querySelector('.kadfont');
    const gameName = gameNameElement.textContent.trim();
    const foundGame = dataHST.find(data => data.gameName === gameName);

    if (foundGame) {
        const gameID = foundGame.gameID;
        resultArray.push({ gameID, gameName, href });

buttonDiv.innerHTML = `<a href="/games/highscores/?game_id=${gameID}" style="width: 25px;" class="inline-block"><img src="https://i.imgur.com/duf5Y08.png" style="font-family: heffaklump; height: 30px; width: 25px; margin-right:20px;"></a>
    <a href="${href}" style="font-family: heffaklump; color: black; font-size: 22px; width: 45px;">Play</a>
    <a class="inline-block" style="font-family: Heffaklump; font-weight:normal; color: black; font-size: 16px; width: 45px; href="javascript:;" onclick="window.open('/games/gamehelp?game_id=${gameID}','newwin', 'height=300,width=300,scrolling=no'); return false;">(info)</a>
`;

    }

    console.log(href);
});


console.log(resultArray);

}



const dataHST = [
    {
        "gameName": "Advert Attack",
        "gameID": "40"
    },
    {
        "gameName": "Alien Aisha Vending Machine",
        "gameID": "8"
    },
    {
        "gameName": "Angry Tax Beast",
        "gameID": "24"
    },
    {
        "gameName": "Attack of the Revenge",
        "gameID": "54"
    },
    {
        "gameName": "Balthazar Basher",
        "gameID": "44"
    },
    {
        "gameName": "Better Than You",
        "gameID": "66"
    },
    {
        "gameName": "Bilge Dice",
        "gameID": "64"
    },
    {
        "gameName": "Bilge Dice Streak",
        "gameID": "65"
    },
    {
        "gameName": "Card Collector",
        "gameID": "18"
    },
    {
        "gameName": "Carnival of Terror",
        "gameID": "36"
    },
    {
        "gameName": "Cheeseroller",
        "gameID": "32"
    },
    {
        "gameName": "Destruct-O-Match II",
        "gameID": "12"
    },
    {
        "gameName": "Dice-A-Roo",
        "gameID": "10"
    },
    {
        "gameName": "Double Or Nothing",
        "gameID": "30"
    },
    {
        "gameName": "Dubloon Disaster",
        "gameID": "3"
    },
    {
        "gameName": "Escape from Meridell Castle",
        "gameID": "51"
    },
    {
        "gameName": "Extreme Herder",
        "gameID": "26"
    },
    {
        "gameName": "Faerie Bubbles",
        "gameID": "46"
    },
    {
        "gameName": "Faerie Cloud Racers",
        "gameID": "27"
    },
    {
        "gameName": "Food Club",
        "gameID": "6"
    },
    {
        "gameName": "Gormball",
        "gameID": "28"
    },
    {
        "gameName": "Grarrl Keno",
        "gameID": "62"
    },
    {
        "gameName": "Grumpy Old King",
        "gameID": "47"
    },
    {
        "gameName": "Guess the Card",
        "gameID": "49"
    },
    {
        "gameName": "Ice Cream Cart",
        "gameID": "69"
    },
    {
        "gameName": "Ice Cream Machine",
        "gameID": "34"
    },
    {
        "gameName": "Jelly Blobs of Doom",
        "gameID": "43"
    },
    {
        "gameName": "Jhudora's Cloud",
        "gameID": "72"
    },
    {
        "gameName": "Kiss the Mortog",
        "gameID": "61"
    },
    {
        "gameName": "Korbats Lab",
        "gameID": "13"
    },
    {
        "gameName": "Lenny Conundrum",
        "gameID": "21"
    },
    {
        "gameName": "Marrow Tax",
        "gameID": "37"
    },
    {
        "gameName": "Meepit Juice Break",
        "gameID": "14"
    },
    {
        "gameName": "Meerca Chase II",
        "gameID": "31"
    },
    {
        "gameName": "Mystery Pic",
        "gameID": "45"
    },
    {
        "gameName": "Neggsweeper",
        "gameID": "52"
    },
    {
        "gameName": "Neggsweeper Cumulative",
        "gameID": "53"
    },
    {
        "gameName": "Neoboard Avatar Collector",
        "gameID": "2"
    },
    {
        "gameName": "Neocola Machine",
        "gameID": "48"
    },
    {
        "gameName": "Neopian Lottery",
        "gameID": "20"
    },
    {
        "gameName": "Revel Roundup",
        "gameID": "73"
    },
    {
        "gameName": "Sakhmet Solitaire Cumulative",
        "gameID": "15"
    },
    {
        "gameName": "Scorchy Slots",
        "gameID": "57"
    },
    {
        "gameName": "Sloth's Invasion Tax",
        "gameID": "25"
    },
    {
        "gameName": "Snow Beast Appropriation",
        "gameID": "38"
    },
    {
        "gameName": "Stamp Collector",
        "gameID": "7"
    },
    {
        "gameName": "Sutek's Tomb",
        "gameID": "39"
    },
    {
        "gameName": "Tax Beast",
        "gameID": "23"
    },
    {
        "gameName": "Test Your Strength",
        "gameID": "42"
    },
    {
        "gameName": "Tyranu Evavu",
        "gameID": "5"
    },
    {
        "gameName": "Ultimate Bullseye",
        "gameID": "35"
    },
    {
        "gameName": "Usuki Frenzy",
        "gameID": "56"
    },
    {
        "gameName": "Volcano Run",
        "gameID": "9"
    },
    {
        "gameName": "Wise Old King",
        "gameID": "63"
    },
    {
        "gameName": "Wishing Well",
        "gameID": "19"
    },
    {
        "gameName": "Zurroball",
        "gameID": "50"
    }
]
console.log(resultArray);


gameButtons();