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)

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

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

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

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

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

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

(I already have a user script manager, let me install it!)

Advertisement:

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.

(I already have a user style manager, let me install it!)

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!");
})();