Stake Mines – Chess Coordinates

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

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 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);
})();