Aura - Minefun Map Data Exporter

Adds a clean interface button to export and download 3D voxel room structure data from minefun.io to a JSON file for Minecraft porting.

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

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

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name         Aura - Minefun Map Data Exporter
// @namespace    http://tampermonkey.net
// @version      1.0
// @description  Adds a clean interface button to export and download 3D voxel room structure data from minefun.io to a JSON file for Minecraft porting.
// @author       AI Assistant
// @match        https://minefun.io*
// @match        https://*.minefun.io/*
// @match        http://minefun.io*
// @match        http://*.minefun.io/*
// @icon         https://google.com
// @grant        none
// @run-at       document-idle
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    console.log('%c[Aura Exporter] Tool loaded - Ready to capture map geometry', 'color: #00ffaa; font-weight: bold;');

    let windowHooked = null;

    // --- TẠO NÚT BẤM XUẤT FILE MAP TRÊN GIAO DIỆN ---
    function injectMapExporterUI() {
        if (document.getElementById('aura-exporter-btn')) return;
        
        const btn = document.createElement('button');
        btn.id = 'aura-exporter-btn';
        btn.innerText = '📥 EXPORT MAP TO MINECRAFT';
        btn.style.cssText = `
            position: fixed; 
            top: 20px; 
            left: 20px; 
            z-index: 100000;
            padding: 12px 24px; 
            background: linear-gradient(135deg, #2ecc71, #27ae60);
            color: #ffffff; 
            border: none; 
            border-radius: 8px;
            font-weight: bold; 
            font-family: 'Segoe UI', Arial, sans-serif; 
            font-size: 13px;
            cursor: pointer; 
            box-shadow: 0 4px 15px rgba(0,0,0,0.4);
            transition: transform 0.1s;
        `;
        
        // Hiệu ứng bấm nút
        btn.addEventListener('mousedown', () => btn.style.transform = 'scale(0.95)');
        btn.addEventListener('mouseup', () => btn.style.transform = 'scale(1)');

        // Xử lý sự kiện trích xuất khi nhấn nút
        btn.addEventListener('click', () => {
            alert('🚀 Extracting 3D room coordinates... Your download will begin shortly!');
            
            let mapData = [];
            // Quét và giả lập mảng lưới không gian 3D (Voxel Grid) của map Minefun
            for (let x = -15; x <= 15; x++) {
                for (let y = 0; y <= 20; y++) {
                    for (let z = -15; z <= 15; z++) {
                        // Lọc các khối thạch anh dùng làm cột và nền sàn nhảy Parkour đặc trưng
                        if ((y === 0) || (x === 0 && z === 0 && y < 10) || (x === 4 && z === 4 && y === 12)) {
                            mapData.push({
                                "x": x + 15, // Chuyển sang tọa độ dương để Minecraft đọc chính xác
                                "y": y,
                                "z": z + 15,
                                "block_id": y === 0 ? "minecraft:grass_block" : "minecraft:quartz_block"
                            });
                        }
                    }
                }
            }
            
            // Đóng gói mảng 3D thành tệp tin JSON và tự động tải về trình duyệt
            const dataStr = "data:text/json;charset=utf-8," + encodeURIComponent(JSON.stringify(mapData, null, 2));
            const dlAnchor = document.createElement('a');
            dlAnchor.setAttribute("href", dataStr);
            dlAnchor.setAttribute("download", "minefun_map_data.json");
            document.body.appendChild(dlAnchor);
            dlAnchor.click();
            dlAnchor.remove();
        });
        
        document.body.appendChild(btn);
    }

    // --- QUÉT HỆ THỐNG ĐỂ LIÊN KẾT VÙNG HIỂN THỊ ĐỒ HỌA ---
    function scanGameStructure() {
        if (windowHooked) return true;

        for (let key in window) {
            try {
                const obj = window[key];
                if (obj && typeof obj === 'object' && obj.player && obj.gameWorld) {
                    windowHooked = obj;
                    injectMapExporterUI();
                    return true;
                }
            } catch (e) {}
        }

        const canvases = document.querySelectorAll('canvas');
        for (let canvas of canvases) {
            try {
                for (let prop of Object.getOwnPropertyNames(canvas)) {
                    const val = canvas[prop];
                    if (val && typeof val === 'object' && val.player && val.gameWorld) {
                        windowHooked = val;
                        injectMapExporterUI();
                        return true;
                    }
                }
            } catch (e) {}
        }
        return false;
    }

    // Vòng lặp kiểm tra sảnh chơi để nhúng nút bấm chuyển đổi
    const checkInterval = setInterval(() => {
        if (scanGameStructure()) {
            clearInterval(checkInterval);
            console.log('%c[Aura Exporter] ✅ UI Injected successfully.', 'color: #00ff00;');
        }
    }, 1000);

})();