Minefun Minecraft Texture Pack

Thay đổi texture của Minefun thành Minecraft gốc theo ID (Tuyết, Rơm, Bàn chế tạo, Rương)

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

Advertisement:

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

Advertisement:

// ==UserScript==
// @name         Minefun Minecraft Texture Pack
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Thay đổi texture của Minefun thành Minecraft gốc theo ID (Tuyết, Rơm, Bàn chế tạo, Rương)
// @author       You
// @match        *://minefun.io/*
// @run-at       document-start
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // --- DANH SÁCH TEXTURE MINECRAFT GỐC ---
    // Link ảnh được lấy trực tiếp từ kho asset chuẩn của Minecraft
    const textureMap = {
        // ID 258: Tuyết (Snow)
        '258': 'https://raw.githubusercontent.com/InventivetalentDev/minecraft-assets/master/assets/minecraft/textures/block/snow.png',
        
        // ID 857: Khối Rơm (Hay Bale)
        '857': 'https://raw.githubusercontent.com/InventivetalentDev/minecraft-assets/master/assets/minecraft/textures/block/hay_block_side.png',
        
        // ID 570: Bàn chế tạo (Crafting Table)
        '570': 'https://raw.githubusercontent.com/InventivetalentDev/minecraft-assets/master/assets/minecraft/textures/block/crafting_table_front.png',
        
        // ID 573: Rương gỗ (Chest)
        // Rương trong Minecraft là entity (vật thể 3D), nên bản 2D thường dùng icon trong kho đồ
        '573': 'https://raw.githubusercontent.com/InventivetalentDev/minecraft-assets/master/assets/minecraft/textures/item/chest.png'
    };

    // --- CƠ CHẾ 1: CHẶN VÀ ĐỔI ẢNH TỪ THẺ <IMAGE> ---
    const originalImageSrc = Object.getOwnPropertyDescriptor(HTMLImageElement.prototype, 'src');
    Object.defineProperty(HTMLImageElement.prototype, 'src', {
        set: function(url) {
            if (typeof url === 'string') {
                for (const [id, newUrl] of Object.entries(textureMap)) {
                    // Nhận diện đường dẫn game có chứa ID, ví dụ: /blocks/258.png hoặc _258.webp
                    if (url.includes(`/${id}.`) || url.includes(`_${id}.`) || url.includes(`${id}.png`)) {
                        url = newUrl; // Tráo đổi thành texture Minecraft
                        break;
                    }
                }
            }
            originalImageSrc.set.call(this, url);
        },
        get: function() {
            return originalImageSrc.get.call(this);
        }
    });

    // --- CƠ CHẾ 2: CHẶN VÀ ĐỔI ẢNH TỪ FETCH API (Tải ngầm) ---
    const originalFetch = window.fetch;
    window.fetch = async function(...args) {
        let url = args[0];
        if (typeof url === 'string') {
            for (const [id, newUrl] of Object.entries(textureMap)) {
                if (url.includes(`/${id}.`) || url.includes(`_${id}.`) || url.includes(`${id}.png`)) {
                    args[0] = newUrl; 
                    break;
                }
            }
        }
        return originalFetch.apply(this, args);
    };

    console.log("✅ Minefun Texture Pack đã được kích hoạt!");
})();