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)

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

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