alchemyDetail v10

alchemyDetail by Redbean

2025-06-30 या दिनांकाला. सर्वात नवीन आवृत्ती पाहा.

This script should not be not be installed directly. It is a library for other scripts to include with the meta directive // @require https://update.greasyfork.org/scripts/541208/1616568/alchemyDetail%20v10.js

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला 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 यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

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

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

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

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

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

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

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

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

// alchemyDetail.js
$(document).ready(function() {
    // 确保itemData存在(从全局获取)
    const itemData = window.itemData || {};
    
    // 存储炼金数据
    let alchemyData = {};
    
    // 加载炼金数据
    function loadAlchemyData() {
        return $.getJSON("https://raw.githubusercontent.com/810517583/Milkyalchemy/refs/heads/main/alchemy-data.json")
            .done(function(data) {
                alchemyData = data;
                console.log("炼金数据加载完成over");
            })
            .fail(function() {
                console.error("炼金数据加载失败tobad");
            });
    }
    
    // 查找物品的炼金数据
 function findAlchemyData(chineseName) {
    // 在全局itemData中查找物品ID
    const itemEntry = Object.entries(itemData).find(
        ([id, name]) => name === chineseName
    );
    
    if (!itemEntry) {
        console.warn(`未找到物品: ${chineseName}`);
        return null;
    }
    
    const itemId = itemEntry[0].toLowerCase();
    const itemInfo = alchemyData[itemId];
    
    // 检查并提取炼金数据
    if (!itemInfo || !itemInfo.alchemyDetail) {
        console.warn(`找到物品但无炼金数据: ${chineseName} (ID: ${itemId})`);
        return null;
    }
    
    // 返回标准化结构
    return {
        successRate: itemInfo.alchemyDetail.transmuteSuccessRate,
        dropTable: itemInfo.alchemyDetail.transmuteDropTable || []
    };
}
    
    // 自动填充函数
async function autoFillAlchemyData(chineseName) {
    try {
        const detail = findAlchemyData(chineseName);
        
        // 防御性检查
        if (!detail) {
            console.warn(`无法获取炼金数据: ${chineseName}`);
            return;
        }
        
        // 1. 填充基础成功率(转换为百分比)
        $('#nonesuccessRate').val((detail.successRate * 100).toFixed(1)).trigger('change');
        
        // 2. 清空现有产出物品行(保留第一行)
        $('#outputItems tr:not(:first)').remove();
        
        // 3. 填充产出物品数据
        if (!Array.isArray(detail.dropTable)) {
            console.warn(`产出表格式不正确:`, detail.dropTable);
            return;
        }
        
        detail.dropTable.forEach((drop, index) => {
            const $row = (index === 0) 
                ? $('#outputItems tr:first') 
                : $('#outputItems tr:first').clone().appendTo('#outputItems');
            
            // 获取中文名称(使用全局itemData映射)
            const itemName = itemData[drop.itemHrid] || 
                            drop.itemHrid.split('/').pop().replace(/_/g, ' ');
            
            // 填充数据
            $row.find('.output-item').val(itemName);
            $row.find('.output-probability').val((drop.dropRate * 100).toFixed(3)); // 保留3位小数
            
            // 重置价格(不自动获取)
            $row.find('.output-price').val('0');
        });
        
    } catch (error) {
        console.error("自动填充失败:", error);
    }
}
    
    // 初始化
    loadAlchemyData();
    
    // 监听物品输入框变化
    $('.alchemy-text').on('change', function() {
        const name = $(this).val().trim();
        if (name) autoFillAlchemyData(name);
    });
});