Mario Maker 2 Auto Goal

Shows the goal for no damage challenge

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         Mario Maker 2 Auto Goal
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Shows the goal for no damage challenge
// @author       bananenkeks
// @match        https://angrystar6k.github.io/The-Mario-Maker-2-Tree/*
// @match        https://galaxy.click/play/318*
// @grant        unsafeWindow
// @run-at       document-end
// ==/UserScript==

(function(){
    'use strict';

    // Text-Mapping pro GoalCode
    const goalText = {
        1: 'Flag',
        2: 'Square',
        3: 'Pole',
        4: 'Axe'
    };

    // CSS für Hervorhebung
    const css = document.createElement('style');
    css.textContent = `
      .tm-highlight-button {
        box-shadow: 0 0 10px 4px rgba(45,187,164,0.8) !important;
        transform: scale(1.1) !important;
        transition: transform 0.2s, box-shadow 0.2s;
        z-index: 100000 !important;
      }
    `;
    document.head.appendChild(css);

    // iFrame-Fix
    let gameWindow = unsafeWindow;
    if (location.hostname !== 'angrystar6k.github.io') {
        const iframe = document.querySelector('iframe');
        if (iframe?.contentWindow) gameWindow = iframe.contentWindow;
    }

    function clear() {
        document.querySelectorAll('.tm-highlight-button').forEach(el => {
            el.classList.remove('tm-highlight-button');
        });
    }

    function highlight() {
        clear();
        let player;
        try { player = gameWindow.player; } catch { return; }
        if (!player?.easy) return;

        const theme = Number(player.easy.random_theme||0);
        const style = Number(player.easy.random_style||0);
        if (theme<1||theme>10||style<1||style>5) return;

        // Tabelle aus vorherigem Skript
        const table = [
          [1,2,3,1,1],[1,2,3,1,1],[1,2,3,1,1],
          [1,2,3,1,1],[1,2,3,1,1],[1,2,3,1,1],
          [1,2,3,1,1],[1,2,3,1,1],[1,2,3,1,1],
          [4,4,4,4,1]
        ];
        const code = table[theme-1][style-1];
        const text = goalText[code];

        // Suche Buttons nach Text
        const btns = Array.from(document.querySelectorAll('button'));
        for(const b of btns){
            if (b.textContent.trim().includes(text)) {
                b.classList.add('tm-highlight-button');
                break;
            }
        }
    }

    setInterval(highlight, 300);
})();