Track faction drug usage and auto-assign debt with reset button
当前为
// ==UserScript==
// @name HALO Faction Drug Debt Tracker
// @namespace http://tampermonkey.net/
// @version 2.2.1
// @description Track faction drug usage and auto-assign debt with reset button
// @author Nova
// @match https://www.torn.com/factions.php?step=your*
// @grant GM_setValue
// @grant GM_getValue
// ==/UserScript==
(function() {
'use strict';
const API_KEY = ''; // Put your API key here
const API_URL = 'https://api.torn.com/faction/?selections=armorynews&key=' + API_KEY;
// Drug prices (your custom list)
const DRUG_PRICES = {
"xanax": 760000,
"vicodin": 800,
"ketamine": 2000,
"shrooms": 2000,
"cannabis": 4500,
"speed": 6000,
"pcp": 7500,
"opium": 23000,
"lsd": 32000,
"ecstasy": 40000
};
// Load stored debts
let debts = GM_getValue("debts", {});
// Fetch logs and update debts
async function fetchLogs() {
try {
const response = await fetch(API_URL);
const data = await response.json();
if (data.armorynews) {
for (let log of data.armorynews) {
if (log.type === "drugs") {
let user = log.user_name;
let item = log.item.toLowerCase();
if (DRUG_PRICES[item]) {
debts[user] = (debts[user] || 0) + DRUG_PRICES[item];
}
}
}
GM_setValue("debts", debts);
renderPanel();
}
} catch (e) {
console.error("Error fetching armory logs:", e);
}
}
// Render panel
function renderPanel() {
let panel = document.getElementById("drug-debt-panel");
if (!panel) {
panel = document.createElement("div");
panel.id = "drug-debt-panel";
panel.style.position = "fixed";
panel.style.top = "100px";
panel.style.right = "20px";
panel.style.background = "#111";
panel.style.color = "#fff";
panel.style.padding = "10px";
panel.style.border = "2px solid #444";
panel.style.zIndex = "9999";
panel.style.fontSize = "14px";
panel.style.maxWidth = "220px";
panel.style.borderRadius = "8px";
document.body.appendChild(panel);
}
panel.innerHTML = "<b>Drug Debts</b><br>";
for (let [user, amount] of Object.entries(debts)) {
panel.innerHTML += `${user}, ${amount.toLocaleString()} <button data-user="${user}" style="margin-left:5px; cursor:pointer;">✅</button><br>`;
}
// Add event listeners for reset buttons
panel.querySelectorAll("button").forEach(btn => {
btn.addEventListener("click", () => {
let user = btn.getAttribute("data-user");
debts[user] = 0;
GM_setValue("debts", debts);
renderPanel();
});
});
}
// Start
fetchLogs();
setInterval(fetchLogs, 60000); // Refresh every 60s
})();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址