您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
estimates gym gain
当前为
// ==UserScript== // @name Gym Gain Estimator // @namespace TornExtensions // @version 1.2 // @description estimates gym gain // @author Xradiation // @match https://www.torn.com/gym.php // @grant none // @run-at document-end // ==/UserScript== (function() { 'use strict'; if (localStorage.getItem("apiKey") === null) { var apiKey = prompt("Please enter your apiKey", ""); if (apiKey !== null && apiKey !== "" ) { window.localStorage.setItem('apiKey', apiKey); } }else { apiKey = window.localStorage.getItem('apiKey'); } if (apiKey != null) { var Gymlist2 = [ { "Gym": "Premier Fitness", "Energy": 5, "Str": 2, "Spe": 2, "Def": 2, "Dex": 2}, { "Gym": "Average Joes", "Energy": 5, "Str": 2.4, "Spe": 2.4, "Def": 2.8, "Dex": 2.4}, { "Gym": "Woody's Workout", "Energy": 5, "Str": 2.8, "Spe": 3.2, "Def": 3, "Dex": 2.8}, { "Gym": "Beach Bods", "Energy": 5, "Str": 3.2, "Spe": 3.2, "Def": 3.2, "Dex": "-"}, { "Gym": "Silver Gym", "Energy": 5, "Str": 3.4, "Spe": 3.6, "Def": 3.4, "Dex": 3.2}, { "Gym": "Pour Femme", "Energy": 5, "Str": 3.4, "Spe": 3.6, "Def": 3.6, "Dex": 3.8}, { "Gym": "Davies Den", "Energy": 5, "Str": 3.7, "Spe": "-", "Def": 3.7, "Dex": 3.7}, { "Gym": "Global Gym", "Energy": 5, "Str": 4, "Spe": 4, "Def": 4, "Dex": 4}, { "Gym": "Knuckle Heads", "Energy": 10, "Str": 4.8, "Spe": 4.4, "Def": 4, "Dex": 4.2}, { "Gym": "Pioneer Fitness", "Energy": 10, "Str": 4.4, "Spe": 4.6, "Def": 4.8, "Dex": 4.4}, { "Gym": "Anabolic Anomalies", "Energy": 10, "Str": 5, "Spe": 4.6, "Def": 5.2, "Dex": 4.6}, { "Gym": "Core", "Energy": 10, "Str": 5, "Spe": 5.2, "Def": 5, "Dex": 5}, { "Gym": "Racing Fitness", "Energy": 10, "Str": 5, "Spe": 5.4, "Def": 4.8, "Dex": 5.2}, { "Gym": "Complete Cardio", "Energy": 10, "Str": 5.5, "Spe": 5.8, "Def": 5.5, "Dex": 5.2}, { "Gym": "Legs, Bums and Tums", "Energy": 10, "Str": "-", "Spe": 5.6, "Def": 5.6, "Dex": 5.8}, { "Gym": "Deep Burn", "Energy": 10, "Str": 6, "Spe": 6, "Def": 6, "Dex": 6}, { "Gym": "Apollo Gym", "Energy": 10, "Str": 6, "Spe": 6.2, "Def": 6.4, "Dex": 6.2}, { "Gym": "Gun Shop", "Energy": 10, "Str": 6.6, "Spe": 6.4, "Def": 6.2, "Dex": 6.2}, { "Gym": "Force Training", "Energy": 10, "Str": 6.4, "Spe": 6.6, "Def": 6.4, "Dex": 6.8}, { "Gym": "Cha Cha's", "Energy": 10, "Str": 6.4, "Spe": 6.4, "Def": 6.8, "Dex": 7}, { "Gym": "Atlas", "Energy": 10, "Str": 7, "Spe": 6.4, "Def": 6.4, "Dex": 6.6}, { "Gym": "Last Round", "Energy": 10, "Str": 6.8, "Spe": 6.6, "Def": 7, "Dex": 6.6}, { "Gym": "The Edge", "Energy": 10, "Str": 6.8, "Spe": 7, "Def": 7, "Dex": 6.8}, { "Gym": "George's", "Energy": 10, "Str": 7.3, "Spe": 7.3, "Def": 7.3, "Dex": 7.3}, { "Gym": "Balboas Gym", "Energy": 25, "Str": "-", "Spe": "-", "Def": 7.5, "Dex": 7.5}, { "Gym": "Frontline Fitness", "Energy": 25, "Str": 7.5, "Spe": 7.5, "Def": "-", "Dex": "-"}, { "Gym": "Gym 3000", "Energy": 50, "Str": 8, "Spe": "-", "Def": "-", "Dex": "-"}, { "Gym": "Mr. Isoyamas", "Energy": 50, "Str": "-", "Spe": "-", "Def": 8, "Dex": "-"}, { "Gym": "Total Rebound", "Energy": 50, "Str": "-", "Spe": 8, "Def": "-", "Dex": "-"}, { "Gym": "Elites", "Energy": 50, "Str": "-", "Spe": "-", "Def": "-", "Dex": 8}, { "Gym": "Sports Science Lab", "Energy": 25, "Str": 9, "Spe": 9, "Def": 9, "Dex": 9} ] var Gym, gymNumber, GymDotsSpe, GymDotsDef, GymDotsDex, GymDotsStr, speed, strength, defense, dexterity, strength_modifier, defense_modifier, speed_modifier, dexterity_modifier; var modifierSpe = modifierAll = modifierStr = modifierDex = modifierDef = 1; var a = 3.480061091 * Math.pow(10, -7);; var b = 250; var c = 3.091619094 * Math.pow(10, -6);; var d = 6.82775184551527 * Math.pow(10, -5);; var e = -0.0301431777; var happy, energy; // if(document.getElementById("gymroot")){ const urlStats = 'https://api.torn.com/user/?selections=battlestats&key=' + apiKey; const urlGym = 'https://api.torn.com/user/?selections=gym&key=' + apiKey; const urlHappy = 'https://api.torn.com/user/?selections=bars&key=' + apiKey; const urlMerits = 'https://api.torn.com/user/?selections=perks&key=' + apiKey; var apiRequest1 = fetch(urlStats).then(function(response){ return response.json() }); var apiRequest2 = fetch(urlHappy).then(function(response){ return response.json() }); var apiRequest3 = fetch(urlGym).then(function(response){ return response.json() }); var apiRequest4 = fetch(urlMerits).then(function(response){ return response.json() }); if( apiRequest1 != null && apiRequest2 != null && apiRequest3 != null && apiRequest4 != null){ Promise.all([apiRequest1,apiRequest2,apiRequest3,apiRequest4]).then(function(data){ //apiRequest1 strength = data[0]['strength']; defense = data[0]['defense']; speed = data[0]['speed']; dexterity = data[0]['dexterity']; strength_modifier = data[0]['strength_modifier']; defense_modifier = data[0]['defense_modifier']; speed_modifier = data[0]['speed_modifier']; dexterity_modifier = data[0]['dexterity_modifier']; //apiRequest2 happy = data[1]["happy"]["current"]; energy = data[1]["energy"]["current"]; //apiRequest3 Gym = Gymlist2[data[2]['active_gym'] - 1]["Gym"]; gymNumber = data[2]['active_gym'] - 1; //apiRequest4 var string; if(data[3].hasOwnProperty('property_perks')){ for (var i = 0; i < data[3]['property_perks'].length; i++) { string = data[3]['property_perks'][i]; if(string.includes('Gym gains')){ var n = parseFloat( data[3]['property_perks'][i].match(/\d+/)[0] ); n = ( n /100) + 1; modifierAll *= n; } } } if(data[3].hasOwnProperty('education_perks')){ for (var i = 0; i < data[3]['education_perks'].length; i++) { string = data[3]['education_perks'][i]; if(string.includes('1% Gym gains')){ modifierAll *= 1.01; } if(string.includes('Dexterity gym gains')){ modifierDex *= 1.01; } if(string.includes('Defense gym gains')){ modifierDef *= 1.01; } if(string.includes('Speed gym gains')){ modifierSpe *= 1.01; } if(string.includes('Strength gym gains')){ modifierStr *= 1.01; } } } if(data[3].hasOwnProperty('company_perks')){ for (var i = 0; i < data[3]['company_perks'].length; i++) { string = data[3]['company_perks'][i]; if(string.includes('dexterity gym gains')){ modifierDex *= 1.1; } else if(string.includes('defense gym gains')){ modifierDef *= 1.1; } else if(string.includes('gym gains')){ modifierAll *= 1.03; } } } if(data[3].hasOwnProperty('book_perks')){ for (var i = 0; i < data[3]['book_perks'].length; i++) { string = data[3]['book_perks'][i]; if(string.includes('all gym gains')){ modifierAll *= 1.2; } else if(string.includes('Strength gym gains')){ modifierStr *= 1.3; } else if(string.includes('Defense gym gains')){ modifierDef *= 1.3; } else if(string.includes('Speed gym gains')){ modifierSpe *= 1.3; } else if(string.includes('Dexterity gym gains')){ modifierDex *= 1.3; } } } if(data[3].hasOwnProperty('faction_perks')){ for (var i = 0; i < data[3]['faction_perks'].length; i++) { string = data[3]['faction_perks'][i]; if(string.includes('strength gym gains')){ n = parseFloat( data[3]['faction_perks'][i].match(/\d+/)[0] ); n = (n/100) + 1; modifierStr *= n; } if(string.includes('speed gym gains')){ n = parseFloat( data[3]['faction_perks'][i].match(/\d+/)[0] ); n = (n/100) + 1; modifierSpe *= n; } if(string.includes('defense gym gains')){ n = parseFloat( data[3]['faction_perks'][i].match(/\d+/)[0] ); n = (n/100) + 1; modifierDef *= n; } if(string.includes('dexterity gym gains by')){ n = parseFloat( data[3]['faction_perks'][i].match(/\d+/)[0] ); n = (n/100) + 1; modifierDex *= n; } } } modifierStr *= modifierAll; modifierSpe *= modifierAll; modifierDef *= modifierAll; modifierDex *= modifierAll; var GymDotsSpe = Gymlist2[gymNumber]['Spe']; var GymDotsDef = Gymlist2[gymNumber]['Def']; var GymDotsDex = Gymlist2[gymNumber]['Dex']; var GymDotsStr = Gymlist2[gymNumber]['Str']; var EnergyPerTrain = Gymlist2[gymNumber]['Energy']; var trains = Math.round( energy / EnergyPerTrain - 0.1 ) console.log("trains:" + trains ); var gainSpe = (modifierSpe)*(GymDotsSpe)*(EnergyPerTrain)*( (a * Math.log(Math.abs(happy + b)) + c) * (speed) + d*(happy+b) + e ); var gainDef = (modifierDef)*(GymDotsDef)*(EnergyPerTrain)*( (a * Math.log(Math.abs(happy + b)) + c) * (defense) + d*(happy+b) + e ); var gainDex = (modifierDex)*(GymDotsDef)*(EnergyPerTrain)*( (a * Math.log(Math.abs(happy + b)) + c) * (dexterity) + d*(happy+b) + e ); var gainStr = (modifierStr)*(GymDotsStr)*(EnergyPerTrain)*( (a * Math.log(Math.abs(happy + b)) + c) * (strength) + d*(happy+b) + e ); console.log (gainSpe); console.log (gainDef); console.log (gainDex); console.log (gainStr); var strText = '<div class="propertyTitle___36JU1 fontSize14___3E9pW"><h3 class="title___3FTtc">' + Math.round(gainStr * 100) / 100 + '</h3><span class="propertyValue___3oAOv">'+ Math.round(gainStr * 100) / 100 +'</span></div>'; var defText = '<div class="propertyTitle___36JU1 fontSize14___3E9pW"><h3 class="title___3FTtc">' + Math.round(gainDef * 100) / 100 + '</h3><span class="propertyValue___3oAOv">'+ Math.round(gainDef * 100) / 100 * trains +'</span></div>'; var speText ='<div class="propertyTitle___36JU1 fontSize14___3E9pW"><h3 class="title___3FTtc">' + Math.round(gainSpe * 100) / 100 + '</h3><span class="propertyValue___3oAOv">'+ Math.round(gainSpe * 100) / 100 +'</span></div>'; var dexText = '<div class="propertyTitle___36JU1 fontSize14___3E9pW"><h3 class="title___3FTtc">' + Math.round(gainDex * 100) / 100 + '</h3><span class="propertyValue___3oAOv">'+ Math.round(gainDex * 100) / 100 +'</span></div>'; /*needs optimalizition*/{ var array = [{'speText':speText, 'value':GymDotsSpe} , {'defText':defText,'value':GymDotsDef} , {'dexText':dexText,'value':GymDotsDex} , {'strText':strText,'value':GymDotsStr}]; var largest= [{'value': 0}]; array.forEach(function(element) { if (element['value']>largest[0]['value']) { largest = [element]; } else if (element['value'] == largest[0]['value']) { largest.push(element); } }); console.log(array); i = 0; largest.forEach(function(e) { var x = Object.keys(e)[0]; array[i][x] = e[x].replace('<div class="propertyTitle___36JU1 fontSize14___3E9pW">','<div class="propertyTitle___36JU1 fontSize14___3E9pW" style="color:lightgreen;">'); i++; }); } $(array[3]['strText']).insertAfter( ".strength___1GeGr .propertyTitle___36JU1" ); $(array[1]['defText']).insertAfter( ".defense___311kR .propertyTitle___36JU1" ); $(array[0]['speText']).insertAfter( ".speed___1o1b_ .propertyTitle___36JU1" ); $(array[2]['dexText']).insertAfter( ".dexterity___1YdUM .propertyTitle___36JU1" ); }); } }else { window.alert("Input a value for apiKey!!"); apiKey = prompt("Please enter your apiKey", ""); if (apiKey !== null && apiKey !== "" ) { window.localStorage.setItem('apiKey', apiKey); } } })();