{"id":"2WwqU7VG78","url":"https://pastebin.ca/2WwqU7VG78","raw_url":"https://raw.anybin.ca/2WwqU7VG78","visibility":"public","access":"public","created_at":1784478606597,"expires_at":1785083406597,"fetch_limit":null,"fetches_used":0,"reads_remaining":null,"size_bytes":11207,"syntax_hint":null,"title":null,"filename":null,"change_note":null,"cipher":null,"cipher_meta":null,"parent_id":null,"root_id":"2WwqU7VG78","version":1,"owner_id":null,"recipient_id":null,"body":"// ==UserScript==\n// @name         HentaiVerse Legendary Upgrade Calculator\n// @namespace    http://tampermonkey.net/\n// @version      1.5\n// @description  Calculate Legendary equipment upgrade cost using HVUT material prices.\n// @author       Gemini, Codex\n// @match        *://hentaiverse.org/isekai/*\n// @match        *://hentaiverse.org/*\n// @grant        none\n// ==/UserScript==\n\n(function() {\n    'use strict';\n\n    const urlParams = new URLSearchParams(window.location.search);\n    if (urlParams.get('s') !== 'Bazaar' || urlParams.get('ss') !== 'am') {\n        return;\n    }\n\n    const upgradeData = [\n        { level: 1, mid: 100, high: 5, rare: 1, core: 1, creds: 25000 },\n        { level: 2, mid: 100, high: 10, rare: 1, core: 1, creds: 25000 },\n        { level: 3, mid: 100, high: 15, rare: 1, core: 1, creds: 25000 },\n        { level: 4, mid: 100, high: 20, rare: 1, core: 1, creds: 25000 },\n        { level: 5, mid: 100, high: 25, rare: 1, core: 1, creds: 25000 },\n        { level: 6, mid: 100, high: 30, rare: 2, core: 2, creds: 25000 },\n        { level: 7, mid: 100, high: 35, rare: 2, core: 2, creds: 25000 },\n        { level: 8, mid: 100, high: 40, rare: 2, core: 2, creds: 25000 },\n        { level: 9, mid: 100, high: 45, rare: 2, core: 2, creds: 25000 },\n        { level: 10, mid: 100, high: 50, rare: 2, core: 2, creds: 25000 },\n        { level: 11, mid: 100, high: 50, rare: 3, core: 3, creds: 50000 },\n        { level: 12, mid: 100, high: 50, rare: 3, core: 3, creds: 50000 },\n        { level: 13, mid: 100, high: 50, rare: 3, core: 3, creds: 50000 },\n        { level: 14, mid: 100, high: 50, rare: 3, core: 3, creds: 50000 },\n        { level: 15, mid: 100, high: 50, rare: 3, core: 3, creds: 50000 },\n        { level: 16, mid: 100, high: 50, rare: 4, core: 4, creds: 50000 },\n        { level: 17, mid: 100, high: 50, rare: 4, core: 4, creds: 50000 },\n        { level: 18, mid: 100, high: 50, rare: 4, core: 4, creds: 50000 },\n        { level: 19, mid: 100, high: 50, rare: 4, core: 4, creds: 50000 },\n        { level: 20, mid: 100, high: 50, rare: 4, core: 4, creds: 50000 },\n        { level: 21, mid: 100, high: 50, rare: 5, core: 5, creds: 100000 },\n        { level: 22, mid: 100, high: 50, rare: 5, core: 5, creds: 100000 },\n        { level: 23, mid: 100, high: 50, rare: 5, core: 5, creds: 100000 },\n        { level: 24, mid: 100, high: 50, rare: 5, core: 5, creds: 100000 },\n        { level: 25, mid: 100, high: 50, rare: 5, core: 5, creds: 100000 }\n    ];\n\n    const materialTypes = [\n        { value: 'Cloth', label: 'Cloth' },\n        { value: 'Leather', label: 'Leather' },\n        { value: 'Metals', label: 'Metals' },\n        { value: 'Wood', label: 'Wood' }\n    ];\n    const rareMaterials = [\n        { value: '', label: 'None' },\n        { value: 'Crystallized Phazon', label: 'Crystallized Phazon' },\n        { value: 'Shade Fragment', label: 'Shade Fragment' },\n        { value: 'Repurposed Actuator', label: 'Repurposed Actuator' },\n        { value: 'Defense Matrix Modulator', label: 'Defense Matrix Modulator' }\n    ];\n    const coreTypes = [\n        { value: 'Legendary Weapon Core', label: 'Legendary Weapon Core' },\n        { value: 'Legendary Staff Core', label: 'Legendary Staff Core' },\n        { value: 'Legendary Armor Core', label: 'Legendary Armor Core' }\n    ];\n\n    function readHvutPrices() {\n        const key = location.pathname.startsWith('/isekai/') ? 'hvuti_prices' : 'hvut_prices';\n        const fallbackKey = key === 'hvut_prices' ? 'hvuti_prices' : 'hvut_prices';\n        for (const storageKey of [key, fallbackKey]) {\n            try {\n                const value = localStorage.getItem(storageKey);\n                if (value) {\n                    return { prices: JSON.parse(value), key: storageKey };\n                }\n            } catch (error) {\n                console.warn('Failed to read HVUT prices:', storageKey, error);\n            }\n        }\n        return { prices: {}, key: '' };\n    }\n\n    function priceOf(prices, itemName) {\n        if (!itemName) {\n            return 0;\n        }\n        const price = Number(prices[itemName]);\n        return Number.isFinite(price) ? price : 0;\n    }\n\n    function formatCredits(value) {\n        return Math.ceil(value).toLocaleString();\n    }\n\n    function buildOptions(items) {\n        return items.map((item) => `<option value=\"${item.value}\">${item.label}</option>`).join('');\n    }\n\n    const style = document.createElement('style');\n    style.textContent = `\n        #hv-upgrade-calc { position: fixed; bottom: 20px; right: 20px; width: 340px; background: #fdfdfd; border: 2px solid #333; border-radius: 8px; padding: 15px; box-shadow: 0 4px 6px rgba(0,0,0,0.3); font-family: Arial, sans-serif; font-size: 14px; z-index: 999999; color: #333; }\n        #hv-upgrade-calc h3 { margin: 0 0 10px 0; font-size: 16px; text-align: center; border-bottom: 1px solid #ccc; padding-bottom: 5px; }\n        .hv-calc-row { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 8px; align-items: center; }\n        .hv-calc-row label { flex: 1; }\n        .hv-calc-row input, .hv-calc-row select { width: 155px; box-sizing: border-box; padding: 2px 5px; border: 1px solid #aaa; border-radius: 4px; background: #fff; color: #333; }\n        .hv-calc-row input[readonly] { background: #eee; }\n        #hv-calc-btn { width: 100%; padding: 8px; margin-top: 10px; background: #4CAF50; color: white; border: none; border-radius: 4px; cursor: pointer; font-weight: bold; }\n        #hv-calc-summary { margin-top: 10px; font-size: 12px; color: #555; background: #f0f0f0; padding: 5px; border-radius: 4px; text-align: center; display: none; line-height: 1.45; }\n        #hv-calc-result { margin-top: 10px; font-weight: bold; text-align: center; color: #d32f2f; font-size: 16px; }\n        #hv-calc-price-source { margin-top: 6px; font-size: 11px; text-align: center; color: #666; }\n    `;\n    document.head.appendChild(style);\n\n    const panel = document.createElement('div');\n    panel.id = 'hv-upgrade-calc';\n    panel.innerHTML = `\n        <h3>Legendary 升级计算器</h3>\n        <div class=\"hv-calc-row\"><label>当前等级 (0-24):</label><input type=\"number\" id=\"hv-curr-lvl\" value=\"0\" min=\"0\" max=\"24\"></div>\n        <div class=\"hv-calc-row\"><label>目标等级 (1-25):</label><input type=\"number\" id=\"hv-target-lvl\" value=\"25\" min=\"1\" max=\"25\"></div>\n        <div class=\"hv-calc-row\"><label>材料类型:</label><select id=\"hv-material-type\">${buildOptions(materialTypes)}</select></div>\n        <div class=\"hv-calc-row\"><label>Mid Grade 单价:</label><input type=\"number\" id=\"hv-price-mid\" value=\"0\" readonly></div>\n        <div class=\"hv-calc-row\"><label>High Grade 单价:</label><input type=\"number\" id=\"hv-price-high\" value=\"0\" readonly></div>\n        <div class=\"hv-calc-row\"><label>Rare 材料:</label><select id=\"hv-rare-material\">${buildOptions(rareMaterials)}</select></div>\n        <div class=\"hv-calc-row\"><label>Rare 单价:</label><input type=\"number\" id=\"hv-price-rare\" value=\"0\" readonly></div>\n        <div class=\"hv-calc-row\"><label>Legendary Core:</label><select id=\"hv-core-type\">${buildOptions(coreTypes)}</select></div>\n        <div class=\"hv-calc-row\"><label>Core 单价:</label><input type=\"number\" id=\"hv-price-core\" value=\"0\" readonly></div>\n        <button id=\"hv-calc-btn\">计算总消耗</button>\n        <div id=\"hv-calc-summary\"></div>\n        <div id=\"hv-calc-result\">等待计算...</div>\n        <div id=\"hv-calc-price-source\"></div>\n    `;\n    document.body.appendChild(panel);\n\n    let hvutPriceState = readHvutPrices();\n\n    function refreshPrices() {\n        hvutPriceState = readHvutPrices();\n        const prices = hvutPriceState.prices;\n        const materialType = document.getElementById('hv-material-type').value;\n        const rareMaterial = document.getElementById('hv-rare-material').value;\n        const coreType = document.getElementById('hv-core-type').value;\n\n        document.getElementById('hv-price-mid').value = priceOf(prices, `Mid-Grade ${materialType}`);\n        document.getElementById('hv-price-high').value = priceOf(prices, `High-Grade ${materialType}`);\n        document.getElementById('hv-price-rare').value = priceOf(prices, rareMaterial);\n        document.getElementById('hv-price-core').value = priceOf(prices, coreType);\n        document.getElementById('hv-calc-price-source').textContent = hvutPriceState.key ? `价格来源: HVUT ${hvutPriceState.key}` : '未找到 HVUT 价格，单价按 0 计算';\n    }\n\n    function calculate() {\n        refreshPrices();\n\n        const currLvl = parseInt(document.getElementById('hv-curr-lvl').value, 10) || 0;\n        const targetLvl = parseInt(document.getElementById('hv-target-lvl').value, 10) || 0;\n        const materialType = document.getElementById('hv-material-type').value;\n        const rareMaterial = document.getElementById('hv-rare-material').value;\n        const coreType = document.getElementById('hv-core-type').value;\n        const priceMid = parseFloat(document.getElementById('hv-price-mid').value) || 0;\n        const priceHigh = parseFloat(document.getElementById('hv-price-high').value) || 0;\n        const priceRare = parseFloat(document.getElementById('hv-price-rare').value) || 0;\n        const priceCore = parseFloat(document.getElementById('hv-price-core').value) || 0;\n\n        if (currLvl >= targetLvl || targetLvl > 25 || currLvl < 0) {\n            document.getElementById('hv-calc-result').textContent = '等级范围错误';\n            return;\n        }\n\n        let totalMid = 0;\n        let totalHigh = 0;\n        let totalRare = 0;\n        let totalCore = 0;\n        let baseCredits = 0;\n        for (let i = currLvl; i < targetLvl; i++) {\n            const data = upgradeData[i];\n            totalMid += data.mid;\n            totalHigh += data.high;\n            totalRare += data.rare;\n            totalCore += data.core;\n            baseCredits += data.creds;\n        }\n\n        const materialCredits = (totalMid * priceMid) + (totalHigh * priceHigh) + (totalRare * priceRare) + (totalCore * priceCore);\n        const totalCredits = baseCredits + materialCredits;\n\n        const summary = document.getElementById('hv-calc-summary');\n        summary.style.display = 'block';\n        summary.innerHTML = [\n            '<strong>材料需求</strong>',\n            `${totalMid} Mid-Grade ${materialType} @ ${formatCredits(priceMid)}c`,\n            `${totalHigh} High-Grade ${materialType} @ ${formatCredits(priceHigh)}c`,\n            `${totalRare} ${rareMaterial} @ ${formatCredits(priceRare)}c`,\n            `${totalCore} ${coreType} @ ${formatCredits(priceCore)}c`,\n            `基础 Credits: ${formatCredits(baseCredits)}`\n        ].join('<br>');\n        document.getElementById('hv-calc-result').textContent = `总需 Credits: ${formatCredits(totalCredits)}`;\n    }\n\n    document.getElementById('hv-material-type').addEventListener('change', calculate);\n    document.getElementById('hv-rare-material').addEventListener('change', calculate);\n    document.getElementById('hv-core-type').addEventListener('change', calculate);\n    document.getElementById('hv-calc-btn').addEventListener('click', calculate);\n    refreshPrices();\n})();\n\n\n"}