☰

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 or Violentmonkey to install this script.

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

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

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

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

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

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

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

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

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

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

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

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

このスクリプトの質問や評価の投稿はこちら、通報はこちらへお寄せください
// ==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!");
})();