Displays combat logs when clicking the button
当前为
// ==UserScript==
// @name Torn Combat Logger
// @namespace http://torn.com/
// @version 3.1
// @description Displays combat logs when clicking the button
// @author Quanna_Parker
// @match https://www.torn.com/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
// Add your Torn API key here
const apiKey = "ADD_API_KEY"; // Replace with your actual API key
// Initialize an array to store combat logs
let combatLogs = JSON.parse(localStorage.getItem("combatLogs")) || [];
// Create a button element
function createButton(text, className, onClickFunction) {
const button = document.createElement('button');
button.innerText = text;
button.classList.add(className);
button.addEventListener('click', onClickFunction);
return button;
}
// Create a div element
function createDiv(className) {
const div = document.createElement('div');
div.classList.add(className);
return div;
}
// Function to display combat logs
function viewLogs() {
let logWindow = document.createElement('div');
logWindow.style.position = 'fixed';
logWindow.style.top = '50px';
logWindow.style.right = '50px';
logWindow.style.width = '400px';
logWindow.style.height = '400px';
logWindow.style.backgroundColor = 'white';
logWindow.style.border = '1px solid black';
logWindow.style.zIndex = 1000;
logWindow.style.overflowY = 'scroll';
logWindow.style.padding = '10px';
logWindow.style.boxShadow = '0px 0px 10px rgba(0, 0, 0, 0.5)';
logWindow.style.borderRadius = '10px';
// Close button
let closeButton = document.createElement('button');
closeButton.innerHTML = 'Close';
closeButton.style.float = 'right';
closeButton.onclick = function() {
document.body.removeChild(logWindow);
};
let logContent = document.createElement('div');
logWindow.appendChild(closeButton);
logWindow.appendChild(logContent);
document.body.appendChild(logWindow);
// Display combat logs
let logsHTML = '<h3>Combat Logs</h3>';
combatLogs.forEach(log => {
logsHTML += `<p><strong>Time:</strong> ${log.time}<br/>
<strong>Attacker:</strong> ${log.attacker}<br/>
<strong>Damage:</strong> ${log.damage}<br/>
<strong>Result:</strong> ${log.result}<br/>
<strong>Attack Type:</strong> ${log.attackType}<br/>
<strong>Your Health (Before):</strong> ${log.yourHealthBefore}<br/>
<strong>Your Health (After):</strong> ${log.yourHealthAfter}</p><hr/>`;
});
logContent.innerHTML = logsHTML;
}
// Create the buttons
const combatLogBtn = createButton('Combat Logs', 'combat-logs-btn', viewLogs);
const settBtn = createButton('Settings', 'combat-settings-btn', toggleSettings);
// Create div containers for buttons
const settDiv = createDiv('combat-settings-container');
settDiv.append(settBtn);
const container = createDiv('combat-container');
container.append(combatLogBtn, settDiv);
document.body.appendChild(container);
// Toggle settings view
function toggleSettings() {
const container = document.getElementsByClassName("combat-settings-container")[0];
if (!container.classList.contains("combat-settings-container-expanded")) {
container.classList.toggle("combat-settings-container-expanded");
document.querySelector(".combat-settings-btn").textContent = "Close Settings";
}
}
// Basic CSS for button placement
const style = document.createElement('style');
style.innerHTML = `
.combat-container {
position: fixed;
top: 100px;
right: 20px;
z-index: 1000;
}
.combat-logs-btn, .combat-settings-btn {
padding: 10px;
margin: 5px;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
}
`;
document.head.appendChild(style);
})();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址