Tampermonkey Script to help Gameplay

Forum rules
Please DO NOT POST BUGS on this forum. Please report (and vote) bugs on : https://boardgamearena.com/#!bugs
Post Reply
User avatar
QC10
Posts: 1
Joined: 26 November 2023, 12:07

Tampermonkey Script to help Gameplay

Post by QC10 »

I like playing this game but there are 2 thing i hate:
1. You have to always scroll down to see what colors you already taken and what the opponents have and
2. the Infothing on the main Playerboard is so small that i cant read it.

I created a Tampermonkeyscript that show the meepels in the Statusbar thats ontop for me and

Image

if you hover over the Playerboard the Area in the lower right Corner is Zoomed in:

Image

here is the script:
(the code still needs testing, but maybe someone whats to do some test runs , will probably a while till i play again)

Code: Select all

// ==UserScript==
// @name         BGA Nippon Meeple Mirror & Corner Zoom - Final
// @version      3.3
// @author       Partner & Assistant
// @include      *boardgamearena.com*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    const style = document.createElement('style');
    style.innerHTML = `
        #nippon-zoom-window {
            position: fixed;
            bottom: 20px;
            right: 20px;
            width: 550px;
            height: 400px;
            background: #fff;
            border: 5px solid #d32f2f;
            border-radius: 12px;
            z-index: 10000;
            display: none;
            overflow: hidden;
            box-shadow: 0 10px 40px rgba(0,0,0,0.8);
            pointer-events: none;
        }
        #nippon-zoom-content-wrapper {
            position: absolute;
            bottom: 0;
            right: 0;
            width: 1000px; /* Virtuelle Breite des Boards */
            height: 1000px; /* Virtuelle Höhe */
            transform-origin: bottom right;
            transform: scale(1.8); /* Zoom-Stärke */
        }
        /* Fix für die Meeple im Mirror (Stat Box) */
        .mirror-meeple-wrapper {
            width: 32px; height: 32px;
            position: relative;
            display: inline-block;
        }
        .mirror-meeple-wrapper .meeple {
            position: absolute !important;
            top: 50% !important; left: 50% !important;
            margin: 0 !important;
            transform: translate(-50%, -50%) scale(1.3) !important;
        }
    `;
    document.head.appendChild(style);

    const zoomWindow = document.createElement('div');
    zoomWindow.id = 'nippon-zoom-window';
    const zoomWrapper = document.createElement('div');
    zoomWrapper.id = 'nippon-zoom-content-wrapper';
    zoomWindow.appendChild(zoomWrapper);
    document.body.appendChild(zoomWindow);

    function update() {
        // --- TEIL 1: MEEPLE MIRROR (Stat-Box oben/links) ---
        document.querySelectorAll('.player-board').forEach(statBox => {
            const pId = statBox.id.match(/\d+/);
            if (!pId) return;
            const slots = document.querySelectorAll('[id^="pworkerslot_' + pId + '"]');
            let activeMeeples = [];
            slots.forEach(s => { if (s.children.length > 0) activeMeeples.push(s.children[0]); });

            let mirror = document.getElementById('meeple_graphic_mirror_' + pId);
            if (!mirror) {
                mirror = document.createElement('div');
                mirror.id = 'meeple_graphic_mirror_' + pId;
                mirror.style.cssText = "background: #ffffff; border: 2px solid #333; padding: 6px; margin-top: 8px; display: flex; gap: 10px; min-height: 42px; border-radius: 8px; flex-wrap: wrap; align-items: center;";
                const target = statBox.querySelector('.player_board_content');
                if (target) target.prepend(mirror);
            }

            if (mirror.dataset.count != activeMeeples.length) {
                mirror.innerHTML = '';
                activeMeeples.forEach(m => {
                    const wrapper = document.createElement('div');
                    wrapper.className = "mirror-meeple-wrapper";
                    wrapper.appendChild(m.cloneNode(true));
                    mirror.appendChild(wrapper);
                });
                mirror.dataset.count = activeMeeples.length;
            }
        });

        // --- TEIL 2: ZOOM (Einfluss/Wertung unten rechts) ---
        const board = document.getElementById('board');
        if (board && !board.dataset.zoomReady) {
            board.dataset.zoomReady = "true";

            board.addEventListener('mouseenter', () => {
                zoomWrapper.innerHTML = '';
                // Wir klonen das gesamte Board ein einziges Mal
                const fullBoardClone = board.cloneNode(true);
                fullBoardClone.id = "cloned-board-content";

                // Wir schieben das Board innerhalb des Zoom-Fensters nach rechts/unten
                // damit wirklich nur die Ecke sichtbar bleibt
                fullBoardClone.style.position = "absolute";
                fullBoardClone.style.bottom = "0";
                fullBoardClone.style.right = "0";
                fullBoardClone.style.margin = "0";

                zoomWrapper.appendChild(fullBoardClone);
                zoomWindow.style.display = 'block';
            });

            board.addEventListener('mouseleave', () => {
                zoomWindow.style.display = 'none';
            });
        }
    }

    setInterval(update, 1000);
})();


Post Reply

Return to “Nippon”