Stake Mines – Chess Coordinates

Adds A1–E5 chess-style coordinates to Stake Mines tiles

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

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

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

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

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

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

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Stake Mines – Chess Coordinates
// @namespace    https://stake.us/
// @version      1.1
// @description  Adds A1–E5 chess-style coordinates to Stake Mines tiles
// @match        https://stake.us/*
// @run-at       document-start
// @grant        none
// @license      MIT
// ==/UserScript==

(function () {
    'use strict';

    const LETTERS = ['A', 'B', 'C', 'D', 'E'];
    const GRID_SIZE = 5;

    function isMinesPage() {
        return location.pathname === '/casino/games/mines';
    }

    function addCoordinates() {
        if (!isMinesPage()) return;

        const tiles = document.querySelectorAll(
            'button.tile[data-testid^="game-tile-"]'
        );

        if (tiles.length !== GRID_SIZE * GRID_SIZE) return;

        tiles.forEach((tile, index) => {
            // Prevent duplicates
            if (tile.querySelector('.chess-coord')) return;

            const row = Math.floor(index / GRID_SIZE);
            const col = index % GRID_SIZE;
            const coord = `${LETTERS[col]}${row + 1}`;

            const label = document.createElement('div');
            label.className = 'chess-coord';
            label.textContent = coord;

            Object.assign(label.style, {
                position: 'absolute',
                top: '4px',
                left: '6px',
                fontSize: '11px',
                fontWeight: '700',
                color: '#ffffff',
                textShadow: '0 0 3px #000',
                pointerEvents: 'none',
                zIndex: '10'
            });

            tile.style.position = 'relative';
            tile.appendChild(label);
        });
    }

    // Observe DOM changes because Stake is a SPA (Svelte)
    const observer = new MutationObserver(() => {
        requestAnimationFrame(addCoordinates);
    });

    observer.observe(document.documentElement, {
        childList: true,
        subtree: true
    });

    // Fallback initial run
    requestAnimationFrame(addCoordinates);
})();