HALO Armory Drug Charges

Tracks drug usage from faction armory and records charges

当前为 2025-09-14 提交的版本,查看 最新版本

// ==UserScript==
// @name         HALO Armory Drug Charges
// @namespace    HALO-Faction
// @version      1.0
// @description  Tracks drug usage from faction armory and records charges
// @author       Nova
// @match        https://www.torn.com/factions.php?step=your*
// @grant        GM_setValue
// @grant        GM_getValue
// ==/UserScript==

(function() {
    'use strict';

    // Editable drug price list (per unit charge)
    const DRUG_PRICES = {
        "xanax": 760000,
        "ecstasy": 0,
        "ketamine": 0,
        "lsd": 0,
        "speed": 0,
        "pcp": 0,
        "shrooms": 0,
        "opium": 0,
        "vicodin": 0,
        "cannabis": 0
    };

    // Load stored debts and processed logs
    let debts = GM_getValue("halo_drug_debts", {});
    let processedLogs = GM_getValue("halo_processed_logs", {});

    // Create HALO panel
    function createPanel() {
        const panel = document.createElement("div");
        panel.id = "halo-panel";
        panel.style.position = "fixed";
        panel.style.bottom = "20px";
        panel.style.right = "20px";
        panel.style.width = "300px";
        panel.style.maxHeight = "400px";
        panel.style.overflowY = "auto";
        panel.style.background = "#111";
        panel.style.color = "#0f0";
        panel.style.padding = "10px";
        panel.style.border = "2px solid #0f0";
        panel.style.borderRadius = "10px";
        panel.style.fontFamily = "monospace";
        panel.style.fontSize = "12px";
        panel.style.zIndex = "9999";
        panel.innerHTML = "<h3 style='margin:0 0 10px 0;'>HALO Drug Charges</h3><div id='halo-debt-list'>Loading...</div>";
        document.body.appendChild(panel);
    }

    // Update panel with current debts
    function updatePanel() {
        let container = document.getElementById("halo-debt-list");
        if (!container) return;
        if (Object.keys(debts).length === 0) {
            container.innerHTML = "<p>No drug usage recorded.</p>";
            return;
        }

        let html = "<table style='width:100%; border-collapse:collapse;'>";
        for (let [user, amount] of Object.entries(debts)) {
            html += `<tr><td>${user}</td><td style='text-align:right;'>$${amount.toLocaleString()}</td></tr>`;
        }
        html += "</table>";
        container.innerHTML = html;
    }

    // Parse armory logs
    function parseLogs() {
        const logEntries = document.querySelectorAll(".faction-armory-events li");
        logEntries.forEach(entry => {
            const text = entry.innerText.toLowerCase();
            const logId = entry.getAttribute("data-id") || text;

            // Skip if already processed
            if (processedLogs[logId]) return;

            // Match drug usage
            let matchedDrug = Object.keys(DRUG_PRICES).find(d => text.includes(d));
            if (matchedDrug) {
                let user = "Unknown";
                const match = entry.innerText.match(/^(.+?)\s(used|took|consumed|used one)/i);
                if (match && match[1]) user = match[1].trim();

                const charge = DRUG_PRICES[matchedDrug] || 0;
                debts[user] = (debts[user] || 0) + charge;

                processedLogs[logId] = true;
            }
        });

        // Save updated data
        GM_setValue("halo_drug_debts", debts);
        GM_setValue("halo_processed_logs", processedLogs);
        updatePanel();
    }

    // Run
    createPanel();
    setInterval(parseLogs, 5000); // check logs every 5s

})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址