Torn Extensions - Gym Torn Gain

calculates gym gain

La data de 01-12-2019. Vezi ultima versiune.

// ==UserScript==
// @name         Torn Extensions - Gym Torn Gain
// @namespace    TornExtensions
// @version      1.0.4
// @description  calculates gym gain
// @author       Xradiation
// @match        https://www.torn.com/gym.php
// @grant        none
// @run-at document-end
// ==/UserScript==

(function() {
    'use strict';


    //EDIT AT OWN RISK!!!

if(null===localStorage.getItem("apiKey")){var apiKey=prompt("Please enter your apiKey","");null!==apiKey&&""!==apiKey&&window.localStorage.setItem("apiKey",apiKey)}else apiKey=window.localStorage.getItem("apiKey");if(null!=apiKey){var Gym,gymNumber,GymDotsSpe,GymDotsDef,GymDotsDex,GymDotsStr,speed,strength,defense,dexterity,strength_modifier,defense_modifier,speed_modifier,dexterity_modifier,happy,energy,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}],modifierSpe=1,modifierAll=1,modifierStr=1,modifierDex=1,modifierDef=1,a=3.480061091*Math.pow(10,-7),b=250,c=3.091619094*Math.pow(10,-6),d=6.82775184551527*Math.pow(10,-5),e=-.0301431777,urlStats="https://api.torn.com/user/?selections=battlestats&key="+apiKey,urlGym="https://api.torn.com/user/?selections=gym&key="+apiKey,urlHappy="https://api.torn.com/user/?selections=bars&key="+apiKey,urlMerits="https://api.torn.com/user/?selections=perks&key="+apiKey,apiRequest1=fetch(urlStats).then(function(e){return e.json()}),apiRequest2=fetch(urlHappy).then(function(e){return e.json()}),apiRequest3=fetch(urlGym).then(function(e){return e.json()}),apiRequest4=fetch(urlMerits).then(function(e){return e.json()});null!=apiRequest1&&null!=apiRequest2&&null!=apiRequest3&&null!=apiRequest4&&Promise.all([apiRequest1,apiRequest2,apiRequest3,apiRequest4]).then(function(r){var t;if(strength=r[0].strength,defense=r[0].defense,speed=r[0].speed,dexterity=r[0].dexterity,strength_modifier=r[0].strength_modifier,defense_modifier=r[0].defense_modifier,speed_modifier=r[0].speed_modifier,dexterity_modifier=r[0].dexterity_modifier,happy=r[1].happy.current,energy=r[1].energy.current,Gym=Gymlist2[r[2].active_gym-1].Gym,gymNumber=r[2].active_gym-1,r[3].hasOwnProperty("property_perks"))for(var i=0;i<r[3].property_perks.length;i++)if((t=r[3].property_perks[i]).includes("Gym gains")){var s=parseFloat(r[3].property_perks[i].match(/\d+/)[0]);modifierAll*=s=s/100+1}if(r[3].hasOwnProperty("education_perks"))for(i=0;i<r[3].education_perks.length;i++)(t=r[3].education_perks[i]).includes("1% Gym gains")&&(modifierAll*=1.01),t.includes("Dexterity gym gains")&&(modifierDex*=1.01),t.includes("Defense gym gains")&&(modifierDef*=1.01),t.includes("Speed gym gains")&&(modifierSpe*=1.01),t.includes("Strength gym gains")&&(modifierStr*=1.01);if(r[3].hasOwnProperty("company_perks"))for(i=0;i<r[3].company_perks.length;i++)(t=r[3].company_perks[i]).includes("dexterity gym gains")?modifierDex*=1.1:t.includes("defense gym gains")?modifierDef*=1.1:t.includes("gym gains")&&(modifierAll*=1.03);if(r[3].hasOwnProperty("book_perks"))for(i=0;i<r[3].book_perks.length;i++)(t=r[3].book_perks[i]).includes("all gym gains")?modifierAll*=1.2:t.includes("Strength gym gains")?modifierStr*=1.3:t.includes("Defense gym gains")?modifierDef*=1.3:t.includes("Speed gym gains")?modifierSpe*=1.3:t.includes("Dexterity gym gains")&&(modifierDex*=1.3);if(r[3].hasOwnProperty("faction_perks"))for(i=0;i<r[3].faction_perks.length;i++)(t=r[3].faction_perks[i]).includes("strength gym gains")&&(s=parseFloat(r[3].faction_perks[i].match(/\d+/)[0]),modifierStr*=s=s/100+1),t.includes("speed gym gains")&&(s=parseFloat(r[3].faction_perks[i].match(/\d+/)[0]),modifierSpe*=s=s/100+1),t.includes("defense gym gains")&&(s=parseFloat(r[3].faction_perks[i].match(/\d+/)[0]),modifierDef*=s=s/100+1),t.includes("dexterity gym gains by")&&(s=parseFloat(r[3].faction_perks[i].match(/\d+/)[0]),modifierDex*=s=s/100+1);modifierStr*=modifierAll,modifierSpe*=modifierAll,modifierDef*=modifierAll,modifierDex*=modifierAll;var n=Gymlist2[gymNumber].Spe,p=Gymlist2[gymNumber].Def,o=Gymlist2[gymNumber].Dex,y=Gymlist2[gymNumber].Str,l=Gymlist2[gymNumber].Energy,m=Math.round(energy/l-.1),f=modifierSpe*n*l*((a*Math.log(Math.abs(happy+b))+c)*speed+d*(happy+b)+e),_=modifierDef*p*l*((a*Math.log(Math.abs(happy+b))+c)*defense+d*(happy+b)+e),g=modifierDex*p*l*((a*Math.log(Math.abs(happy+b))+c)*dexterity+d*(happy+b)+e),u=modifierStr*y*l*((a*Math.log(Math.abs(happy+b))+c)*strength+d*(happy+b)+e),S='<div class="propertyTitle___36JU1 fontSize14___3E9pW"><h3 class="title___3FTtc">'+Math.round(100*u)/100+'</h3><span class="propertyValue___3oAOv">'+Math.round(100*u)/100*m+"</span></div>",D='<div class="propertyTitle___36JU1 fontSize14___3E9pW"><h3 class="title___3FTtc">'+Math.round(100*_)/100+'</h3><span  class="propertyValue___3oAOv">'+Math.round(100*_)/100*m+"</span></div>",h=[{speText:'<div class="propertyTitle___36JU1 fontSize14___3E9pW"><h3 class="title___3FTtc">'+Math.round(100*f)/100+'</h3><span  class="propertyValue___3oAOv">'+Math.round(100*f)/100*m+"</span></div>",value:n},{defText:D,value:p},{dexText:'<div class="propertyTitle___36JU1 fontSize14___3E9pW"><h3 class="title___3FTtc">'+Math.round(100*g)/100+'</h3><span  class="propertyValue___3oAOv">'+Math.round(100*g)/100*m+"</span></div>",value:o},{strText:S,value:y}],x=[{value:0}];h.forEach(function(e){e.value>x[0].value?x=[e]:e.value==x[0].value&&x.push(e)}),i=0,x.forEach(function(e){var r=Object.keys(e)[0];h[i][r]=e[r].replace('<div class="propertyTitle___36JU1 fontSize14___3E9pW">','<div class="propertyTitle___36JU1 fontSize14___3E9pW" style="color:lightgreen;">'),i++}),$(h[3].strText).insertAfter(".strength___1GeGr .propertyTitle___36JU1"),$(h[1].defText).insertAfter(".defense___311kR .propertyTitle___36JU1"),$(h[0].speText).insertAfter(".speed___1o1b_ .propertyTitle___36JU1"),$(h[2].dexText).insertAfter(".dexterity___1YdUM .propertyTitle___36JU1")})}else window.alert("Input a value for apiKey!!"),null!==(apiKey=prompt("Please enter your apiKey",""))&&""!==apiKey&&window.localStorage.setItem("apiKey",apiKey);

})();