您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Calculates how much enemy's health has to be for execute to proc
// ==UserScript== // @name Execute Proc Calculator // @namespace http://tampermonkey.net/ // @version 1.0.1 // @description Calculates how much enemy's health has to be for execute to proc // @author CastyLoz17 // @match https://www.torn.com/loader.php?sid=attack* // @icon https://www.google.com/s2/favicons?sz=64&domain=torn.com // @grant none // @license MIT // ==/UserScript== (function () { "use strict"; function getNthParentDiv(element, n) { let current = element; let count = 0; while (current && count < n) { current = current.parentElement; if (current) { count++; } } return count === n ? current : null; } function run() { // get enemy health const opponent_health_elem = document.querySelectorAll( '[id^="player-health-value_"]' )[1]; if (!opponent_health_elem) { console.log("no opponent health found yet, retrying..."); setTimeout(run, 100); // retry after half a sec return; } const opponent_max_health = parseInt( opponent_health_elem.innerText.split(" / ")[1].replaceAll(",", "") ); const coreWrap = document.querySelector(".coreWrap___LtSEy"); if (!coreWrap) { console.log("no coreWrap yet, retrying..."); setTimeout(run, 500); return; } [...document.getElementsByClassName("bonus-attachment-execute")].forEach( (bonus_element) => { let bonus = bonus_element.dataset.bonusAttachmentDescription; let execute_percentage = parseInt( bonus.split(" ")[7].replaceAll("%", "") ); let weapon_element = getNthParentDiv(bonus_element, 4); let weapon_name = weapon_element.ariaLabel.replaceAll( "Attack with ", "" ); let health_calculation = opponent_max_health * (execute_percentage / 100); // add to interface let message = `Execute will proc for ${weapon_name} at ${Math.floor(health_calculation)} life`; const p = document.createElement("h2"); p.textContent = message; coreWrap.insertBefore(p, coreWrap.children[1]); } ); } window.addEventListener("load", run); })();