您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Calculates and displays the life percentage on Torn user profiles.
// ==UserScript== // @name Torn Life Percentage // @namespace https://bypxbyp.com // @version 1.1 // @description Calculates and displays the life percentage on Torn user profiles. // @license MIT // @author BypXByp [3243346] // @match https://www.torn.com/profiles.php?* // @icon https://www.google.com/s2/favicons?sz=64&domain=torn.com // @grant none // @run-at document-end // ==/UserScript== (function() { 'use strict'; function calculateAndDisplayLife() { const allInfoSections = document.querySelectorAll('div.user-information-section'); let lifeValueElement = null; for (const section of allInfoSections) { if (section.textContent.trim().toLowerCase() === 'life') { lifeValueElement = section.nextElementSibling; break; } } if (!lifeValueElement) { return false; } if (!lifeValueElement.classList.contains('user-info-value') || lifeValueElement.textContent.includes('%')) { return true; } const lifeText = lifeValueElement.textContent; const parts = lifeText.split('/'); if (parts.length !== 2) { return true; } const currentLife = parseInt(parts[0], 10); const maxLife = parseInt(parts[1], 10); if (!isNaN(currentLife) && !isNaN(maxLife) && maxLife > 0) { const percentage = Math.round((currentLife / maxLife) * 100); lifeValueElement.textContent = `${lifeText} (${percentage}%)`; console.log(`Torn Life Percentage: Successfully updated life to "${lifeValueElement.textContent}".`); return true; } return true; } const interval = setInterval(() => { if (calculateAndDisplayLife()) { clearInterval(interval); } }, 500); setTimeout(() => { clearInterval(interval); }, 20000); })();