Torn Display Case Sets Tracker

Track flower and plushie sets in display case and show missing items for next set.

当前为 2025-10-01 提交的版本,查看 最新版本

// ==UserScript==
// @name         Torn Display Case Sets Tracker
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Track flower and plushie sets in display case and show missing items for next set.
// @author       Nova
// @match        https://www.torn.com/displaycase.php*
// @grant        GM_addStyle
// ==/UserScript==

(function() {
    'use strict';

    // Define required sets
    const FLOWERS = [
        "Dahlia", "Orchid", "African Violet", "Cherry Blossom", "Peony", "Ceibo Flower",
        "Edelweiss", "Crocus", "Heather", "Tribulus Omanense", "Banana Orchid"
    ];

    const PLUSHIES = [
        "Sheep Plushie", "Teddy Bear Plushie", "Kitten Plushie", "Jaguar Plushie", "Wolverine Plushie",
        "Nessie Plushie", "Red Fox Plushie", "Monkey Plushie", "Chamois Plushie", "Panda Plushie",
        "Lion Plushie", "Camel Plushie", "Stingray Plushie"
    ];

    // Add floating panel styles
    GM_addStyle(`
      #setTrackerPanel {
        position: fixed;
        top: 100px;
        left: 20px;
        width: 300px;
        background: #fff;
        color: #000;
        font-family: monospace;
        font-size: 12px;
        border: 1px solid #444;
        border-radius: 6px;
        padding: 8px;
        z-index: 9999;
        box-shadow: 0 0 10px rgba(0,0,0,0.4);
        max-height: 400px;
        overflow-y: auto;
      }
      #setTrackerPanel b { font-size: 13px; }
      #setTrackerPanel ul { margin: 2px 0 6px 15px; padding: 0; }
      #setTrackerPanel li { margin: 0; }
    `);

    const panel = document.createElement("div");
    panel.id = "setTrackerPanel";
    panel.innerHTML = `<b>Loading sets...</b>`;
    document.body.appendChild(panel);

    function parseCase() {
        const items = {};
        document.querySelectorAll(".item-wrap .title").forEach(el => {
            const name = el.textContent.trim();
            const qtyEl = el.closest(".item-wrap").querySelector(".qty");
            const qty = qtyEl ? parseInt(qtyEl.textContent.replace("x","").trim()) : 1;
            items[name] = (items[name] || 0) + qty;
        });
        return items;
    }

    function calcSets(required, items) {
        const counts = required.map(name => items[name] || 0);
        const minComplete = Math.min(...counts);
        const missing = required.filter(name => (items[name] || 0) <= minComplete);
        return { complete: minComplete, missing };
    }

    function updatePanel() {
        const items = parseCase();
        const flowers = calcSets(FLOWERS, items);
        const plushies = calcSets(PLUSHIES, items);

        panel.innerHTML = `
          <b>Flower Sets:</b> ${flowers.complete}<br>
          Missing for next:<ul>${flowers.missing.map(m => `<li>${m}</li>`).join("") || "<li>None</li>"}</ul>
          <b>Plushie Sets:</b> ${plushies.complete}<br>
          Missing for next:<ul>${plushies.missing.map(m => `<li>${m}</li>`).join("") || "<li>None</li>"}</ul>
        `;
    }

    // Run once page loads
    setTimeout(updatePanel, 1000);
})();