IdlePixel XP Calculator - GodofNades Fork (rehost)

Calculator for Idle-Pixel.com for Mining / Crafting / Farming / Brewing

  1. // ==UserScript==
  2. // @name IdlePixel XP Calculator - GodofNades Fork (rehost)
  3. // @namespace namespaceuniquetome
  4. // @version 1.4.2
  5. // @description Calculator for Idle-Pixel.com for Mining / Crafting / Farming / Brewing
  6. // @author Original Author: shtos || Modded By: GodofNades
  7. // @license MIT
  8. // @match *://idle-pixel.com/login/play*
  9. // @grant none
  10. // @require https://gf.qytechs.cn/scripts/441206-idlepixel/code/IdlePixel+.js
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15. let loaded = false;
  16.  
  17. const POTION_XP_MAP = {
  18. "stardust_potion": 75,
  19. "energy_potion": 50,
  20. "anti_disease_potion": 250,
  21. "tree_speed_potion": 525,
  22. "smelting_upgrade_potion": 550,
  23. "great_stardust_potion": 1925,
  24. "farming_speed_potion": 500,
  25. "rare_monster_potion": 2125,
  26. "super_stardust_potion": 4400,
  27. "gathering_unique_potion": 3000,
  28. "heat_potion": 2500,
  29. "bait_potion": 1000,
  30. "bone_potion": 1550,
  31. "furnace_speed_potion": 6000,
  32. "promethium_potion": 2000,
  33. "oil_potion": 5000,
  34. "super_rare_monster_potion": 6000,
  35. "ultra_stardust_potion": 12900,
  36. "magic_shiny_crystal_ball_potion": 7000,
  37. "birdhouse_potion": 800,
  38. "rocket_potion": 1500,
  39. "titanium_potion": 5000,
  40. "blue_orb_potion": 50000,
  41. "geode_potion": 9500,
  42. "magic_crystal_ball_potion": 12000,
  43. "stone_converter_potion": 4000,
  44. "rain_potion": 2500,
  45. "combat_loot_potion": 9500,
  46. "rotten_potion": 1250,
  47. "merchant_speed_potion": 50000,
  48. "green_orb_potion": 200000,
  49. "guardian_key_potion": 42500,
  50. "ancient_potion": 40000,
  51. "red_orb_potion": 500000,
  52. "cooks_dust_potion": 100000,
  53. "farm_dust_potion": 100000,
  54. "fighting_dust_potion": 100000,
  55. "tree_dust_potion": 100000,
  56. "infinite_oil_potion": 0
  57. }
  58.  
  59. const INGREDIENT_XP_MAP = {
  60. "dotted_green_leaf": 25,
  61. "green_leaf": 100,
  62. "lime_leaf":250,
  63. "gold_leaf":800,
  64. "red_mushroom": 5,
  65. "strange_leaf":500,
  66. "moonstone": 249,
  67. "rocket_fuel": 250,
  68. "seaweed":0,
  69. "bones":0,
  70. "promethium":0,
  71. "titanium":0,
  72. "stranger_leaf":2875,
  73. "crystal_leaf": 2000,
  74. "super_bait": 0,
  75. "fruit_skin": 0,
  76. "maggots":0,
  77. "stone":0,
  78. "ancient_ore": 0,
  79. "blue_shooting_star": 50000,
  80. "green_shooting_star": 200000,
  81. "red_shooting_star": 500000,
  82. "charcoal": 0,
  83. "feathers": 0,
  84. "ice_feathers": 0,
  85. "fire_feathers": 0,
  86. "cooks_dust": 20000,
  87. "farm_dust": 20000,
  88. "fighting_dust": 20000,
  89. "tree_dust": 20000,
  90. "achievements": 0
  91. }
  92.  
  93. const BARS_XP_MAP = {
  94. "bronze": 5,
  95. "iron": 25,
  96. "silver": 50,
  97. "gold": 100,
  98. "promethium": 500,
  99. "titanium": 2000,
  100. "ancient": 5000,
  101. "dragon": "Nan"
  102. }
  103.  
  104. const ORES_XP_MAP = {
  105. "stone": 0.1,
  106. "copper": 1,
  107. "iron": 5,
  108. "silver": 10,
  109. "gold": 20,
  110. "promethium":100,
  111. "titanium":300,
  112. "ancient": "NaN",
  113. "dragon": "NaN"
  114. }
  115.  
  116. const SEEDS_XP_MAP = {
  117. "red_mushroom_seeds": 40,
  118. "dotted_green_leaf_seeds": 150,
  119. "stardust_seeds": 222,
  120. "green_leaf_seeds": 300,
  121. "lime_leaf_seeds": 390,
  122. "gold_leaf_seeds": 1000,
  123. "crystal_leaf_seeds": 2450,
  124. "tree_seeds": 3000,
  125. "oak_tree_seeds": 10000,
  126. "willow_tree_seeds": 20000,
  127. "apple_tree_seeds": 20000,
  128. "maple_tree_seeds": 45000,
  129. "banana_tree_seeds": 47800,
  130. "stardust_tree_seeds": 70000,
  131. "orange_tree_seeds": 72850,
  132. "pine_tree_seeds": 90000,
  133. "palm_tree_seeds": 100000,
  134. "redwood_tree_seeds": 150000,
  135. "bone_tree_seeds": 200000,
  136. "lava_tree_seeds": 264000,
  137. "strange_tree_seeds": 425145,
  138. "dragon_fruit_tree_seeds": 400000
  139. }
  140.  
  141. const BONEMEAL_SEED_MAP = {
  142. "red_mushroom_seeds": 0,
  143. "dotted_green_leaf_seeds": 0,
  144. "stardust_seeds": 0,
  145. "green_leaf_seeds": 0,
  146. "lime_leaf_seeds": 1,
  147. "gold_leaf_seeds": 5,
  148. "crystal_leaf_seeds": 25,
  149. "tree_seeds": 10,
  150. "oak_tree_seeds": 25,
  151. "willow_tree_seeds": 50,
  152. "apple_tree_seeds": 50,
  153. "maple_tree_seeds": 120,
  154. "banana_tree_seeds": 70,
  155. "stardust_tree_seeds": 150,
  156. "orange_tree_seeds": 120,
  157. "pine_tree_seeds": 180,
  158. "palm_tree_seeds": 200,
  159. "redwood_tree_seeds": 300,
  160. "bone_tree_seeds": 0,
  161. "lava_tree_seeds": 300,
  162. "strange_tree_seeds": 500,
  163. "dragon_fruit_tree_seeds": 500
  164. }
  165.  
  166. let potionArray = Object.keys(POTION_XP_MAP).toString().split(',');
  167.  
  168. const calculatorSettings = {
  169. mining: {
  170. targetLevel: 0,
  171. tool: 'none',
  172. orb: false,
  173. hide: false,
  174. outfit: {
  175. gloves: false,
  176. shirt: false,
  177. pants: false,
  178. boots: false,
  179. bonus: 0,
  180. },
  181. fullOutfit: false,
  182. },
  183. crafting: {
  184. targetLevel: 0,
  185. tool: 'none',
  186. orb: false,
  187. hide: false,
  188. perk: false,
  189. outfit: {
  190. gloves: false,
  191. shirt: false,
  192. pants: false,
  193. boots: false,
  194. bonus: 0,
  195. },
  196. fullOutfit: false,
  197. },
  198. brewing: {
  199. targetLevel: 0,
  200. hide: false,
  201. outfit: {
  202. gloves: false,
  203. shirt: false,
  204. pants: false,
  205. boots: false,
  206. bonus: 0,
  207. },
  208. fullOutfit: false
  209. },
  210. farming: {
  211. targetLevel: 0,
  212. hide: false,
  213. outfit: {
  214. gloves: false,
  215. shirt: false,
  216. pants: false,
  217. boots: false,
  218. bonus: 0,
  219. },
  220. fullOutfit: false,
  221. },
  222. shared: {
  223. donor: false,
  224. }
  225. }
  226.  
  227.  
  228. class XpCalculatorPlugin extends IdlePixelPlusPlugin {
  229. constructor() {
  230. super("xpcalculator", { // unique plugin id, "sample"
  231. about: { // optional, but highly recommended
  232. name: GM_info.script.name + " (ver: " + GM_info.script.version + ")",
  233. version: GM_info.script.version,
  234. author: GM_info.script.author,
  235. description: GM_info.script.description
  236. }
  237. });
  238. }
  239.  
  240. onLogin(){
  241.  
  242.  
  243. // CRAFTING HTML
  244.  
  245. let html = $('#oil-summary-crafting').children().length ? '#oil-summary-crafting' : '#panel-crafting .progress-bar';
  246. $(html).after(
  247. `<hr>
  248. <div style="display: flex; flex-direction: column;">
  249. <h5>XP Calculator:<button id="crafting-visibility-button">Hide</button></h5>
  250. <div id="crafting-calculator-div">
  251. <div>
  252. <label>Target Level:</label><input id="crafting-target-level" style="width:70px" type="number">
  253. <span >Required XP: <span id="crafting-xp-required"></span></span>
  254. <span>Required SD: <span id="crafting-sd-required"></span></span>
  255. <span>Required bars: <span id="crafting-bars-required">
  256. <span><img style="height: 32px; width: 32px;" src="https://d1xsc8x7nc5q8t.cloudfront.net/images/bronze_bar.png"> <span id="crafting-calculator-bronze"> 0</span> </span>
  257. <span><img style="height: 32px; width: 32px;" src="https://d1xsc8x7nc5q8t.cloudfront.net/images/iron_bar.png"> <span id="crafting-calculator-iron"> 0</span> </span>
  258. <span><img style="height: 32px; width: 32px;" src="https://d1xsc8x7nc5q8t.cloudfront.net/images/silver_bar.png"> <span id="crafting-calculator-silver"> 0</span> </span>
  259. <span><img style="height: 32px; width: 32px;" src="https://d1xsc8x7nc5q8t.cloudfront.net/images/gold_bar.png"> <span id="crafting-calculator-gold"> 0</span> </span>
  260. <span><img style="height: 32px; width: 32px;" src="https://d1xsc8x7nc5q8t.cloudfront.net/images/promethium_bar.png"> <span id="crafting-calculator-promethium"> 0</span> </span>
  261. <span><img style="height: 32px; width: 32px;" src="https://d1xsc8x7nc5q8t.cloudfront.net/images/titanium_bar.png"> <span id="crafting-calculator-titanium"> 0</span> </span>
  262. <span><img style="height: 32px; width: 32px;" src="https://d1xsc8x7nc5q8t.cloudfront.net/images/ancient_bar.png"> <span id="crafting-calculator-ancient"> 0</span> </span>
  263. <span><img style="height: 32px; width: 32px;" src="https://d1xsc8x7nc5q8t.cloudfront.net/images/dragon_bar.png"> <span id="crafting-calculator-dragon"> 0</span> </span>
  264. </span>
  265. </span>
  266. </div>
  267. <div id="crafting-xp-options" style="
  268. margin-top: 15px;
  269. ">
  270.  
  271. <form id="crafting-calculator-form">
  272. <span>Tool gem: </span><label for="none" style="margin-right: 5px;">None</label><input type="radio" id="none" value="none" name="tool">
  273. <label for="sapphire" style="margin-right: 5px;">Sapphire</label><input type="radio" id="sapphire" value="sapphire" name="tool">
  274. <label for="emerald" style="margin-right: 5px;">Emerald</label><input type="radio" id="emerald" value="emerald" name="tool">
  275. <label for="ruby" style="margin-right: 5px;">Ruby</label><input type="radio" id="ruby" value="ruby" name="tool">
  276. <label for="diamond" style="margin-right: 5px;">Diamond</label><input type="radio" id="diamond" value="diamond" name="tool">
  277. </form>
  278. <span>Donor perk: </span> <input id="crafting-donor-perk-check" type="checkbox" style="margin-right: 10px;">
  279. <span>Blue orb: </span> <input id="crafting-blue-orb-check" type="checkbox" style="margin-right: 10px;">
  280. <span>Medium perk: </span> <input id="crafting-medium-achievement-check" type="checkbox" style="margin-right: 10px;">
  281. <span>Outfit bonus: </span> <input id="crafting-outfit-check" type="checkbox" style="margin-right: 10px;">
  282. </div>
  283. </div>
  284. </div>
  285. `)
  286. document.querySelector('#crafting-visibility-button').onclick = ()=>{this.handleVisibility('crafting')};
  287. document.querySelector('#crafting-target-level').onchange = (event)=>{this.calculatorSettingsChanged('crafting', 'targetLevel', event.target.value)};
  288. document.querySelector('#crafting-calculator-form').onchange = (event)=>{this.calculatorSettingsChanged('crafting', 'tool', event.target.value)};
  289. document.querySelector('#crafting-blue-orb-check').onchange = (event)=>{this.calculatorSettingsChanged('crafting', 'orb', event.target.checked)};
  290. document.querySelector('#crafting-medium-achievement-check').onchange = (event)=>{this.calculatorSettingsChanged('crafting', 'perk', event.target.checked)};
  291. document.querySelector('#crafting-donor-perk-check').onchange = (event)=>{this.calculatorSettingsChanged('shared', 'donor', event.target.checked)};
  292. document.querySelector('#crafting-outfit-check').onchange = (event)=>{this.calculatorSettingsChanged('crafting', 'fullOutfit', event.target.checked)};
  293. //
  294. //
  295. // MINING HTML
  296. html = $('#oil-summary-mining').children().length ? '#oil-summary-mining' : '#panel-mining .progress-bar';
  297. $(html).after(
  298. `<hr>
  299. <div style="display: flex; flex-direction: column;">
  300. <h5>XP Calculator:<button id="mining-visibility-button">Hide</button></h5>
  301. <div id="mining-calculator-div">
  302. <div>
  303. <label>Target Level:</label><input id="mining-target-level" style="width:70px" type="number">
  304. <span >Required XP: <span id="mining-xp-required"></span></span>
  305. <span>Required SD: <span id="mining-sd-required"></span></span>
  306. <span>Required ores: <span id="mining-ores-required">
  307. <span><img style="height: 32px; width: 32px;" src="https://d1xsc8x7nc5q8t.cloudfront.net/images/stone.png"> <span id="mining-calculator-stone"> 0</span> </span>
  308. <span><img style="height: 32px; width: 32px;" src="https://d1xsc8x7nc5q8t.cloudfront.net/images/copper.png"> <span id="mining-calculator-copper"> 0</span> </span>
  309. <span><img style="height: 32px; width: 32px;" src="https://d1xsc8x7nc5q8t.cloudfront.net/images/iron.png"> <span id="mining-calculator-iron"> 0</span> </span>
  310. <span><img style="height: 32px; width: 32px;" src="https://d1xsc8x7nc5q8t.cloudfront.net/images/silver.png"> <span id="mining-calculator-silver"> 0</span> </span>
  311. <span><img style="height: 32px; width: 32px;" src="https://d1xsc8x7nc5q8t.cloudfront.net/images/gold.png"> <span id="mining-calculator-gold"> 0</span> </span>
  312. <span><img style="height: 32px; width: 32px;" src="https://d1xsc8x7nc5q8t.cloudfront.net/images/promethium.png"> <span id="mining-calculator-promethium"> 0</span> </span>
  313. <span><img style="height: 32px; width: 32px;" src="https://d1xsc8x7nc5q8t.cloudfront.net/images/titanium.png"> <span id="mining-calculator-titanium"> 0</span> </span>
  314. <span><img style="height: 32px; width: 32px;" src="https://d1xsc8x7nc5q8t.cloudfront.net/images/ancient_ore.png"> <span id="mining-calculator-ancient"> 0</span> </span>
  315. <span><img style="height: 32px; width: 32px;" src="https://d1xsc8x7nc5q8t.cloudfront.net/images/dragon_ore.png"> <span id="mining-calculator-dragon"> 0</span> </span>
  316. </span>
  317. </span>
  318. </div>
  319. <div id="mining-xp-options" style="
  320. margin-top: 15px;
  321. ">
  322.  
  323. <form id="mining-calculator-form">
  324. <span>Tool gem: </span><label for="none" style="margin-right: 5px;">None</label><input type="radio" id="none" value="none" name="tool">
  325. <label for="sapphire" style="margin-right: 5px;">Sapphire</label><input type="radio" id="sapphire" value="sapphire" name="tool">
  326. <label for="emerald" style="margin-right: 5px;">Emerald</label><input type="radio" id="emerald" value="emerald" name="tool">
  327. <label for="ruby" style="margin-right: 5px;">Ruby</label><input type="radio" id="ruby" value="ruby" name="tool">
  328. <label for="diamond" style="margin-right: 5px;">Diamond</label><input type="radio" id="diamond" value="diamond" name="tool">
  329. </form>
  330. <span>Donor perk: </span> <input id="mining-donor-perk-check" type="checkbox" style="margin-right: 10px;">
  331. <span>Blue orb: </span> <input id="mining-blue-orb-check" type="checkbox" style="margin-right: 10px;">
  332. <span>Outfit bonus: </span> <input id="mining-outfit-check" type="checkbox" style="margin-right: 10px;">
  333. </div>
  334. </div>
  335. </div>
  336. `)
  337.  
  338. document.querySelector('#mining-visibility-button').onclick = ()=>{this.handleVisibility('mining')};
  339. document.querySelector('#mining-target-level').onchange = (event)=>{this.calculatorSettingsChanged('mining', 'targetLevel', event.target.value)};
  340. document.querySelector('#mining-calculator-form').onchange = (event)=>{this.calculatorSettingsChanged('mining', 'tool', event.target.value)};
  341. document.querySelector('#mining-blue-orb-check').onchange = (event)=>{this.calculatorSettingsChanged('mining', 'orb', event.target.checked)};
  342. document.querySelector('#mining-donor-perk-check').onchange = (event)=>{this.calculatorSettingsChanged('shared', 'donor', event.target.checked)};
  343. document.querySelector('#mining-outfit-check').onchange = (event)=>{this.calculatorSettingsChanged('mining', 'fullOutfit', event.target.checked)};
  344. ////////////////////////////////////////////////////////////////////
  345. //Array.from(document.querySelectorAll('#brewing-table img[src*="potion"]')).forEach((potion)=>potionArray.push(potion.title))
  346. $("#panel-brewing .progress-bar").first().after(`
  347. <hr>
  348. <div style="display: flex; flex-direction: column;">
  349. <h5>XP Calculator:<button id="brewing-visibility-button">Hide</button></h5>
  350. <div id="brewing-calculator-div">
  351. <div>
  352. <label>Target Level:</label><input id="brewing-target-level" style="width:70px" type="number">
  353. <span >Required XP: <span id="brewing-xp-required"></span></span>
  354. <div style="margin-top: 10px;">Required potions: <span id="brewing-potions-required">
  355.  
  356. </span>
  357. </div>
  358. </div>
  359. <div id="brewing-xp-options" style="
  360. margin-top: 15px;
  361. ">
  362. <span>Donor perk: </span> <input id="brewing-donor-perk-check" type="checkbox" style="margin-right: 10px;">
  363. <span>Outfit bonus: </span> <span id="brewing-outfit-bonus" style="margin-right: 10px;">0</span>
  364. </div>
  365. </div>
  366. </div>`)
  367.  
  368. let potionHTML = '';
  369. potionArray.forEach((potion)=>{
  370. if(potion != "infinite_oil_potion") {
  371. potionHTML += `<span><img style="height: 32px; width: 32px;" src="https://d1xsc8x7nc5q8t.cloudfront.net/images/${potion}.png"> <span id="brewing-calculator-${potion}"> 0</span> </span>`
  372. }
  373. })
  374. document.querySelector('#brewing-potions-required').innerHTML = potionHTML;
  375. document.querySelector('#brewing-visibility-button').onclick = ()=>{this.handleVisibility('brewing')};
  376. document.querySelector('#brewing-target-level').onchange = (event)=>{this.calculatorSettingsChanged('brewing', 'targetLevel', event.target.value)};
  377. document.querySelector('#brewing-donor-perk-check').onchange = (event)=>{this.calculatorSettingsChanged('shared', 'donor', event.target.checked)};
  378. //////////////////////////////////////////////////////////////////////
  379. //Array.from(document.querySelectorAll("#farming-table img[src*=farming]")).forEach((seeds)=>seedsArray.push(seeds.title))
  380. $("#panel-farming .progress-bar").first().after(`
  381. <hr>
  382. <div style="display: flex; flex-direction: column;">
  383. <h5>XP Calculator:<button id="farming-visibility-button">Hide</button></h5>
  384. <div id="farming-calculator-div">
  385. <div>
  386. <label>Target Level:</label><input id="farming-target-level" style="width:70px" type="number">
  387. <span >Required XP: <span id="farming-xp-required"></span></span>
  388. <div style="margin-top: 10px;">Required Seeds (Bonemeal): <span id="farming-seeds-required">
  389.  
  390. </span>
  391. </div>
  392. </div>
  393. <div id="farming-xp-options" style="
  394. margin-top: 15px;
  395. ">
  396. <span>Donor perk: </span> <input id="farming-donor-perk-check" type="checkbox" style="margin-right: 10px;">
  397. <span>Outfit bonus: </span> <span id="farming-outfit-bonus" style="margin-right: 10px;">0</span>
  398. </div>
  399. </div>
  400. </div>`)
  401.  
  402. let farmingHTML = '';
  403. let seeds = Object.keys(SEEDS_XP_MAP);
  404. seeds.forEach((seeds)=>{
  405. farmingHTML += `<span><img style="height: 32px; width: 32px;" src="https://d1xsc8x7nc5q8t.cloudfront.net/images/${seeds}.png"> <span id="farming-calculator-${seeds}"> 0</span> </span>`
  406. })
  407. document.querySelector('#farming-seeds-required').innerHTML = farmingHTML;
  408. document.querySelector('#farming-visibility-button').onclick = ()=>{this.handleVisibility('farming')};
  409. document.querySelector('#farming-target-level').onchange = (event)=>{this.calculatorSettingsChanged('farming', 'targetLevel', event.target.value)};
  410. document.querySelector('#farming-donor-perk-check').onchange = (event)=>{this.calculatorSettingsChanged('shared', 'donor', event.target.checked)};
  411. ////////////////////////////////////////////////////////////////////
  412.  
  413. calculatorSettings.crafting.targetLevel = get_level(IdlePixelPlus.getVarOrDefault('crafting_xp', 0, 'int'))+1;
  414. document.querySelector('#crafting-target-level').value = calculatorSettings.crafting.targetLevel;
  415. calculatorSettings.mining.targetLevel = get_level(IdlePixelPlus.getVarOrDefault('mining_xp', 0, 'int'))+1;
  416. document.querySelector('#mining-target-level').value = calculatorSettings.mining.targetLevel;
  417. calculatorSettings.brewing.targetLevel = get_level(IdlePixelPlus.getVarOrDefault('brewing_xp', 0, 'int'))+1;
  418. document.querySelector('#brewing-target-level').value = calculatorSettings.brewing.targetLevel;
  419. calculatorSettings.farming.targetLevel = get_level(IdlePixelPlus.getVarOrDefault('farming_xp', 0, 'int'))+1;
  420. document.querySelector('#farming-target-level').value = calculatorSettings.farming.targetLevel;
  421.  
  422. if (IdlePixelPlus.getVarOrDefault('diamond_hammer', 0, 'int')) calculatorSettings.crafting.tool = 'diamond'
  423. else if (IdlePixelPlus.getVarOrDefault('ruby_hammer', 0, 'int')) calculatorSettings.crafting.tool = 'ruby'
  424. else if (IdlePixelPlus.getVarOrDefault('emerald_hammer', 0, 'int')) calculatorSettings.crafting.tool = 'emerald'
  425. else if (IdlePixelPlus.getVarOrDefault('sapphire_hammer', 0, 'int')) calculatorSettings.crafting.tool = 'sapphire'
  426. else calculatorSettings.crafting.tool = 'none'
  427.  
  428. if (IdlePixelPlus.getVarOrDefault('diamond_pickaxe', 0, 'int')) calculatorSettings.mining.tool = 'diamond'
  429. else if (IdlePixelPlus.getVarOrDefault('ruby_pickaxe', 0, 'int')) calculatorSettings.mining.tool = 'ruby'
  430. else if (IdlePixelPlus.getVarOrDefault('emerald_pickaxe', 0, 'int')) calculatorSettings.mining.tool = 'emerald'
  431. else if (IdlePixelPlus.getVarOrDefault('sapphire_pickaxe', 0, 'int')) calculatorSettings.mining.tool = 'sapphire'
  432. else calculatorSettings.mining.tool = 'none'
  433.  
  434. if (IdlePixelPlus.getVarOrDefault('blue_hammer_orb_absorbed', 0, 'int')) calculatorSettings.crafting.orb = true;
  435. if (IdlePixelPlus.getVarOrDefault('blue_pickaxe_orb_absorbed', 0, 'int')) calculatorSettings.mining.orb = true;
  436. let donorTimestamp = IdlePixelPlus.getVarOrDefault('donor_bonus_xp_timestamp', 0, 'int');
  437. let hasDonorXpPerk = DonorShop.has_donor_active(donorTimestamp);
  438. calculatorSettings.shared.donor = hasDonorXpPerk;
  439.  
  440. Array.from(document.querySelector('#crafting-calculator-form').children).find(elem=>elem.id == calculatorSettings.crafting.tool).checked = true;
  441. Array.from(document.querySelector('#mining-calculator-form').children).find(elem=>elem.id == calculatorSettings.mining.tool).checked = true;
  442. document.querySelector('#mining-donor-perk-check').checked = calculatorSettings.shared.donor;
  443. document.querySelector('#crafting-donor-perk-check').checked = calculatorSettings.shared.donor;
  444. document.querySelector('#brewing-donor-perk-check').checked = calculatorSettings.shared.donor;
  445. document.querySelector('#farming-donor-perk-check').checked = calculatorSettings.shared.donor;
  446.  
  447. if(IdlePixelPlus.getVarOrDefault('ach_medium_oil_capacity_1600', 0, 'int') &&
  448. IdlePixelPlus.getVarOrDefault('ach_medium_smelt_promethium_bar', 0, 'int') &&
  449. IdlePixelPlus.getVarOrDefault('ach_medium_convert_500_gold_bars', 0, 'int') &&
  450. IdlePixelPlus.getVarOrDefault('ach_medium_use_charcoal_foundry', 0, 'int') &&
  451. IdlePixelPlus.getVarOrDefault('ach_medium_craft_10_iron_buckets', 0, 'int') &&
  452. IdlePixelPlus.getVarOrDefault('ach_medium_crush_50_bones_into_ashes', 0, 'int')) calculatorSettings.crafting.perk = true;
  453. document.querySelector('#crafting-medium-achievement-check').checked = calculatorSettings.crafting.perk;
  454.  
  455. this.checkForSkillingOutfits();
  456. document.querySelector('#mining-outfit-check').checked = calculatorSettings.mining.fullOutfit;
  457. document.querySelector('#crafting-outfit-check').checked = calculatorSettings.crafting.fullOutfit;
  458. //document.querySelector('#farming-outfit-check').checked = calculatorSettings.farming.fullOutfit;
  459.  
  460.  
  461. this.calculateCraftingXP();
  462. this.calculateMiningXP();
  463. this.calculateBrewingXP();
  464. this.calculateFarmingXP();
  465. this.handleVisibility('mining');
  466. this.handleVisibility('crafting');
  467. this.handleVisibility('brewing');
  468. this.handleVisibility('farming');
  469. loaded = true;
  470. }
  471.  
  472. calculatorSettingsChanged(skill, type, value){
  473. if (skill == 'crafting'){
  474. calculatorSettings.crafting[type] = value;
  475. this.calculateCraftingXP();
  476. }
  477. if (skill == 'mining'){
  478. calculatorSettings.mining[type] = value;
  479. this.calculateMiningXP();
  480. }
  481. if (skill == 'brewing'){
  482. calculatorSettings.brewing[type] = value;
  483. this.calculateBrewingXP();
  484. }
  485. if (skill == 'farming'){
  486. calculatorSettings.farming[type] = value;
  487. this.calculateFarmingXP();
  488. }
  489. if (skill = 'shared'){
  490. calculatorSettings.shared[type] = value;
  491. this.calculateCraftingXP();
  492. this.calculateMiningXP();
  493. this.calculateBrewingXP();
  494. this.calculateFarmingXP();
  495. }
  496.  
  497. }
  498.  
  499. calculateCraftingXP(){
  500. let currentXp = IdlePixelPlus.getVarOrDefault('crafting_xp', 0, 'int');
  501. let requiredXp = get_xp_required(calculatorSettings.crafting.targetLevel);
  502. let hasDonorPerk = calculatorSettings.shared.donor ? 1.1 : 1;
  503. //let bonusXp = parseFloat((hasDonorPerk + calculatorSettings.crafting.outfit.bonus / 100).toFixed(2));
  504. let bonusXp = hasDonorPerk;
  505. let deltaXp = requiredXp + 1 - currentXp
  506. let toolGem = this.getSdByGem(calculatorSettings.crafting.tool)
  507. let hasAchPerk = calculatorSettings.crafting.perk ? 1 : 0;
  508. let hasBlueorb = calculatorSettings.crafting.orb ? 2 : 0;
  509. let hasFullOutfit = calculatorSettings.crafting.fullOutfit ? 1 : 0;
  510. let requiredSd = deltaXp * (toolGem - hasAchPerk - hasBlueorb - hasFullOutfit);
  511.  
  512. document.querySelector('#crafting-xp-required').textContent = window.format_number(deltaXp);
  513. document.querySelector('#crafting-sd-required').textContent = window.format_number(requiredSd);
  514. let bars = Object.keys(BARS_XP_MAP);
  515. bars.forEach(bar=>{
  516. document.querySelector(`#crafting-calculator-${bar}`).textContent = window.format_number(Math.ceil(deltaXp / ((BARS_XP_MAP[bar] * bonusXp ))));
  517. })
  518. }
  519.  
  520. calculateMiningXP(){
  521. let currentXp = IdlePixelPlus.getVarOrDefault('mining_xp', 0, 'int');
  522. let requiredXp = get_xp_required(calculatorSettings.mining.targetLevel);
  523. let hasDonorPerk = calculatorSettings.shared.donor ? 1.1 : 1;
  524. //let bonusXp = parseFloat((hasDonorPerk + calculatorSettings.mining.outfit.bonus / 100).toFixed(2));
  525. let bonusXp = hasDonorPerk;
  526. let deltaXp = requiredXp + 1 - currentXp
  527. let toolGem = this.getSdByGem(calculatorSettings.mining.tool)
  528. let hasBlueOrb = calculatorSettings.mining.orb ? 2 : 0;
  529. let hasFullOutfit = calculatorSettings.mining.fullOutfit ? 1 : 0;
  530. let requiredSd = deltaXp * (toolGem - hasBlueOrb - hasFullOutfit);
  531.  
  532.  
  533. document.querySelector('#mining-xp-required').textContent = window.format_number(deltaXp);
  534. document.querySelector('#mining-sd-required').textContent = window.format_number(requiredSd);
  535. let ores = Object.keys(ORES_XP_MAP);
  536. ores.forEach(ore=>{
  537. document.querySelector(`#mining-calculator-${ore}`).textContent = window.format_number(Math.ceil(deltaXp / ((ORES_XP_MAP[ore] * bonusXp ))));
  538. })
  539. }
  540.  
  541. calculateFarmingXP(){
  542. let currentXp = IdlePixelPlus.getVarOrDefault('farming_xp', 0, 'int');
  543. let requiredXp = get_xp_required(calculatorSettings.farming.targetLevel);
  544. let hasDonorPerk = calculatorSettings.shared.donor ? 1.1 : 1;
  545. let bonusXp = hasDonorPerk + calculatorSettings.farming.outfit.bonus;
  546. let deltaXp = requiredXp + 1 - currentXp
  547. let hasDonorPatches = IdlePixelPlus.getVarOrDefault('donor_farm_patches_timestamp', 0, 'int');
  548. let farm_1_XP = 0;
  549. let farm_2_XP = 0;
  550. let farm_3_XP = 0;
  551. let farm_4_XP = 0;
  552. let farm_5_XP = 0;
  553. let farm_Total_XP = 0;
  554. //farm_1_XP = SEEDS_XP_MAP[IdlePixelPlus.getVarOrDefault('farm_1')];
  555. //farm_2_XP = SEEDS_XP_MAP[IdlePixelPlus.getVarOrDefault('farm_2')];
  556. //farm_3_XP = SEEDS_XP_MAP[IdlePixelPlus.getVarOrDefault('farm_3')];
  557. if(SEEDS_XP_MAP[IdlePixelPlus.getVarOrDefault('farm_1')]) {
  558. farm_1_XP = SEEDS_XP_MAP[IdlePixelPlus.getVarOrDefault('farm_1')];
  559. }
  560. else {
  561. farm_1_XP = 0;
  562. }
  563. if(SEEDS_XP_MAP[IdlePixelPlus.getVarOrDefault('farm_2')]) {
  564. farm_2_XP = SEEDS_XP_MAP[IdlePixelPlus.getVarOrDefault('farm_2')];
  565. }
  566. else {
  567. farm_2_XP = 0;
  568. }
  569. if(SEEDS_XP_MAP[IdlePixelPlus.getVarOrDefault('farm_3')]) {
  570. farm_3_XP = SEEDS_XP_MAP[IdlePixelPlus.getVarOrDefault('farm_3')];
  571. }
  572. else {
  573. farm_3_XP = 0;
  574. }
  575. if(hasDonorPatches > 0) {
  576. if(SEEDS_XP_MAP[IdlePixelPlus.getVarOrDefault('farm_4')]) {
  577. farm_4_XP = SEEDS_XP_MAP[IdlePixelPlus.getVarOrDefault('farm_4')];
  578. }
  579. else {
  580. farm_4_XP = 0;
  581. }
  582. if(SEEDS_XP_MAP[IdlePixelPlus.getVarOrDefault('farm_5')]) {
  583. farm_5_XP = SEEDS_XP_MAP[IdlePixelPlus.getVarOrDefault('farm_5')];
  584. }
  585. else {
  586. farm_5_XP = 0;
  587. }
  588. };
  589. farm_Total_XP = (farm_1_XP + farm_2_XP + farm_3_XP + farm_4_XP + farm_5_XP) * bonusXp;
  590. if(deltaXp < 0) {
  591. deltaXp = 0
  592. }
  593. let bonemeal = IdlePixelPlus.getVarOrDefault('bonemeal', 0, 'int');
  594. document.querySelector('#farming-xp-required').textContent = window.format_number(deltaXp);
  595. let seeds = Object.keys(SEEDS_XP_MAP);
  596. let bones = Object.keys(BONEMEAL_SEED_MAP);
  597. seeds.forEach(seeds=>{
  598. let bonemealReq = (Math.ceil((deltaXp - farm_Total_XP) / ((SEEDS_XP_MAP[seeds] * bonusXp))) * BONEMEAL_SEED_MAP[seeds]) - bonemeal;
  599. if(bonemealReq < 0) {
  600. bonemealReq = 0;
  601. }
  602. document.querySelector(`#farming-calculator-${seeds}`).textContent = window.format_number(Math.ceil((deltaXp - farm_Total_XP) / ((SEEDS_XP_MAP[seeds] * bonusXp)))) + ` (${bonemealReq})`;
  603. })
  604. }
  605.  
  606. calculateBrewingXP(){
  607.  
  608. let currentXp = IdlePixelPlus.getVarOrDefault('brewing_xp', 0, 'int');
  609. let requiredXp = get_xp_required(calculatorSettings.brewing.targetLevel);
  610. let hasDonorPerk = calculatorSettings.shared.donor ? 1.1 : 1;
  611. let bonusXp = hasDonorPerk + calculatorSettings.brewing.outfit.bonus;
  612. let deltaXp = requiredXp + 1 - currentXp
  613. document.querySelector('#brewing-xp-required').textContent = window.format_number(deltaXp);
  614. let potions = Object.keys(POTION_XP_MAP);
  615. potionArray.forEach(potion=>{
  616. if(potion != "infinite_oil_potion") {
  617. let ingredients = Brewing.get_ingredients(potion);
  618. let xpPerPotion = 0;
  619. let maxCraftable = Number.MAX_SAFE_INTEGER;
  620. for (let i=0;i<ingredients.length;i+=2){
  621. xpPerPotion += Math.floor((INGREDIENT_XP_MAP[ingredients[i]] * bonusXp) * parseInt(ingredients[i+1]));
  622. let craftable = Math.floor(IdlePixelPlus.getVarOrDefault(ingredients[i], 0, 'int') / parseInt(ingredients[i+1]));
  623. craftable < maxCraftable ? maxCraftable = craftable : null;
  624. }
  625. document.querySelector(`#brewing-calculator-${potion}`).textContent = window.format_number(Math.ceil(deltaXp / xpPerPotion)) + ` (${maxCraftable})`;
  626. }
  627. })
  628. }
  629.  
  630. getSdByGem(gem){
  631. let sd = {none: 13, sapphire: 12, emerald: 11, ruby: 10, diamond: 9}
  632. return sd[gem]
  633. }
  634.  
  635. handleVisibility(key){
  636. calculatorSettings[key].hide = !calculatorSettings[key].hide;
  637. if (calculatorSettings[key].hide) document.querySelector(`#${key}-calculator-div`).style.display = 'none'
  638. else document.querySelector(`#${key}-calculator-div`).style.display = 'block'
  639. calculatorSettings[key].hide ? document.querySelector(`#${key}-visibility-button`).textContent = 'Show' : document.querySelector(`#${key}-visibility-button`).textContent = 'Hide';
  640. }
  641.  
  642. onVariableSet(key, valueBefore, valueAfter) {
  643. if (!loaded) return;
  644. switch (key){
  645. case 'crafting_xp':
  646. calculatorSettings.crafting.targetLevel = get_level(IdlePixelPlus.getVarOrDefault('crafting_xp', 0, 'int'))+1;
  647. document.querySelector('#crafting-target-level').value = calculatorSettings.crafting.targetLevel;
  648. this.calculateCraftingXP();
  649. break;
  650. case 'mining_xp':
  651. calculatorSettings.mining.targetLevel = get_level(IdlePixelPlus.getVarOrDefault('mining_xp', 0, 'int'))+1;
  652. document.querySelector('#mining-target-level').value = calculatorSettings.mining.targetLevel;
  653. this.calculateMiningXP();
  654. break;
  655. case 'brewing_xp':
  656. calculatorSettings.brewing.targetLevel = get_level(IdlePixelPlus.getVarOrDefault('brewing_xp', 0, 'int'))+1;
  657. document.querySelector('#brewing-target-level').value = calculatorSettings.brewing.targetLevel;
  658. this.calculateBrewingXP();
  659. break;
  660. case 'farming_xp':
  661. calculatorSettings.farming.targetLevel = get_level(IdlePixelPlus.getVarOrDefault('farming_xp', 0, 'int'))+1;
  662. document.querySelector('#farming-target-level').value = calculatorSettings.farming.targetLevel;
  663. this.calculateFarmingXP();
  664. break;
  665. default:
  666. break;
  667. }
  668. if (key.includes('skilling')) this.checkForSkillingOutfits();
  669. }
  670.  
  671. checkForSkillingOutfits(){
  672. ['gloves', 'boots', 'pants', 'shirt'].forEach(item=>{
  673. ['crafting', 'mining', 'brewing', 'farming'].forEach(skill=>{
  674. let hasItem = IdlePixelPlus.getVarOrDefault(`${skill}_skilling_${item}`, 0, 'int')
  675. if (hasItem && !calculatorSettings[skill].outfit[item]){
  676. calculatorSettings[skill].outfit[item] = true;
  677. calculatorSettings[skill].outfit.bonus += 0.01;
  678. if (calculatorSettings[skill].outfit.gloves &&
  679. calculatorSettings[skill].outfit.shirt &&
  680. calculatorSettings[skill].outfit.pants &&
  681. calculatorSettings[skill].outfit.boots){
  682. calculatorSettings[skill].fullOutfit = true;
  683. calculatorSettings[skill].outfit.bonus = 0.05;
  684. }
  685. this.updateOutfitBonus();
  686. }
  687. })
  688. })
  689. }
  690.  
  691. updateOutfitBonus(){
  692. //document.querySelector('#brewing-outfit-bonus').textContent = calculatorSettings.brewing.fullOutfit ? '5%' : calculatorSettings.brewing.outfit.bonus + '%';
  693. document.querySelector('#brewing-outfit-bonus').textContent = `${calculatorSettings.brewing.outfit.bonus * 100}%`
  694. document.querySelector('#farming-outfit-bonus').textContent = `${calculatorSettings.farming.outfit.bonus * 100}%`
  695. this.calculateCraftingXP();
  696. this.calculateMiningXP();
  697. this.calculateBrewingXP();
  698. this.calculateFarmingXP();
  699. }
  700. }
  701.  
  702. const plugin = new XpCalculatorPlugin();
  703. IdlePixelPlus.registerPlugin(plugin); // register the plugin
  704.  
  705. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址