Greasy Fork is available in English.

Jz Warlight

Warzone/Warlight script that allows note-taking in games. It also includes statistics-like features for Warzone Idle.

  1. // ==UserScript==
  2. // @name Jz Warlight
  3. // @namespace https://greasyfork.org/en/users/44200-jz
  4. // @version 1.4.4
  5. // @grant none
  6. // @match https://www.warlight.net/*
  7. // @match https://www.warzone.com/*
  8. // @description Warzone/Warlight script that allows note-taking in games. It also includes statistics-like features for Warzone Idle.
  9. // @license GNU General Public License v3.0
  10. // ==/UserScript==
  11.  
  12. var idlePermanent = {};
  13. var idleObject = {}
  14. var artifacts_list = [];
  15. var scannedSpan;
  16. var idleSelected = null;
  17. var idleObjectArchive = null;
  18. var artifact_rarity = "Owned";
  19. var loadedLevel = false;
  20.  
  21. // Change the below to true to show some potentially
  22. // confusing and less user-friendly features
  23. var showDevelopmentFeatures = false;
  24. var drafts = [];
  25. main();
  26.  
  27. function main() {
  28. try{
  29. setupSettings();
  30.  
  31. //var filter_setting = localStorage.getItem('setting_extra_filters');
  32. //if(pageIsDashboard()) {
  33. // if(filter_setting == 'true') {
  34. // //$("#MyGamesFilter").append('<option value="0">Games that are active</option>');
  35. // $("#MyGamesFilter").append('<option value="7">Games that are active or have unread chat messages</option>');
  36. // $("#MyGamesFilter").append('<option value="3">Weird Filter (Non-Archived Games)</option>');
  37. // }
  38. //}
  39. if(pageIsTournaments()) {
  40. var muli_setting = localStorage.getItem('setting_enhance_muli');
  41. if(muli_setting == 'true') {
  42. // Add filters for tournaments, to expand the functionality Muli provided
  43. var filter = $('<select id="tournamentFilter" title="After updating the tournament data using Muli\'s script, pick a filter." style="float: right;margin: 0 10px;"/>');
  44. filter.append($('<option value="showAll">Show all</option>'));
  45. filter.append($('<option value="showGamesLeft">Tournaments with games left</option>'));
  46. filter.append($('<option value="showInProgress">Tournaments with games in progress</option>'));
  47. filter.append($('<option value="showNotEliminated">Tournaments that I am not eliminated from</option>'));
  48. filter.append($('<option value="showAlmostDone">Tournaments that are almost done</option>'));
  49. filter.append($('<option value="showCoin">Coin Tournaments</option>'));
  50. filter.on("change", function () {
  51. var selected = $( this ).val();
  52.  
  53. var tds = $("td .tournamentData");
  54. for(var i = 0; i < tds.length; i++) {
  55. var td = tds[i];
  56. var parentTr = $(td).parent('tr');
  57. if(selected == "showAll") {
  58. parentTr.show();
  59. } else if(selected == "showGamesLeft") {
  60. if(td.innerHTML.indexOf('<font color="#858585">Games left:</font> None <br>') > 0) {
  61. parentTr.hide();
  62. } else {
  63. parentTr.show();
  64. }
  65. } else if(selected == "showInProgress") {
  66. if(td.innerHTML.indexOf('<font color="#858585">Playing:</font> 0 <br>') > 0) {
  67. parentTr.hide();
  68. } else if(td.innerHTML.indexOf('<font color="#858585">Playing:</font>') > 0) {
  69. parentTr.show();
  70. } else {
  71. parentTr.hide();
  72. }
  73. } else if(selected == "showNotEliminated") {
  74. // Show round robins, tournaments with games in progress, and tournaments with games left
  75. if(parentTr.html().indexOf('Round robin tournament') >= 0) {
  76. parentTr.show();
  77. } else if(td.innerHTML.indexOf('<font color="#858585">Playing:</font>') > 0
  78. && td.innerHTML.indexOf('<font color="#858585">Playing:</font> 0 <br>') == -1) {
  79. parentTr.show();
  80. } else if(td.innerHTML.indexOf('<font color="#858585">Games left:</font> None <br>') == -1) {
  81. parentTr.show();
  82. } else {
  83. parentTr.hide();
  84. }
  85. } else if(selected == "showAlmostDone") {
  86. if(td.innerHTML.indexOf('Almost done') > 0) {
  87. parentTr.show();
  88. } else {
  89. parentTr.hide();
  90. }
  91. } else if(selected == "showCoin") {
  92. if(parentTr.html().indexOf('SmallCoins.png') != -1) {
  93. parentTr.show();
  94. } else {
  95. parentTr.hide();
  96. }
  97. }
  98. }
  99. });
  100. $("#MyTournamentsTable h2").after(filter);
  101. }
  102. }
  103. if(pageIsPastTournaments()) {
  104. if(filter_setting == 'true') {
  105. //$("#Filter").append('<option value="4">Actionable</option>');
  106. $("#Filter").append('<option value="5">Tournaments with unread chat</option>');
  107. //$("#Filter").append('<option value="6">Actionable or unread chat</option>');
  108. //$("#Filter").append('<option value="8">Not Complete that I joined</option>');
  109. }
  110. }
  111. if(pageIsGame()) {
  112. var note_setting = localStorage.getItem('setting_enable_notes');
  113. if(note_setting == 'true') {
  114. setupNotes();
  115. }
  116. }
  117. // Reimplement Alt tagging
  118. /*// Tag alts (alts retrieved from the library)
  119. for(var main_count = 0; main_count < mains.length; main_count++) {
  120. var main = mains[main_count];
  121. for(var alt_count = 0; alt_count < main.alts.length; alt_count++) {
  122. var alt = main.alts[alt_count];
  123. if(poster_id == alt) {
  124. var username = poster_cell.html();
  125. poster_cell.html(username + " (" + main.name + ")");
  126. }
  127. }
  128. }*/
  129.  
  130. if(pageIsClanWars()) {
  131. setupClanWarsFeatures();
  132. }
  133.  
  134. if(pageIsIdle()) {
  135. var idle_setting = localStorage.getItem('setting_idle_features');
  136. if(idle_setting == 'true') {
  137. setupIdleFeatures();
  138. }
  139. }
  140. } catch(err) {
  141. console.log(err);
  142. }
  143. }
  144.  
  145. function setupSettings() {
  146. $("#AccountDropDown").parent().find("div .dropdown-divider").before('<div class="dropdown-item" id="jz-userscript-menu" style="cursor:pointer" data-toggle="modal" data-target="#settingsdialog">Jz\'s Userscript</div>');
  147.  
  148. var modalhtml = ''
  149. modalhtml += '<div class="modal" tabindex="-1" role="dialog" id="settingsdialog">'
  150. modalhtml += ' <div class="modal-dialog" role="document" style="max-height:95%;overflow-y:auto;">'
  151. modalhtml += ' <div class="modal-content">'
  152. modalhtml += ' <div class="modal-header" style="color:#b3b081;background-color:#330000;height:40px">'
  153. modalhtml += ' <h5 class="modal-title">Settings (Automatically Saved)</h5>'
  154. modalhtml += ' <button type="button" class="close" data-dismiss="modal" aria-label="Close">'
  155. modalhtml += ' <span aria-hidden="true" style="color:#b3b081">&times;</span>'
  156. modalhtml += ' </button>'
  157. modalhtml += ' </div>'
  158. modalhtml += ' <div class="modal-body" id="settingsbody" style="color:#b3b081;background-color:#171717">'
  159. modalhtml += ' </div>'
  160. modalhtml += ' <div class="modal-body" id="idlebody" style="color:#b3b081;background-color:#171717">'
  161. modalhtml += ' </div>'
  162. modalhtml += ' </div>'
  163. modalhtml += ' </div>'
  164. modalhtml += '</div>'
  165. var settings_modal=$(modalhtml)
  166. $('body').append(settings_modal)
  167.  
  168. var settings_body = $("#settingsbody")
  169. addSetting(settings_body, "Enable Note Taking", "setting_enable_notes", "true", "Allow note taking in games");
  170. //addSetting(settings_body, "Add extra filters", "setting_extra_filters", "true", "Add extra filters to the dashboard and past tournaments pages");
  171. addSetting(settings_body, "Add features to enhance Muli's userscript", "setting_enhance_muli", "true", "If muli's script is installed, add features to enhance it.");
  172. addSetting(settings_body, "Enable Idle Features \(In Development\)", "setting_idle_features", "true", "Enable idle screen scanning and calculations. These features provide approximations only.");
  173. //addSetting(settings_body, "Enable Special Features (fun feature)", "setting_extra_features", "false", "Enable future april fools features");
  174. //addSetting(settings_body, "Allow Audio Features (fun feature)", "setting_audio_features", "false", "Enable potential april fools features that use audio");
  175. refreshIdleLevels();
  176. }
  177.  
  178. function addSetting(settings_dialog, label, id, default_val, title) {
  179.  
  180. var setting_header = $('<label for="setting_' + id + '" title="' + title + '">' + label + '</label>');
  181. var setting = $('<input type="checkbox" id="setting_' + id + '"/>');
  182. settings_dialog.append(setting);
  183. settings_dialog.append(setting_header);
  184. settings_dialog.append($('<br/>'));
  185. var stored_value = localStorage.getItem(id);
  186. if(stored_value == null) {
  187. stored_value = default_val;
  188. localStorage.setItem(id, default_val);
  189. }
  190. if(stored_value == 'true') {
  191. setting.prop('checked', true);
  192. }
  193. setting.on('change', function() {
  194. if(setting.prop('checked')) {
  195. localStorage.setItem(id, 'true');
  196. } else {
  197. localStorage.setItem(id, 'false');
  198. }
  199. });
  200. }
  201.  
  202. function refreshIdleLevels() {
  203. var idle_body = $("#idlebody");
  204. idle_body.empty();
  205. idle_body.append($('<div style="font-weight:bold">Archived Idle Levels:</div>'));
  206. idleObjectArchive = getIdleObjectArchiveFromStorage();
  207. if(idleObjectArchive.length == 0) {
  208. idle_body.append($('<div>None</div>'))
  209. }
  210. for(var i = 0; i < idleObjectArchive.length; i++) {
  211. var idleObj = idleObjectArchive[i];
  212. var idle_level_div = $('<div></div>');
  213. var idleobj_display = $('<div><span id="json_title"></span><br/><textarea id="IdleJSONOutput" rows="10" cols="50"/></div>');
  214. idleobj_display.hide()
  215. idle_level_div.append(idleobj_display);
  216.  
  217. var view_button = $('<button type="button" class="btn btn-primary" id="View' + i + '" aria-label="View ' + idleObj.level + '">JSON</button>');
  218. view_button.attr('title','View JSON for "' + idleObj.level + '"');
  219. view_button.on('click', function() {
  220. var level = this.title.substring(this.title.indexOf("\"") + 1);
  221. level = level.substring(0, level.indexOf("\""));
  222. viewIdleObjectFromArchive(level);
  223. });
  224. idle_level_div.append(view_button);
  225. idle_level_div.append($('<span>&nbsp;</span>'));
  226.  
  227. // Load the stats into the window if we're on the idle page
  228. if(pageIsIdle()) {
  229. var load_button = $('<button type="button" class="btn btn-primary" id="Load' + i + '" aria-label="Load ' + idleObj.level + ' into the stats window.">Load</button>');
  230. load_button.attr('title','Load "' + idleObj.level + '" into the stats window.');
  231. load_button.on('click', function() {
  232. archiveIdleObject(idleObject);
  233. var level = this.title.substring(this.title.indexOf("\"") + 1);
  234. level = level.substring(0, level.indexOf("\""));
  235. idleObject = getArchivedIdleObject(level);
  236. outputResults(idleObject);
  237. loadedLevel = true;
  238. scannedSpan.text("Scanning Paused. Stats for " + level + '. Press Scan to resume scanning current level.');
  239. });
  240. idle_level_div.append(load_button);
  241. idle_level_div.append($('<span>&nbsp;</span>'));
  242. }
  243.  
  244. var remove_button = $('<button type="button" class="btn btn-primary" id="Remove' + i + '" aria-label="Remove">Remove</button>');
  245. remove_button.attr('title',idleObj.level);
  246. remove_button.on('click', function() {
  247. removeIdleObjectFromArchive(this.title);
  248. });
  249. idle_level_div.append(remove_button);
  250. idle_level_div.append($('<span>&nbsp;' + idleObj.level + '</span>'))
  251. idle_body.append(idle_level_div);
  252. }
  253. }
  254.  
  255. function insertCss( code ) {
  256. var style = document.createElement('style');
  257. style.type = 'text/css'
  258.  
  259. if (style.styleSheet) {
  260. // IE
  261. style.styleSheet.cssText = code;
  262. } else {
  263. // Other browsers
  264. style.innerHTML = code;
  265. }
  266.  
  267. document.getElementsByTagName("head")[0].appendChild( style );
  268. }
  269.  
  270. // **************** Notes ****************
  271.  
  272. function setupNotes() {
  273. // Create the minimized notes
  274. var modalhtml = ''
  275. modalhtml += '<div class="panel" tabindex="-1" id="notesdialogmini">'
  276. modalhtml += ' <div class="modal-dialog" role="document" style="border: 2px solid;border-radius: 5px;max-width:100px;position:fixed;bottom:0px;right:0px;margin:0px;padding:0px">'
  277. modalhtml += ' <div class="modal-content" style="color:#b3b081">'
  278. modalhtml += ' <div class="modal-header" id="notesheadermini" style="border:0px;color:#b3b081;background-color:#330000;padding:5px;height:15px">'
  279. modalhtml += ' <span aria-hidden="true" id="notesopen" style="cursor:pointer;font-size:x-small">Notes</span>'
  280. modalhtml += ' </div>'
  281. modalhtml += ' </div>'
  282. modalhtml += ' </div>'
  283. modalhtml += '</div>'
  284. var notes_modal2=$(modalhtml)
  285. $('body').append(notes_modal2)
  286.  
  287. // Create the popup for the notes
  288. modalhtml = ''
  289. modalhtml += '<div class="panel" tabindex="-1" id="notesdialog">'
  290. modalhtml += ' <div class="modal-dialog" role="document" style="max-width:340px;position:fixed;bottom:0px;right:0px;margin:0px">'
  291. modalhtml += ' <div class="modal-content">'
  292. modalhtml += ' <div class="modal-header" id="notesheader" style="color:#b3b081;background-color:#330000;height:35px">'
  293. modalhtml += ' <h5 class="modal-title">Notes</h5>'
  294. modalhtml += ' <button type="button" class="close" id="notesminimize" aria-label="Minimize">'
  295. modalhtml += ' <span aria-hidden="true" style="color:#b3b081">-</span>'
  296. modalhtml += ' </button>'
  297. modalhtml += ' </div>'
  298. modalhtml += ' <div class="modal-body" id="notesbody" style="color:#b3b081;background-color:#171717">'
  299. modalhtml += ' <textarea id="GameNotes" rows="4" cols="30"/>'
  300. modalhtml += ' </div>'
  301. modalhtml += ' </div>'
  302. modalhtml += ' </div>'
  303. modalhtml += '</div>'
  304. var notes_modal=$(modalhtml)
  305. notes_modal.hide();
  306. $('body').append(notes_modal)
  307.  
  308. // Add the notes header to the Multi-Player Menu
  309. var notesHeader = $('<div class="dropdown-item" id="NotesHeader" style="cursor:pointer">Notes</div>');
  310. $("#CreateGameLink").after(notesHeader);
  311.  
  312. // Setup note display events
  313. notesHeader.on('click', function() {
  314. notes_modal.show();
  315. notes_modal2.hide();
  316. });
  317.  
  318. var notes_minimize=$("#notesminimize")
  319. notes_minimize.on('click', function() {
  320. notes_modal.hide();
  321. notes_modal2.show();
  322. });
  323.  
  324. var notes_open=$("#notesopen")
  325. notes_open.on('click', function() {
  326. notes_modal.show();
  327. notes_modal2.hide();
  328. });
  329.  
  330. // Parse the gameid
  331. var gameid = getGameID();
  332.  
  333. // Create the events
  334. // Save the note automatically
  335. var gameNotes = $("#GameNotes")
  336. gameNotes.on('change', function() {
  337. saveNote(gameNotes, gameid);
  338. });
  339.  
  340. // Populate the notes field and set the background color for the notes
  341. var notes = getNotesFromStorage();
  342. var note = notes[gameid];
  343. if(note != null && note.value != null && note.value.length > 0) {
  344. gameNotes.val(note.value);
  345. notes_modal.show();
  346.  
  347. // Resaving it updates the timestamp
  348. saveNote(gameNotes, gameid);
  349. }
  350. colorNotesHeader(gameNotes);
  351. }
  352.  
  353. function getGameID() {
  354. var gameid = location.href.substring(location.href.indexOf('GameID=') + 7)
  355. if(gameid.indexOf('&') > 0) {
  356. gameid = gameid.substring(0, gameid.indexOf('&'));
  357. }
  358. return gameid;
  359. }
  360.  
  361. function getNotesFromStorage() {
  362. var notesString = localStorage.getItem("notes");
  363. if(notesString != null) {
  364. return JSON.parse(notesString);
  365. } else {
  366. return {};
  367. }
  368. }
  369.  
  370. function saveNotesToStorage(notes) {
  371. localStorage.setItem("notes", JSON.stringify(notes));
  372. }
  373.  
  374. function saveNote(gameNotes, gameid) {
  375. var notes = getNotesFromStorage();
  376. var note = notes[gameid];
  377. if(note == null) {
  378. note = {};
  379. }
  380. note.date = new Date();
  381. note.value = gameNotes.val();
  382. notes[gameid] = note;
  383. if(note.value == null || note.value.length == 0) {
  384. delete notes[gameid];
  385. }
  386. saveNotesToStorage(notes);
  387. colorNotesHeader(gameNotes);
  388. }
  389.  
  390. function colorNotesHeader(gameNotes) {
  391. var notesHeader = $("#NotesHeader")
  392. var miniNotesHeader = $("#notesheadermini")
  393. miniNotesHeader.css('font-style','normal');
  394. var color = "";
  395. if(gameNotes.val() != null && gameNotes.val().length > 0) {
  396. color = '#FFAA00';
  397. miniNotesHeader.css('font-style','italic');
  398. }
  399. notesHeader.css('color',color);
  400. }
  401.  
  402. // **************** Clan Wars Features ****************
  403. function setupClanWarsFeatures() {
  404. var modalhtml = ''
  405. modalhtml = ''
  406. modalhtml += '<div class="panel" tabindex="-1" id="cwdialog">'
  407. modalhtml += ' <div class="modal-dialog" role="document" style="max-width:600px;position:fixed;bottom:0px;right:0px;margin:0px">'
  408. modalhtml += ' <div class="modal-content">'
  409. modalhtml += ' <div class="modal-header" id="cwheader" style="color:#b3b081;background-color:#330000;height:35px">'
  410. modalhtml += ' <h5 class="modal-title">Clan War Games (Copy/Paste to Spreadsheet)</h5>'
  411. modalhtml += ' <button type="button" class="close" id="cwclose" aria-label="Minimize">'
  412. modalhtml += ' <span aria-hidden="true" style="color:#b3b081">x</span>'
  413. modalhtml += ' </button>'
  414. modalhtml += ' </div>'
  415. modalhtml += ' <div class="modal-body" id="cwbody" style="color:#b3b081;background-color:#171717">'
  416. modalhtml += ' <textarea id="cw_output" rows="10" cols="100"/>'
  417. modalhtml += ' </div>'
  418. modalhtml += ' </div>'
  419. modalhtml += ' </div>'
  420. modalhtml += '</div>'
  421.  
  422. var cw_modal=$(modalhtml)
  423. cw_modal.hide();
  424. $('body').append(cw_modal)
  425.  
  426.  
  427. var cw_close=$("#cwclose")
  428. cw_close.on('click', function() {
  429. cw_modal.hide();
  430. });
  431.  
  432. $(document).keydown(function(e){
  433. // Letter "s"
  434. if(e.keyCode == 83){
  435. scanClanWarsGames();
  436. }
  437. });
  438. }
  439.  
  440. function scanClanWarsGames() {
  441. var games = [];
  442. $('*[id*=ujs_row]').each(function() {
  443. var element = $(this);
  444. var id = element.attr("id");
  445. var outcome = "?";
  446. var link = null;
  447. element.find("a").each(function() {
  448. var tmp_link = $(this).attr("href");
  449. if(tmp_link.indexOf("GameID") != -1) {
  450. link = tmp_link;
  451. }
  452. });
  453. var test = null;
  454. var template = null;
  455. var territory = null;
  456. var players = null;
  457. if(element.html().indexOf("UIButton-198225.png") > 0) {
  458. outcome = "w";
  459. } else if(element.html().indexOf("UIButton-9A2929.png") > 0) {
  460. outcome = "l";
  461. }
  462.  
  463. var index = 0;
  464. element.find(".ujsText").each(function() {
  465. if(index == 0) {
  466. test = this.textContent;
  467. }
  468. if(index == 1) {
  469. template = this.textContent
  470. }
  471. if(index == 2) {
  472. territory = this.textContent
  473. }
  474. if(index == 3) {
  475. players = this.textContent.replace("Game with ","").replace("Free win by ","")
  476. }
  477. index++;
  478. });
  479. if(index == 4 && test == "V") {
  480. var game = {
  481. "id":id,
  482. "link":link,
  483. "outcome":outcome,
  484. "template":template,
  485. "territory":territory,
  486. "players":players
  487. }
  488. games.push(game)
  489. }
  490. });
  491. if(games.length > 0) {
  492. var output = ''
  493. for(var i = games.length - 1; i >= 0; i--) {
  494. output += games[i].template + '\t'
  495. output += games[i].territory + '\t'
  496. var players = games[i].players.split(",");
  497. var player1 = players[0];
  498. var player2 = "";
  499. if(players.length == 2) {
  500. player2 = players[1];
  501. }
  502. output += player1 + '\t'
  503. output += player2 + '\t'
  504. output += games[i].outcome
  505. output += '\n'
  506. }
  507. $("#cw_output").val(output);
  508. $("#cwdialog").show();
  509. }
  510.  
  511. }
  512.  
  513. // **************** Idle Features ****************
  514.  
  515. function setupIdleFeatures() {
  516. insertCss(".artifact_insane { color:#FFFF00; }")
  517. insertCss(".artifact_legendary { color:#FFC200; }")
  518. insertCss(".artifact_epic { color:rgb\(255, 0, 237\); }")
  519. insertCss(".artifact_rare { color:rgb\(108, 115, 209\); }")
  520. insertCss(".artifact_uncommon { color: rgb\(25, 130, 37\); }")
  521. insertCss(".artifact_common { color:rgb\(255, 255, 255\); }")
  522. insertCss(".artifact_poor { color:rgb\(186, 186, 188\); }")
  523.  
  524. insertCss(".jz_table td { padding: 5px}")
  525. var modalhtml = ''
  526.  
  527. // Instructions Modal
  528. modalhtml = ''
  529. modalhtml += '<div class="panel" tabindex="-1" id="instructionsdialog">'
  530. modalhtml += ' <div class="modal-dialog" role="document" style="max-width:40%;position:absolute;top:10%;left:30%;margin:0px">'
  531. modalhtml += ' <div class="modal-content">'
  532. modalhtml += ' <div class="modal-header" id="instructionsheader" style="color:#b3b081;background-color:#330000;height:35px">'
  533. modalhtml += ' <h5 class="modal-title">Instructions (Jz\'s Userscript)</h5>'
  534. modalhtml += ' <button type="button" class="close" id="instructionsminimize" aria-label="Close">'
  535. modalhtml += ' <span aria-hidden="true" style="color:#b3b081">x</span>'
  536. modalhtml += ' </button>'
  537. modalhtml += ' </div>'
  538. modalhtml += ' <div class="modal-body" id="instructionsbody" style="color:#b3b081;background-color:#171717;font-size:80%">'
  539. modalhtml += ' <span>This script is in development. It is recommended that you verify the results.<br/><br/>'
  540. modalhtml += ' This feature allows you to construct additional statistics for recipes, armies, and money.'
  541. modalhtml += ' Certain features may be restricted if the Statistics advancement is not sufficiently upgraded.'
  542. modalhtml += ' The script works by reading the values displayed on the screen. '
  543. modalhtml += ' Because the values displayed are rounded, the resulting calculations are only estimates.'
  544. modalhtml += ' The most recent scan results for each level are saved to local storage. '
  545. modalhtml += ' Go to the userscript settings (under your username) to remove old level scan data if the local storage becomes too full.'
  546. modalhtml += ' <br/><br/>Follow these instructions (in any order) to make data available to the script:'
  547. modalhtml += ' <br/>Step 1: Go to the crafters, click "Change Recipe" to bring up the recipes, then press "s".'
  548. modalhtml += ' <br/>Step 2: (Statistics 1) Open the "Money Stats" pop-up (top right), then press "s".'
  549. modalhtml += ' <br/>Step 3: (Statistics 1) Open the "Army Stats" pop-up (top right), then press "s".'
  550. modalhtml += ' <br/>Step 4: (Statistics 2) On the "Army Camps" tab, open the Modifiers pop-up, then press "s".'
  551. modalhtml += ' <br/>Step 5: On the "Advancements" tab, open the Artifacts pop-up, then press "s".'
  552. modalhtml += ' <br/>Once everything is scanned, you can select the statistics you wish to view.'
  553. modalhtml += ' <br/><br/>It is very important to keep scans up to date in order to ensure correct results.'
  554. modalhtml += ' Repeat the above steps after swapping artifacts, unlocking techs, unlocking recipes, upgrading camps, claiming clan war rewards, or for any other change.'
  555. modalhtml += ' </span>'
  556. modalhtml += ' </div>'
  557. modalhtml += ' </div>'
  558. modalhtml += ' </div>'
  559. modalhtml += '</div>'
  560. var instructions_modal=$(modalhtml)
  561. instructions_modal.hide();
  562. $('body').append(instructions_modal);
  563.  
  564. var instructions_minimize=$("#instructionsminimize")
  565. instructions_minimize.on('click', function() {
  566. instructions_modal.hide();
  567. });
  568.  
  569. // Create the minimized idle button
  570. modalhtml = ''
  571. modalhtml += '<div class="panel" tabindex="-1" id="notesdialogmini">'
  572. modalhtml += ' <div class="modal-dialog" role="document" style="border: 2px solid;border-radius: 5px;max-width:100px;position:fixed;bottom:0px;left:0px;margin:0px;padding:0px">'
  573. modalhtml += ' <div class="modal-content" style="color:#b3b081">'
  574. modalhtml += ' <div class="modal-header" id="idleheadermini" style="border:0px;color:#b3b081;background-color:#330000;padding:5px;height:15px">'
  575. modalhtml += ' <span aria-hidden="false" id="idlemenuopen" style="cursor:pointer;font-size:x-small">Idle Menu</span>'
  576. modalhtml += ' </div>'
  577. modalhtml += ' </div>'
  578. modalhtml += ' </div>'
  579. modalhtml += '</div>'
  580. var idle_modal2=$(modalhtml)
  581. idle_modal2.hide();
  582. $('body').append(idle_modal2)
  583. var max_height = $(window).height() - 290;
  584. // Create the popup for Idle
  585. modalhtml = ''
  586. modalhtml += '<div class="panel" tabindex="-1" id="idledialog">'
  587. modalhtml += ' <div class="modal-dialog" role="document" style="min-width:300px;max-width:25%;position:fixed;bottom:0px;left:0px;margin:0px">'
  588. modalhtml += ' <div class="modal-content">'
  589. modalhtml += ' <div class="modal-header" id="idleheader" style="color:#b3b081;background-color:#330000;height:35px">'
  590. modalhtml += ' <h5 class="modal-title">Beta! Idle Stats (Jz\'s Userscript)</h5>'
  591. modalhtml += ' <button type="button" class="btn-link" title="Instructions" id="idleinstructionbutton" aria-label="Instructions">'
  592. modalhtml += ' <span aria-hidden="true" style="color:#b3b081">?</span>'
  593. modalhtml += ' </button>'
  594. modalhtml += ' <button type="button" class="close" title="Minimize" id="idleminimize" aria-label="Minimize">'
  595. modalhtml += ' <span aria-hidden="true" style="color:#b3b081">-</span>'
  596. modalhtml += ' </button>'
  597. modalhtml += ' </div>'
  598. modalhtml += ' <div class="modal-body" id="idlebody" style="color:#b3b081;background-color:#171717">'
  599. modalhtml += ' <span id="scanned">Click "Scan" or press "s" to scan. <br/><br/>Items to open and scan: Modifiers, Money Stats (pop-up), Army Stats (pop-up), Crafter Recipes (Change Recipe)</span><br/>'
  600. modalhtml += ' <hr style="border-top:3px dashed bbb"/>'
  601. modalhtml += ' <div id="IdleOutput" style="font-size:80%;max-height:' + max_height+ 'px;overflow-y:auto;"></div><br/>'
  602. modalhtml += ' <button type="button" id="idlescanbutton" aria-label="Scan">'
  603. modalhtml += ' <span style="color:#000000">Scan</span>'
  604. modalhtml += ' </button>'
  605. modalhtml += ' <button type="button" id="idlerecipesbutton" aria-label="Recipes">'
  606. modalhtml += ' <span style="color:#000000">Recipes</span>'
  607. modalhtml += ' </button>'
  608. modalhtml += ' <button type="button" id="idlepercentsbutton" aria-label="Percentages">'
  609. modalhtml += ' <span style="color:#000000">Income</span>'
  610. modalhtml += ' </button>'
  611. modalhtml += ' <button type="button" id="idleartifactbutton" aria-label="Artifact">'
  612. modalhtml += ' <span style="color:#000000">Artifact</span>'
  613. modalhtml += ' </button>'
  614. modalhtml += ' <button type="button" id="idleotherbutton" aria-label="Other">'
  615. modalhtml += ' <span style="color:#000000">Other</span>'
  616. modalhtml += ' </button>'
  617. modalhtml += ' </div>'
  618. modalhtml += ' </div>'
  619. modalhtml += ' </div>'
  620. modalhtml += '</div>'
  621.  
  622. var idle_modal=$(modalhtml)
  623. idle_modal.show();
  624. $('body').append(idle_modal)
  625.  
  626. var instructions_open=$("#idleinstructionbutton")
  627. instructions_open.on('click', function() {
  628. instructions_modal.show();
  629. });
  630.  
  631. var idle_minimize=$("#idleminimize")
  632. idle_minimize.on('click', function() {
  633. idle_modal.hide();
  634. idle_modal2.show();
  635. });
  636.  
  637. var idle_open=$("#idlemenuopen")
  638. idle_open.on('click', function() {
  639. idle_modal.show();
  640. idle_modal2.hide();
  641. });
  642.  
  643. var idle_scan_click=$("#idlescanbutton")
  644. idle_scan_click.on('click', function() {
  645. scanIdle();
  646. });
  647.  
  648. var idle_recipes_click=$("#idlerecipesbutton")
  649. idle_recipes_click.on('click', function() {
  650. idleSelected = "recipes";
  651. if(!loadedLevel) {
  652. scanIdle();
  653. } else {
  654. outputResults(idleObject);
  655. }
  656. });
  657.  
  658. var idle_percents_click=$("#idlepercentsbutton")
  659. idle_percents_click.on('click', function() {
  660. idleSelected = "percents";
  661. if(!loadedLevel) {
  662. scanIdle();
  663. } else {
  664. outputResults(idleObject);
  665. }
  666. });
  667.  
  668. var idle_artifact_click=$("#idleartifactbutton")
  669. idle_artifact_click.on('click', function() {
  670. idleSelected = "artifact";
  671. if(!loadedLevel) {
  672. scanIdle();
  673. } else {
  674. outputResults(idleObject);
  675. }
  676. });
  677.  
  678. var idle_other_click=$("#idleotherbutton")
  679. idle_other_click.on('click', function() {
  680. idleSelected = "other";
  681. if(!loadedLevel) {
  682. scanIdle();
  683. } else {
  684. outputResults(idleObject);
  685. }
  686. });
  687.  
  688. scannedSpan = $("#scanned");
  689.  
  690. $(document).keydown(function(e){
  691. //CTRL + V keydown combo
  692. //if(e.ctrlKey && e.keyCode == 86){
  693. if(e.keyCode == 83){
  694. scanIdle();
  695. }
  696. });
  697.  
  698. var idleObject_tmp = getIdleObjectFromStorage();
  699. if(idleObject_tmp != null) {
  700. idleObject = idleObject_tmp;
  701. if(idleObject.scan_times == null) {
  702. idleObject.scan_times = createScanTimes();
  703. saveIdleObjectToStorage(idleObject);
  704. }
  705. var output = 'Retrieved level "' + idleObject.level + '" from storage.'
  706. var idleOut = $("#IdleOutput");
  707. idleOut.html(output);
  708. }
  709. setIdlePermanentFromStorage();
  710.  
  711. // Remove this in the future
  712. // Update permanent upgrades to new format
  713. if(idleObject.artifacts && idleObject.artifacts.length > 0) {
  714. if(idlePermanent.artifacts == null) {
  715. idlePermanent.artifacts = idleObject.artifacts;
  716. idlePermanent.scan_times.artifacts = idleObject.scan_times.artifacts;
  717. saveIdlePermanentToStorage();
  718. }
  719. delete idleObject.artifacts;
  720. delete idleObject.scan_times.artifacts;
  721. saveIdleObjectToStorage(idleObject);
  722. }
  723. setupArtifactsLookup()
  724. }
  725.  
  726. function setupArtifactsLookup() {
  727. artifacts_list = [];
  728. // Passives
  729. artifacts_list.push({"name":"Alloy Values","value":[0.035],"type":"+"});
  730. artifacts_list.push({"name":"Army Camp Boost","value":[0.05],"type":"+"});
  731. artifacts_list.push({"name":"Army Cache Boost","value":[0.01],"type":"+"});
  732. artifacts_list.push({"name":"Army Camp Discount","value":[0.0075],"type":"x"});
  733. artifacts_list.push({"name":"Bonus Money Boost","value":[0.05],"type":"+"});
  734. artifacts_list.push({"name":"Cache Boost","value":[0.004],"type":"+"});
  735. artifacts_list.push({"name":"Craft Double","value":[0.0075],"type":"+"});
  736. artifacts_list.push({"name":"Draft Boost","value":[0.02],"type":"+"});
  737. artifacts_list.push({"name":"Efficient Crafters","value":[0.005],"type":"x"});
  738. artifacts_list.push({"name":"Efficient Smelters","value":[0.005],"type":"x"});
  739. artifacts_list.push({"name":"Hospital Boost","value":[0.01],"type":"+"});
  740. artifacts_list.push({"name":"Hospital Discount","value":[0.0075],"type":"x"});
  741. artifacts_list.push({"name":"Idle Time","value":[10.00],"type":"+"});
  742. artifacts_list.push({"name":"Item Values","value":[0.02],"type":"+"});
  743. artifacts_list.push({"name":"Mercenary Discount","value":[0.01],"type":"x"});
  744. artifacts_list.push({"name":"Mine Boost","value":[0.0175],"type":"+"});
  745. artifacts_list.push({"name":"Mine Discount","value":[0.0125],"type":"x"});
  746. artifacts_list.push({"name":"Money Cache Boost","value":[0.02],"type":"+"});
  747. artifacts_list.push({"name":"Ore Values","value":[0.045],"type":"+"});
  748. artifacts_list.push({"name":"Resource Cache Boost","value":[0.05],"type":"+"});
  749. artifacts_list.push({"name":"Smelt Double","value":[0.0075],"type":"+"});
  750. artifacts_list.push({"name":"Speedy Crafters","value":[0.05,0.1,0.15,0.25,0.35,0.50,0.65],"type":"x"});
  751. artifacts_list.push({"name":"Speedy Smelters","value":[0.05,0.1,0.15,0.25,0.35,0.50,0.65],"type":"x"});
  752. artifacts_list.push({"name":"Tech Discount","value":[0.0075],"type":"x"});
  753. artifacts_list.push({"name":"Territory Money Boost","value":[0.125],"type":"+"});
  754.  
  755. // Actives
  756. artifacts_list.push({"name":"Army Cache","value":[0.10]});
  757. artifacts_list.push({"name":"Damage Territory","value":[0.015]});
  758. artifacts_list.push({"name":"Discount Army Camp","value":[0.03]});
  759. artifacts_list.push({"name":"Discount Hospital","value":[0.03]});
  760. artifacts_list.push({"name":"Discount Mine","value":[0.03]});
  761. artifacts_list.push({"name":"Field Hospital","value":[0.015]});
  762. artifacts_list.push({"name":"Fog Buster","value":[2.00]});
  763. artifacts_list.push({"name":"Inspire Mercenaries","value":[0.015]});
  764. artifacts_list.push({"name":"Market Raid","value":[0.075]});
  765. artifacts_list.push({"name":"Money Cache","value":[0.15]});
  766. artifacts_list.push({"name":"Quadruple Strike","value":[0.06]});
  767. artifacts_list.push({"name":"Resource Cache","value":[0.15]});
  768. artifacts_list.push({"name":"Supercharge Army Camp","value":[7.50]});
  769. artifacts_list.push({"name":"Supercharge Mine","value":[7.50]});
  770. artifacts_list.push({"name":"Time Warp","value":[7.50]});
  771. artifacts_list.push({"name":"Triple Strike","value":[0.05]});
  772. }
  773.  
  774. // **************** Idle Information Scan ****************
  775.  
  776. function scanIdle() {
  777. loadedLevel = false;
  778. scannedSpan.text("Scanned: Tabs");
  779. var idleOut = $("#IdleOutput");
  780. idleOut.html("");
  781.  
  782. idleObject = scanMain(idleObject);
  783. idleObject.scan_times.tabs = (new Date()).getTime();
  784. scanArmiesTab(idleObject);
  785. scanMinesTab(idleObject);
  786. scanOresTab(idleObject);
  787. scanItemsAlloysTab(idleObject);
  788. scanRecipesTab(idleObject);
  789. scanTechTab(idleObject);
  790. scanPowersTab(idleObject);
  791. scanAdvancementsTab(idleObject);
  792. scanOther(idleObject);
  793.  
  794. saveIdleObjectToStorage(idleObject);
  795. saveIdlePermanentToStorage();
  796. outputResults(idleObject);
  797. }
  798.  
  799. function scanMain(idleObject) {
  800. //<div class="ujsInner ujsTextInner" id="ujs_ArmiesLabel_2_tmp"
  801. //style="width: 190px; height: 30px; color: rgb(186, 186, 187); text-shadow: rgb(0, 0, 0) -1px -1px 0px, rgb(0, 0, 0) 1px -1px 0px, rgb(0, 0, 0) -1px 1px 0px, rgb(0, 0, 0)
  802. //1px 1px 0px; text-align: right; justify-content: flex-end; align-items: center; font-size: 17.4px; line-height: 17.4px; white-space: pre; padding: 0px 0px 0.582124px;
  803. //font-weight: bold; overflow: visible;">₳2.37B (56K/sec)</div>
  804. var level = "";
  805. $('*[id*=ujs_GameNameLabel_]').each(function() {
  806. var element = this;
  807. level = element.textContent;
  808. });
  809.  
  810. if(level != idleObject.level) {
  811. archiveIdleObject(idleObject);
  812. var output = 'Archived level ' + idleObject.level + '.'
  813. idleObject = getArchivedIdleObject(level);
  814. if(idleObject == null) {
  815. idleObject = getNewIdleObject();
  816. idleObject.level = level;
  817. } else {
  818. output += ' Retrieved level ' + idleObject.level + ' from storage.'
  819. }
  820. var idleOut = $("#IdleOutput");
  821. idleOut.html(output);
  822.  
  823. saveIdleObjectToStorage(idleObject);
  824. }
  825.  
  826. // Set the armies per second from the top right
  827. idleObject.armies_ps = null;
  828. $('*[id*=ujs_ArmiesLabel]').each(function() {
  829. var element = this;
  830. if(idleObject.armies_ps == null) {
  831. var label = element.textContent;
  832. var startIndex = label.indexOf("(") + 1;
  833. var endIndex = label.indexOf("/sec");
  834. if(startIndex > 0 && endIndex > startIndex) {
  835. idleObject.armies_ps = parseIdleNumber(label.substring(startIndex, endIndex));
  836. }
  837. }
  838. });
  839.  
  840. // Set the money per second from the top right
  841. idleObject.money_ps = null;
  842. $('*[id*=ujs_MoneyLabel]').each(function() {
  843. var element = this;
  844. if(idleObject.money_ps == null) {
  845. var label = element.textContent;
  846. var startIndex = label.indexOf("(") + 1;
  847. var endIndex = label.indexOf("/sec");
  848. if(startIndex > 0 && endIndex > startIndex) {
  849. idleObject.money_ps = parseIdleNumber(label.substring(startIndex, endIndex));
  850. }
  851. }
  852. });
  853.  
  854. // Get the more detailed armies per second if the stats are open
  855. $('*[id*=ujs_ArmiesHoverDialog]').each(function() {
  856. var hoverdialog = $(this);
  857. var armyhover = [];
  858. hoverdialog.find('*[id*=ujs_Row]').each(function() {
  859. var hoverrow = $(this);
  860. var splithover = hoverrow.text().split(":");
  861. if(splithover.length == 2) {
  862. var name = splithover[0];
  863. var value = parseIdleNumber(splithover[1].substring(1));
  864. if(splithover[1].indexOf("day") != -1
  865. || splithover[1].indexOf("hour") != -1
  866. || splithover[1].indexOf("minute") != -1) {
  867. value = parseIdleTimeString(splithover[1])
  868. }
  869. armyhover.push({"name": name, "value": value})
  870. }
  871. });
  872. if(idleSelected == null) {
  873. idleSelected = "percents";
  874. }
  875. if(showDevelopmentFeatures && idleObject.armyhover != null
  876. && idleObject.armyhover.length >= 7
  877. && armyhover.length >= 7) {
  878. var drafted1 = idleObject.armyhover[6].value;
  879. var drafted2 = armyhover[6].value;
  880. // Current armies minus drafts
  881. //var earned = armyhover[2].value-armyhover[6].value;
  882. //sigfigmult =
  883. //earned = Math.Round(earned/sigfigmult)*sigfigmult
  884. // Last Scanned earned
  885. var earned = idleObject.armyhover[2].value;
  886. var income = idleObject.armyhover[1].value;
  887.  
  888. var drafted = drafted2-drafted1;
  889. if(drafted > 0) {
  890. var draft = {
  891. "aps":income,
  892. "tot":earned,
  893. "dft":drafted,
  894. "dftd":drafted1
  895. }
  896. drafts.push(draft)
  897. }
  898. }
  899. idleObject.armyhover = armyhover;
  900. scannedSpan.text(scannedSpan.text() + ", " + "Army Hover");
  901. idleObject.scan_times.army_hover = (new Date()).getTime();
  902. });
  903.  
  904. // Get the more detailed money per second if the stats are open
  905. $('*[id*=ujs_MoneyHoverDialog]').each(function() {
  906. var hoverdialog = $(this);
  907. var moneyhover = [];
  908. hoverdialog.find('*[id*=ujs_Row]').each(function() {
  909. var hoverrow = $(this);
  910. var splithover = hoverrow.text().split(":");
  911. if(splithover.length == 2) {
  912. var name = splithover[0];
  913. var value = parseIdleNumber(splithover[1].substring(1));
  914. if(isNaN(value)) {
  915. value = parseIdleTimeString(splithover[1])
  916. }
  917. moneyhover.push({"name": name, "value": value})
  918. }
  919. });
  920. if(idleSelected == null) {
  921. idleSelected = "percents";
  922. }
  923. idleObject.moneyhover = moneyhover;
  924. scannedSpan.text(scannedSpan.text() + ", " + "Money Hover");
  925. idleObject.scan_times.money_hover = (new Date()).getTime();
  926. });
  927.  
  928. // Overwrite if there is a more accurate version from the stats hovers
  929. if(idleObject.armyhover != null && idleObject.armyhover.length > 1) {
  930. var aps1 = idleObject.armyhover[1].value;
  931. var aps2 = idleObject.armies_ps;
  932. if(aps2 == null) {
  933. idleObject.armies_ps = aps1;
  934. } else if(aps1*.99 <= aps2 && aps2*.99 <= aps1) {
  935. // If equal, use the hover scan
  936. idleObject.armies_ps = aps1;
  937. }
  938. }
  939. if(idleObject.moneyhover != null && idleObject.moneyhover.length > 1) {
  940. var mps1 = idleObject.moneyhover[1].value;
  941. var mps2 = idleObject.money_ps;
  942. if(mps2 == null) {
  943. idleObject.money_ps = mps1;
  944. } else if(mps1*.99 <= mps2 && mps2*.99 <= mps1) {
  945. // If equal, use the hover scan
  946. idleObject.money_ps = mps1;
  947. }
  948. }
  949.  
  950. return idleObject;
  951. }
  952.  
  953. function scanArmiesTab(idleObject) {
  954. var camps = [];
  955. $('*[id*=ujs_WziTabBodyArmyCampRow]').each(function() {
  956. var camp = $(this);
  957. var name = "";
  958. var level = -1;
  959. var armies_per_s = 0;
  960. var cost = 0;
  961. camp.find('*[id*=ujs_NameLabel]').each(function() {
  962. var element = $(this);
  963. name = element.text();
  964. });
  965. camp.find('*[id*=ujs_LevelLabel]').each(function() {
  966. var element = $(this);
  967. var levelstr = element.text();
  968. level = parseInt(levelstr.substring(1));
  969. });
  970. //id="ujs_ArmiesPerSecondLabel_2_tmp"
  971. camp.find('*[id*=ujs_ArmiesPerSecondLabel]').each(function() {
  972. var element = $(this);
  973. var aps_str = element.text().substring(1);
  974. aps_str = aps_str.substring(0, aps_str.indexOf(" / "));
  975. armies_per_s = parseIdleNumber(aps_str);
  976. });
  977. camps.push({
  978. "name": name,
  979. "level": level,
  980. "armies_per_s": armies_per_s,
  981. "cost": cost
  982. })
  983. });
  984. if(camps.length > 0) {
  985. idleObject.camps = camps;
  986. }
  987.  
  988. // Get Hospitals
  989. var hospitals = [];
  990. $('*[id*=ujs_WziTabBodyHospitalRow]').each(function() {
  991. var element = $(this);
  992. var level = getTextValueForIdContaining("ujs_LevelLabel", element);
  993. var upgrade = getTextValueForIdContaining("ujs_UpgradeBtn", element, true);
  994. var effect = getTextValueForIdContaining("ujs_EffectLabel", element);
  995. var slider = getTextValueForIdContaining("ujs_ProgressLabel", element);
  996.  
  997. var l = parseIdleNumber(level.replace("L","").trim())
  998.  
  999. var upgrade_cost = -1;
  1000. var upgrade_trunc = upgrade.substring(upgrade.indexOf("₩") + 1)
  1001. // This had a value in it, get the cost
  1002. if(upgrade_trunc != upgrade) {
  1003. upgrade_cost = parseIdleNumber(upgrade_trunc);
  1004. }
  1005.  
  1006. var effects = effect.replace("Saves ","");
  1007. var split = effects.split("/");
  1008. var saves1 = parseIdleNumber(split[0].trim().substring(1));
  1009. var saves2 = parseIdleNumber(split[1].trim().substring(1));
  1010.  
  1011. var hospital = {
  1012. "l":l,
  1013. "c":upgrade_cost,
  1014. "s1":saves1,
  1015. "s2":saves2
  1016. }
  1017. hospitals.push(hospital)
  1018. });
  1019. if(hospitals.length > 0) {
  1020. idleObject.hospitals = hospitals;
  1021. }
  1022.  
  1023. // Get Mercenaries
  1024. var mercs = [];
  1025. var mercs_cost = 0.0;
  1026. var mercs_sum = 0.0;
  1027. $('*[id*=ujs_WziTabBodyMercenaryCampRow]').each(function() {
  1028. var element = $(this);
  1029. var split = element.text().split(" ");
  1030. var num = 0;
  1031. var price = 0;
  1032. for(var i = 0; i < split.length; i++) {
  1033. if(split[i].indexOf("₳") != -1) {
  1034. num = parseIdleNumber(split[i].substring(split[i].indexOf("₳")+1));
  1035. }
  1036. if(split[i].indexOf("₩") != -1) {
  1037. price = parseIdleNumber(split[i].substring(split[i].indexOf("₩")+1));
  1038. }
  1039. }
  1040. mercs.push({"available":num,"price":price,"total":num*price});
  1041. mercs_cost += num*price;
  1042. mercs_sum += num;
  1043. });
  1044. if(mercs.length > 0) {
  1045. idleObject.mercenaries = mercs;
  1046. idleObject.mercenaries_sum = mercs_sum;
  1047. idleObject.mercenaries_cost = mercs_cost;
  1048. }
  1049.  
  1050. // Get Modifiers
  1051. $('*[id*=ujs_ModifierBreakdownDialog]').each(function() {
  1052. var modifier_dialog = $(this)
  1053. var modifiers = [];
  1054. scannedSpan.text(scannedSpan.text() + ", Modifiers");
  1055. idleObject.scan_times.modifiers = (new Date()).getTime();
  1056. modifier_dialog.find("*[id*=ujs_main]").each(function() {
  1057. var mod = $(this);
  1058. var texts = [];
  1059. mod.find(".ujsTextInner").each(function() {
  1060. texts.push(this.textContent);
  1061. });
  1062. if(texts.length > 1) {
  1063. var modifier = {
  1064. "name":null,
  1065. "value":null,
  1066. "det":[]
  1067. }
  1068. modifier.name = texts[0];
  1069. modifier.value = texts[1];
  1070. for(var i = 2; i < texts.length-1; i+=2) {
  1071. var detail = {
  1072. "name":texts[i],
  1073. "value":texts[i+1]
  1074. }
  1075. modifier.det.push(detail);
  1076. }
  1077. if(texts.length%2 == 1) {
  1078. modifier.note = texts[texts.length - 1];
  1079. }
  1080. modifiers.push(modifier);
  1081. }
  1082. });
  1083. idleObject.modifiers = modifiers;
  1084. });
  1085. }
  1086.  
  1087. function scanMinesTab(idleObject) {
  1088.  
  1089. }
  1090.  
  1091. function scanOresTab(idleObject) {
  1092.  
  1093. }
  1094.  
  1095. function scanItemsAlloysTab(idleObject) {
  1096. var items_alloys = [];
  1097. var modified = false;
  1098. $('*[id*=WziTabBodyResourceRow]').each(function() {
  1099. var element = $(this);
  1100. var name = "";
  1101. var qty = "";
  1102. var pricestr = "";
  1103. var price = -1;
  1104. var id = "";
  1105.  
  1106. element.find("*[id*=NameLabel]").each(function() {
  1107. name = this.textContent;
  1108. });
  1109. element.find("*[id*=QuantityLabel]").each(function() {
  1110. qty = this.textContent;
  1111. });
  1112. element.find("*[id*=SellsForLabel]").each(function() {
  1113. pricestr = this.textContent.substring(1);
  1114. price = parseIdleNumber(pricestr);
  1115. });
  1116.  
  1117.  
  1118. var ids = getIngredientIDs(element);
  1119. if(ids.length > 0 ) {
  1120. id = ids[0];
  1121. }
  1122. var item_alloy = {
  1123. "name": name,
  1124. "qty": qty,
  1125. "pricestr": pricestr,
  1126. "price": price,
  1127. "id" : id
  1128. }
  1129. items_alloys.push(item_alloy);
  1130. });
  1131. if(items_alloys.length > 0) {
  1132. idleObject.items_alloys = items_alloys;
  1133. modified = true;
  1134. }
  1135.  
  1136. var market_items = [];
  1137. var market_costs = [];
  1138. $('*[id*=MarketRow]').each(function() {
  1139. var element = $(this);
  1140. var ingredients = element.find("*[id*=ujs_ResourcesContainer]");
  1141. var result = element.find("*[id*=ujs_MakingContainer]");
  1142. var ing_ids = [];
  1143. var ingcosts = [];
  1144. ingredients.each(function() {
  1145. var ing = $(this);
  1146. ing_ids = ing_ids.concat(getIngredientIDs(ing));
  1147. ingcosts = ingcosts.concat(getIngredientQtys(ing));
  1148. });
  1149.  
  1150. market_items = market_items.concat(ing_ids);
  1151. market_costs = market_costs.concat(ingcosts);
  1152. });
  1153. var market = [];
  1154. if(market_items.length > 0 && market_items.length == market_costs.length) {
  1155. for(var i = 0; i < market_costs.length; i++) {
  1156. var name = market_items[i];
  1157. var coststr = market_costs[i];
  1158. var cost = parseIdleNumber(coststr.substring(coststr.indexOf("₩")+1));
  1159. market.push({
  1160. "name":name,
  1161. "coststr":coststr,
  1162. "cost":cost
  1163. })
  1164. }
  1165. idleObject.market_resource_ids = market_items;
  1166. idleObject.market_resources = market;
  1167. modified = true;
  1168. }
  1169. return modified;
  1170. }
  1171.  
  1172. function scanRecipesTab(idleObject) {
  1173.  
  1174. // Get Number of crafters
  1175. $('*[id*=ujs_CraftersContainer]').each(function() {
  1176. var cftr = $(this);
  1177. var cftrs = cftr.find('*[id*=ujs_WziTabBodySmelterOrCrafterRow]')
  1178. idleObject.num_cftr = cftrs.length;
  1179. });
  1180. // Get Recipes
  1181. var recipes = [];
  1182. $('*[id*=RecipeRow]').each(function() {
  1183. var element = $(this);
  1184. var ingredients = element.find("*[id*=ujs_ResourcesContainer]");
  1185. var result = element.find("*[id*=ujs_MakingContainer]");
  1186. var ing_ids = [];
  1187. var ing_qtys = [];
  1188. ingredients.each(function() {
  1189. var ing = $(this);
  1190. ing_ids = ing_ids.concat(getIngredientIDs(ing));
  1191. ing_qtys = ing_qtys.concat(getIngredientQtys(ing));
  1192. });
  1193.  
  1194. for(var i = 0; i < ing_qtys.length; i++) {
  1195. var qty = ing_qtys[i];
  1196. qty = qty.substring(qty.indexOf("/")+1);
  1197. ing_qtys[i] = qty;
  1198. }
  1199. var makes = "";
  1200. result.each(function() {
  1201. var text_node = $(this).find("*[id*=ujs_Text_]");
  1202. if(text_node != null && text_node.length > 0) {
  1203. makes = text_node[0].textContent;
  1204. if(makes.indexOf("(") != -1) {
  1205. makes = makes.substring(0, makes.indexOf("(") -1);
  1206. }
  1207. }
  1208. });
  1209.  
  1210. var recipe_id = makes;
  1211. var ids = getIngredientIDs(result);
  1212. if(ids.length != 0) {
  1213. recipe_id = ids[0];
  1214. }
  1215.  
  1216. var time = "";
  1217. element.find("*[id*=DurationLabel]").each(function() {
  1218. time = this.textContent;
  1219. });
  1220. var time_in_s = parseIdleTimeString(time);
  1221. //var value = getItemAlloySellValueById(idleObject, recipe_id);
  1222. var recipe = {
  1223. "name" : makes,
  1224. "id" : recipe_id,
  1225. "ing_ids" : ing_ids,
  1226. "ing_qtys" : ing_qtys,
  1227. "time" : time,
  1228. "time_in_s" : time_in_s
  1229. }
  1230. recipes.push(recipe);
  1231. });
  1232. if(recipes.length > 0) {
  1233. if(idleSelected == null) {
  1234. idleSelected = "recipes";
  1235. }
  1236. if(recipes[0].ing_ids[0].indexOf("Rock-") != -1) {
  1237. //This makes an alloy
  1238. idleObject.recipes_smelter = recipes;
  1239. scannedSpan.text(scannedSpan.text() + ", Smelter Recipes");
  1240. idleObject.scan_times.recipe_smelter = (new Date()).getTime();
  1241. } else {
  1242. idleObject.recipes = recipes;
  1243. scannedSpan.text(scannedSpan.text() + ", Crafter Recipes");
  1244. idleObject.scan_times.recipe_crafter = (new Date()).getTime();
  1245. }
  1246. }
  1247.  
  1248. }
  1249.  
  1250. function scanTechTab(idleObject) {
  1251. var techs = [];
  1252. var camps = 0;
  1253. var draft = 0;
  1254. var crafter_speed = 0;
  1255. var smelter_speed = 0;
  1256. var mines = 0;
  1257. $('*[id*=ujs_techtree]').each(function() {
  1258. var element = $(this);
  1259. var icon = null;
  1260. element.find('*[id*=ujs_Icon]').each(function() {
  1261. var html = $(this).html();
  1262. var icon_tmp = getIcon(html);
  1263. if(icon_tmp != null) {
  1264. icon = icon_tmp;
  1265. }
  1266. });
  1267.  
  1268. var border = null;
  1269. element.find('*[id*=ujs_Border]').each(function() {
  1270. var html = $(this).html();
  1271. var icon_tmp = getIcon(html);
  1272. if(icon_tmp != null) {
  1273. border = icon_tmp;
  1274. }
  1275. });
  1276. if(border != null && icon != null) {
  1277. if(border.indexOf("FFFF00") != -1) {
  1278. // Unlocked
  1279. if(icon.indexOf("CampingTent") != -1) {
  1280. camps++;
  1281. } else if(icon.indexOf("DropWeapon") != -1) {
  1282. draft++;
  1283. } else if(icon.indexOf("Crafting") != -1) {
  1284. crafter_speed++;
  1285. } else if(icon.indexOf("PulleyHook") != -1) {
  1286. smelter_speed++;
  1287. } else if(icon.indexOf("MineTruck") != -1) {
  1288. mines++;
  1289. } else {
  1290. var ignore = [
  1291. "DropWeapon",
  1292. "MoneyStack",
  1293. "ClaymoreExplosive",
  1294. "Profit",
  1295. "Doubled",
  1296. "SwordBrandish",
  1297. "Minerals",
  1298. "Hospital",
  1299. "GemPendant",
  1300. "Cash",
  1301. "Campfire",
  1302. "Banknote",
  1303. ]
  1304. if(ignore.indexOf(icon) == -1) {
  1305. console.log("Did not store tech: " + icon)
  1306. }
  1307. }
  1308. }
  1309. }
  1310. });
  1311. techs = {
  1312. "camp":camps,
  1313. "draft":draft,
  1314. "cr_speed":crafter_speed,
  1315. "sm_speed":smelter_speed,
  1316. "mine":mines
  1317. }
  1318.  
  1319. idleObject.techs = techs;
  1320. }
  1321.  
  1322. function scanPowersTab(idleObject) {
  1323.  
  1324. }
  1325.  
  1326. function scanAdvancementsTab(idleObject) {
  1327. var artifacts_equipped = [];
  1328. var artifacts = [];
  1329. $('*[id*=ArtifactCard]').each(function() {
  1330. var element = $(this);
  1331.  
  1332. var name = "";
  1333. element.find('*[id*=ujs_Name]').each(function() {
  1334. name = this.textContent;
  1335. });
  1336.  
  1337. var rarity = "";
  1338. element.find('*[id*=ujs_Rarity]').each(function() {
  1339. rarity = this.textContent;
  1340. });
  1341.  
  1342. if(name.length != 0 && rarity.length != 0) {
  1343. if(artifacts_equipped.length < 3) {
  1344. artifacts_equipped.push({"n":name,"r":rarity})
  1345. } else {
  1346. if (artifacts.length == 0 && artifacts_equipped[0].n != name) {
  1347. artifacts.push(artifacts_equipped[0]);
  1348. artifacts.push(artifacts_equipped[1]);
  1349. artifacts.push(artifacts_equipped[2]);
  1350. }
  1351. artifacts.push({"n":name,"r":rarity})
  1352. }
  1353. }
  1354.  
  1355. });
  1356. if(artifacts_equipped.length == 3) {
  1357. idleObject.artifacts_equipped = artifacts_equipped;
  1358. idlePermanent.artifacts_equipped = artifacts_equipped;
  1359. }
  1360. if(artifacts.length > 0) {
  1361. idlePermanent.artifacts = artifacts;
  1362. scannedSpan.text(scannedSpan.text() + ", Artifacts");
  1363. idlePermanent.scan_times.artifacts = (new Date()).getTime();
  1364. }
  1365.  
  1366. // Scan the advancements
  1367. var advancements = [];
  1368. $('*[id*=ujs_WziTabBodyAPRow]').each(function() {
  1369. var row = $(this);
  1370. var name = getTextValueForIdContaining("ujs_NameLabel", row)
  1371. var value = getTextValueForIdContaining("ujs_CurrentValueIfUnlockedLabel", row)
  1372. if(name != null && value != null) {
  1373. value = value.replace("Current value: ","");
  1374. var adv = {"n":name,"v":value}
  1375. advancements.push(adv);
  1376. }
  1377. });
  1378. if(advancements.length > 0) {
  1379. idlePermanent.advancements = advancements;
  1380. idlePermanent.scan_times.advancements = (new Date()).getTime();
  1381. }
  1382.  
  1383. // Scan the stats pop up window (Statistics 4)
  1384. $('*[id*=ujs_CurrentLevelStatsContainer]').each(function() {
  1385. var level_stats = $(this);
  1386. level_stats.find(".ujsText").each(function() {
  1387. var text = this.textContent;
  1388. var split = text.split(":");
  1389. if(split[0].indexOf("bonuses you own") != -1) {
  1390. var value = parseIdleNumber(split[1].trim());
  1391. var mod = getModifierBreakdown(idleObject, "Money from Bonuses");
  1392. var arti_mod = getEquippedArtifactModifier(idleObject, "Bonus Money Boost");
  1393. // Save the base value
  1394. idleObject.bonusMoney = value/(mod.mod_no_a + arti_mod);
  1395. }
  1396. });
  1397. });
  1398.  
  1399. }
  1400.  
  1401. function scanOther(idleObject) {
  1402. idleObject.last_terr = null;
  1403. var territory_name = null;
  1404. $('*[id*=ujs_MainLabel]').each(function() {
  1405. var label = $(this).text();
  1406. if(label.indexOf("Territory") != -1) {
  1407. territory_name = label.substring(label.indexOf(":") + 2);
  1408. }
  1409. });
  1410. $('*[id*=ujs_DetailsLabel]').each(function() {
  1411. var element = $(this)
  1412. if(idleObject.last_terr == null || idleObject.last_terr.c == 0) {
  1413. var value = element.text();
  1414. var lines = value.split('\n');
  1415. var cost = 0;
  1416. var hospitals = 0;
  1417. for(var i = 0; i < lines.length; i++) {
  1418. if(lines[i].indexOf("armies to conquer") != -1) {
  1419. cost = parseIdleNumber(lines[i].substring(1,lines[i].indexOf(" armies to conquer")))
  1420. }
  1421. if(lines[i].indexOf("will retain") != -1) {
  1422. hospitals = parseIdleNumber(lines[i].substring(
  1423. lines[i].indexOf("₳")+1,
  1424. lines[i].indexOf("(")-1
  1425. ))
  1426. }
  1427. }
  1428. if(cost != 0 && territory_name != null) {
  1429. idleObject.last_terr = {
  1430. "c":cost,
  1431. "h":hospitals,
  1432. "n":territory_name
  1433. }
  1434. }
  1435. }
  1436. });
  1437. }
  1438.  
  1439. function getTextValueForIdContaining(id, parent, skip_hidden) {
  1440. var results = null;
  1441. if(parent) {
  1442. results = parent.find('*[id*=' + id + ']')
  1443. } else {
  1444. results = $('*[id*=' + id + ']');
  1445. }
  1446. var result = null;
  1447. results.each(function() {
  1448. if(skip_hidden == true && this.style.display == 'none') {
  1449. // Ignore
  1450. } else {
  1451. if(this.textContent == "") {
  1452. if(result == null) {
  1453. result = this.textContent;
  1454. }
  1455. } else {
  1456. result = this.textContent
  1457. }
  1458. }
  1459. });
  1460. return result;
  1461. }
  1462.  
  1463. function getIcon(html) {
  1464. var start = html.indexOf("https://warzonecdn.com/ujs/Resources/") + 37;
  1465. var end = html.indexOf(".png");
  1466. if(start >= 37 && end != -1 && end > start) {
  1467. return html.substring(start,end);
  1468. }
  1469. return null;
  1470. }
  1471.  
  1472. function getIngredientIDs(parent) {
  1473. var names = [];
  1474. var stop = false;
  1475. parent.children().each(function () {
  1476. var child = $(this);
  1477. var id = child.attr('id');
  1478. if(id != null && id.indexOf("ujs_ResourceIcon_") != -1) {
  1479. stop = true;
  1480. var ing = $(this)
  1481. var resource_icon = getIcon(ing.html());
  1482. names.push(resource_icon);
  1483. }
  1484. if(!stop){
  1485. names = names.concat(getIngredientIDs(child));
  1486. }
  1487. });
  1488. return names;
  1489. }
  1490.  
  1491. function getIngredientQtys(parent) {
  1492. var qtys = [];
  1493. var stop = false;
  1494. parent.children().each(function () {
  1495. var child = $(this);
  1496. var id = child.attr('id');
  1497. if(id != null && id.indexOf("ujs_Text_") != -1) {
  1498. stop = true;
  1499. var ing = this
  1500. qtys.push(ing.textContent);
  1501. }
  1502. if(!stop){
  1503. qtys = qtys.concat(getIngredientQtys(child));
  1504. }
  1505. });
  1506. return qtys;
  1507. }
  1508.  
  1509. function parseIdleNumber(coststr) {
  1510. if(coststr.indexOf("P") != -1) {
  1511. return parseFloat(coststr.substring(0,coststr.indexOf("P"))) * 1.0E15;
  1512. } else if(coststr.indexOf("T") != -1) {
  1513. return parseFloat(coststr.substring(0,coststr.indexOf("T"))) * 1.0E12;
  1514. } else if(coststr.indexOf("B") != -1) {
  1515. return parseFloat(coststr.substring(0,coststr.indexOf("B"))) * 1.0E9;
  1516. } else if(coststr.indexOf("M") != -1) {
  1517. return parseFloat(coststr.substring(0,coststr.indexOf("M"))) * 1.0E6;
  1518. } else if(coststr.indexOf("K") != -1) {
  1519. return parseFloat(coststr.substring(0,coststr.indexOf("K"))) * 1.0E3;
  1520. } else {
  1521. return parseFloat(coststr);
  1522. }
  1523. return -1.0
  1524. }
  1525.  
  1526. function parseIdleTimeString(timestr) {
  1527. timestr = timestr.toLowerCase();
  1528. var timesplit = timestr.split(" ");
  1529. var val_in_s = 0;
  1530. for(var i = 0; i < timesplit.length; i+=2) {
  1531. var value = timesplit[i]
  1532. if(value.indexOf("ago") != -1) {
  1533. i--;
  1534. continue;
  1535. }
  1536. var unit = timesplit[i+1]
  1537. if(unit.indexOf("day") != -1) {
  1538. val_in_s += parseInt(value)*60*60*24;
  1539. } else if(unit.indexOf("hour") != -1) {
  1540. val_in_s += parseInt(value)*60*60;
  1541. } else if(unit.indexOf("minute") != -1) {
  1542. val_in_s += parseInt(value)*60;
  1543. } else if(unit.indexOf("second") != -1) {
  1544. val_in_s += parseInt(value);
  1545. }
  1546. }
  1547. return val_in_s;
  1548. }
  1549.  
  1550. // **************** Idle Output ****************
  1551.  
  1552. function outputResults(idleObject) {
  1553. if(idleSelected == "percents") {
  1554. outputPercents(idleObject);
  1555. } else if(idleSelected == "recipes") {
  1556. outputRecipes(idleObject);
  1557. } else if(idleSelected == "artifact") {
  1558. outputArtifacts(idleObject);
  1559. } else if(idleSelected == "other") {
  1560. outputOther(idleObject);
  1561. }
  1562. }
  1563.  
  1564. function outputPercents(idleObject) {
  1565. idleSelected = "percents";
  1566. var moneyhover = idleObject.moneyhover;
  1567. var armyhover = idleObject.armyhover;
  1568. var idx = 0;
  1569. var successful = false;
  1570. var output = ''
  1571.  
  1572. if(moneyhover != null) {
  1573. output += '<table>'
  1574. output += '<thead><th align="left">Money Category Name</th><th>% of All</th></thead>'
  1575. for(idx = 2; idx < moneyhover.length; idx++) {
  1576. var percentage = Math.round(moneyhover[idx].value/moneyhover[2].value*10000)/100;
  1577. output += '<tr>'
  1578. output += '<td>' + moneyhover[idx].name + '</td>'
  1579. output += '<td>' + percentage + '%</td>'
  1580. output += '</tr>'
  1581. successful = true;
  1582. }
  1583. output += '</table>'
  1584. var mps = getMoneyPerSecond();
  1585. if(mps > 0) {
  1586. output += 'Income: ' + formatOutputMoney(mps*3600,'/hour')
  1587. output += '<br/>'
  1588. }
  1589. output += '<span style="font-style: italic">(Last Scanned: ' + getDateString(idleObject.scan_times.money_hover) + ')</span>'
  1590. } else {
  1591. output += 'Hover over the money information on the top right and click s'
  1592. }
  1593.  
  1594. output += '<br/><br/>'
  1595.  
  1596. if(armyhover != null && armyhover.length >= 2) {
  1597. var total2 = armyhover[2].value;
  1598. if(armyhover.length >= 9) {
  1599. total2 += armyhover[7].value + armyhover[8].value;
  1600. }
  1601. output += '<table>'
  1602. output += '<thead><th>Army Category Name</th><th>% of Earned</th><th>% of All</th></thead>'
  1603. for(idx = 2; idx < armyhover.length; idx++) {
  1604. if(armyhover[idx].name.indexOf("Started") == 0) {
  1605. break;
  1606. }
  1607.  
  1608. var percentage1 = Math.round(armyhover[idx].value/armyhover[2].value*10000)/100;
  1609. var percentage2 = Math.round(armyhover[idx].value/total2*10000)/100;
  1610.  
  1611. output += '<tr><td>'
  1612. if(armyhover[idx].name.toLowerCase().indexOf("joint strike") != -1
  1613. || armyhover[idx].name.toLowerCase().indexOf("hospitals") != -1) {
  1614. output += '*'
  1615. }
  1616. output += armyhover[idx].name + '</td>'
  1617. output += '<td>' + percentage1 + '%</td>'
  1618. output += '<td>' + percentage2 + '%</td>'
  1619. output += '</tr>'
  1620. successful = true;
  1621. }
  1622. output += '</table>'
  1623. var aps = getArmiesPerSecond();
  1624. if(aps > 0) {
  1625. output += 'Income: ' + formatOutputArmies(aps*3600,'/hour')
  1626. output += '<br/>'
  1627. }
  1628. output += '<span style="font-style: italic">(Last Scanned: ' + getDateString(idleObject.scan_times.army_hover) + ')</span>'
  1629. } else {
  1630. output += 'Hover over the army information on the top right and click s'
  1631. }
  1632. var idleOut = $("#IdleOutput");
  1633. if(successful) {
  1634. idleOut.html(output);
  1635. } else {
  1636. idleOut.html("Hover information not found. Hover over the top right army or income information and press s while the window is open to scan it.");
  1637. }
  1638. }
  1639.  
  1640. function outputRecipes(idleObject) {
  1641. idleSelected = "recipes";
  1642. var recipes = idleObject.recipes;
  1643. var output = '<header>Estimated Profit Per Second for various scenarios. Hover over the headers for more details.</header>'
  1644.  
  1645. output += 'As of version 5.15, these calculations are outdated. The best recipe profitability can be found by unlocking Statistics 3.<br/>'
  1646. var item_values_modifier = idleObject.item_values;
  1647. if(item_values_modifier == null) {
  1648. item_values_modifier = 100;
  1649. idleObject.item_values = item_values_modifier;
  1650. }
  1651. var cd_modifier = idleObject.craft_double;
  1652. if(cd_modifier == null) {
  1653. cd_modifier = 10;
  1654. idleObject.craft_double = cd_modifier;
  1655. }
  1656. if(showDevelopmentFeatures) {
  1657. var item_values_text = '<label for="item_values_input">Item Values Boost (Percentage):</label><input name="item_values_input" id="item_values_input" value="' + idleObject.item_values + '"/>'
  1658. output += '<br/>' + item_values_text
  1659.  
  1660. var craft_double_text = '<label for="craft_double_input">Craft Double Modifier (Percentage):</label><input name="craft_double_input" id="craft_double_input" value="' + idleObject.craft_double + '"/>'
  1661. output += '<br/>' + craft_double_text
  1662. }
  1663.  
  1664. output += '<table class="sortable jz_table"><thead>'
  1665. output += '<th title="Crafter Recipe Name">Recipe</th>'
  1666. output += '<th title="Profit per second if ingredients are purchased from the market.">Market</th>'
  1667. output += '<th title="Profit per second if ingredients are purchased from the market + ' + idleObject.craft_double + '% craft double.">Market<br/>w/Craft<br/>Double<br/>Tech</th>'
  1668. if(showDevelopmentFeatures) {
  1669. output += '<th title="Profit per second if ingredients are purchased from the market with a ' + idleObject.item_values + '% modifier to item sell values.">' + idleObject.item_values + '%</th>'
  1670. output += '<th title="Profit per second if ingredients are purchased from the market with a ' + idleObject.item_values + '% modifier to item sell values and '
  1671. output += idleObject.craft_double + '% craft double..">' + idleObject.item_values + '%<br/>w/' + idleObject.craft_double + '%<br/>Craft<br/>Double</th>'
  1672. output += '<th title="Profit per second including time to craft item ingredients. Alloys are purchased from the market when possible.">Item Ingredient<br/>Adjusted</th>'
  1673. }
  1674. output += '</thead>'
  1675. var successful = false;
  1676. var best_market_val = 0;
  1677. var best_market_name = "";
  1678. for(var recipe_idx = 0; recipe_idx < recipes.length; recipe_idx++) {
  1679. var recipe = recipes[recipe_idx];
  1680. var calcs = getRecipeCalculations(idleObject, recipe);
  1681. if(calcs == null) {
  1682. continue;
  1683. }
  1684. if(calcs.m_pps > best_market_val) {
  1685. best_market_val = calcs.m_pps;
  1686. best_market_name = recipe.name;
  1687. }
  1688. var found = false;
  1689. var positive = false;
  1690.  
  1691. var row = '<tr><td>' + recipe.name + '</td>'
  1692. if(calcs.m_pps == -1) {
  1693. row += '<td>N/A</td>'
  1694. row += '<td>N/A</td>'
  1695. if(showDevelopmentFeatures) {
  1696. row += '<td>N/A</td>'
  1697. row += '<td>N/A</td>'
  1698. }
  1699. } else {
  1700. found = true;
  1701. var val1 = calcs.m_pps;
  1702. row += '<td>' + formatOutputNumber(val1) + '</td>'
  1703. var sell_value = getItemAlloySellValueById(idleObject, recipe.id);
  1704. var craft_double = sell_value*.1/recipe.time_in_s;
  1705. var val2 = calcs.m_pps + craft_double;
  1706. row += '<td>' + formatOutputNumber(val2) + '</td>'
  1707. if(showDevelopmentFeatures) {
  1708. var boosted_sell_value = calcs.base*(idleObject.item_values/100+1);
  1709. var itemval = ((boosted_sell_value-calcs.m_i_cost)/recipe.time_in_s)
  1710. row += '<td>' + formatOutputNumber(itemval) + '</td>'
  1711. if(itemval > 0) {
  1712. positive = true;
  1713. }
  1714.  
  1715. var boosted_craft_double = boosted_sell_value*idleObject.craft_double*.01/recipe.time_in_s
  1716. var itemval_boosted = itemval + boosted_craft_double
  1717. row += '<td>' + formatOutputNumber(itemval_boosted) + '</td>'
  1718.  
  1719. if(itemval_boosted > 0) {
  1720. positive = true;
  1721. }
  1722. }
  1723. if(val1 > 0 || val2 > 0) {
  1724. positive = true;
  1725. }
  1726. }
  1727. if(showDevelopmentFeatures) {
  1728. if(recipe.missing_alloy != false && calcs.craft_pps && calcs.craft_pps != -1) {
  1729. row += '<td title="' + calcs.craft_desc + '">' + formatOutputNumber(calcs.craft_pps) + '</td>'
  1730. if(calcs.craft_pps > 0) {
  1731. positive = true;
  1732. }
  1733. } else if(calcs.craft_desc != null && calcs.craft_desc == "Missing") {
  1734. row += '<td title="Missing Ingredient\(s\)">???</td>'
  1735. found = true;
  1736. } else {
  1737. row += '<td>N/A</td></tr>'
  1738. }
  1739. }
  1740.  
  1741. if(positive || (found && recipes.length < 20)){
  1742. output += row;
  1743. successful = true;
  1744. }
  1745. }
  1746.  
  1747. idleObject.best_r_m_v = best_market_val;
  1748. idleObject.best_r_m_n = best_market_name;
  1749.  
  1750. output += '</table>'
  1751.  
  1752. output += '<span style="font-style: italic">(Last Scanned: ' + getDateString(idleObject.scan_times.recipe_crafter) + ')</span>'
  1753. var idleOut = $("#IdleOutput");
  1754. if(successful) {
  1755. idleOut.html(output);
  1756. if(showDevelopmentFeatures) {
  1757. $("#item_values_input").change(function() {
  1758. idleObject.item_values = this.value;
  1759. outputRecipes(idleObject)
  1760. });
  1761. }
  1762. $("#craft_double_input").change(function() {
  1763. idleObject.craft_double = this.value;
  1764. outputRecipes(idleObject)
  1765. });
  1766. } else {
  1767. idleOut.html('Go to your crafters and scan the Change Recipe popup to display additional recipe calculations. Only recipes that have items as ingredients or that can be crafted from market purchases will be shown here.');
  1768. }
  1769.  
  1770. }
  1771.  
  1772. function outputArtifacts(idleObject) {
  1773. idleSelected = "artifact";
  1774.  
  1775. var select_box = '<select name="artifact_rarity" id="artifact_rarity">'
  1776. select_box += '<option value="Owned">Owned</option>'
  1777. select_box += '<option value="Insane">Insane</option>'
  1778. select_box += '<option value="Legendary">Legendary</option>'
  1779. select_box += '<option value="Epic">Epic</option>'
  1780. select_box += '<option value="Rare">Rare</option>'
  1781. select_box += '<option value="Uncommon">Uncommon</option>'
  1782. select_box += '<option value="Common">Common</option>'
  1783. select_box += '<option value="Poor">Poor</option>'
  1784. select_box += '</select><br/>'
  1785.  
  1786. var output = getArtifactRecommendations(idleObject);
  1787.  
  1788. var idleOut = $("#IdleOutput");
  1789. idleOut.html(select_box + output);
  1790.  
  1791. var rarity_select = $("#artifact_rarity");
  1792. rarity_select.val(artifact_rarity);
  1793. rarity_select.change(function() {
  1794. artifact_rarity = this.value;
  1795. outputArtifacts(idleObject)
  1796. });
  1797. }
  1798.  
  1799. function outputOther(idleObject) {
  1800. idleSelected = "other";
  1801. var output = 'Estimated cost to buy all mercenaries: '
  1802. output += formatOutputMoney(idleObject.mercenaries_cost)
  1803. output += '<br/>Estimated mercenaries left to buy: '
  1804. output += formatOutputArmies(idleObject.mercenaries_sum)
  1805.  
  1806. var draftinfo = ''
  1807. var aps = getArmiesPerSecond();
  1808. var modifier = getModifierBreakdown(idleObject,"Draft Size Increased");
  1809. var draft_mod = 1;
  1810. if(modifier != null) {
  1811. draft_mod = modifier.mod_no_a;
  1812. } else {
  1813. // Try to construct the modifier
  1814. var tech_mod = 0;
  1815. if(idleObject.techs != null
  1816. && idleObject.techs.draft != null
  1817. && idleObject.techs.draft > 1) {
  1818. tech_mod = (idleObject.techs - 1)*.2
  1819. }
  1820. var ap_mod = 0;
  1821. for(var i=0;i<idlePermanent.advancements;i++) {
  1822. if(idlePermanent.advancements[i].n == "Increased Draft Sizes") {
  1823. ap_mod = parseIdleNumber(idlePermanent.advancements[i].v.replace("%",""))/100
  1824. }
  1825. }
  1826. draft_mod += tech_mod + ap_mod;
  1827. }
  1828.  
  1829.  
  1830. var arti_mod = getEquippedArtifactModifier(idleObject, "Draft Boost");
  1831. draft_mod += arti_mod;
  1832.  
  1833. if(arti_mod != null && arti_mod != null && aps != null && aps != -1) {
  1834. var fixed_draft = (90*(draft_mod)*aps);
  1835. // Max Draft: 3690 * Army Income Per Second * (1 + Modifiers)
  1836. // Fixed Draft: 90 * Army Income Per Second * (1 + Modifiers)
  1837. // Sliding Draft Percentage: 15%
  1838. draftinfo = '<br/><br/><span>Drafts consist of two pieces, a fixed portion and a sliding (variable) portion.'
  1839. draftinfo += ' These numbers are added together to determine the value of each draft.'
  1840. draftinfo += ' The total gained from the sliding portions can be up to 15% of the total armies earned.'
  1841. draftinfo += ' There is no maximum for the fixed portion total.</span>'
  1842. draftinfo += '<br/><span title="1 + Modifiers">Draft Multiplier: ' + draft_mod + '</span>'
  1843. draftinfo += '<br/><span title="Scanned Armies Per Second">Armies Per Second: '
  1844. draftinfo += formatOutputArmies(aps) + '</span>'
  1845. draftinfo += '<br/><span title="90 x Armies Per Second x Multiplier">Fixed Draft Portion: '
  1846. draftinfo += formatOutputArmies(fixed_draft) + '</span>'
  1847. draftinfo += '<br/><span title="Fixed Draft/.85 + 360 x Armies Per Second x .15/.85">Min Draft: '
  1848. draftinfo += formatOutputArmies(fixed_draft*1/.85+360*aps*.15/.85) + '</span>'
  1849. draftinfo += '<br/><span title="3690 x Armies Per Second x Multiplier">Max Draft: '
  1850. draftinfo += formatOutputArmies(3690*(draft_mod)*aps) + '</span>'
  1851.  
  1852. var earned = idleObject.armyhover[2].value;
  1853. var sliding = -1;
  1854. for(var a = 0; a < idleObject.armyhover.length; a++) {
  1855. if(idleObject.armyhover[a].name.toLowerCase().indexOf("sliding") != -1) {
  1856. sliding = idleObject.armyhover[a].value;
  1857. }
  1858. }
  1859. if(sliding >= 0) {
  1860. draftinfo += '<br/><span title="Total Armies Earned * 15% - Sliding Drafts">Sliding Draft Pool Remaining: '
  1861. draftinfo += formatOutputArmies(earned * .15 - sliding) + '</span>'
  1862. }
  1863. }
  1864. output += draftinfo
  1865.  
  1866.  
  1867. /*var num_territories = idleObject.terr_left;
  1868. if(num_territories == null) {
  1869. num_territories = 100;
  1870. idleObject.terr_left = num_territories;
  1871. }
  1872. var terr_text = '<label for="terr_left">Territories Left To Apply Hospital Upgrade To:</label><input name="terr_left" id="terr_left" value="' + num_territories + '"/>'
  1873. output += '<br/>' + terr_text + '</br>'*/
  1874.  
  1875. // Get Hospitals
  1876. var best_hospital = null;
  1877. var best_cost = -1;
  1878. var best_location = -1;
  1879. for(var h_count = 0; h_count < idleObject.hospitals.length; h_count++) {
  1880. var hospital = idleObject.hospitals[h_count];
  1881. var upgrade_cost = hospital.c;
  1882. var cost_per_army = getHospitalUpgradeEffectiveness(hospital);
  1883. if(cost_per_army != null ) {
  1884. if(best_cost == -1 || cost_per_army < best_cost) {
  1885. best_hospital = hospital;
  1886. best_cost = cost_per_army;
  1887. best_location = h_count + 1;
  1888. }
  1889. }
  1890. }
  1891.  
  1892. if(best_hospital != null) {
  1893. output += '<br/><br/>Most Efficient Hospital Upgrade: #' + best_location
  1894. output += '<span title="To compare the value of upgrading this hospital to buying mercenaries, divide the first number by the number of territories that this hospital is expected to affect">'
  1895. output += '<br/>Upgrade Value: ~' + formatOutputNumber(best_cost,2) + ' ₩/₳ for ' + formatOutputMoney(best_hospital.c)
  1896. output += '</span>'
  1897. }
  1898.  
  1899. if(showDevelopmentFeatures && drafts.length > 0) {
  1900. output += "<br/><br/>Last Few Drafts:";
  1901. output += "<table><thead><td>Armies/sec</td><td>Total Earned</td><td>Draft</td><td>Drafted</td><td>Multiplier</td></thead>"
  1902. var start = 0;
  1903. if(drafts.length > 8) {
  1904. start = drafts.length - 8;
  1905. }
  1906. for(var d_count = start; d_count < drafts.length; d_count++) {
  1907. output += '<tr><td>' + formatOutputNumber(drafts[d_count].aps,2,true)+ '</td><td>'
  1908. + formatOutputNumber(drafts[d_count].tot,2,true) + '</td><td>'
  1909. + formatOutputNumber(drafts[d_count].dft,2,true) + '</td><td>'
  1910. + formatOutputNumber(drafts[d_count].dftd,2,true) + '</td><td>'
  1911. + formatOutputNumber(drafts[d_count].dft/drafts[d_count].aps,1,true) + '</td></tr>';
  1912. }
  1913. output += "</table>";
  1914. }
  1915. var idleOut = $("#IdleOutput");
  1916. idleOut.html(output);
  1917.  
  1918.  
  1919. /*$("#terr_left").change(function() {
  1920. idleObject.terr_left = this.value;
  1921. outputOther(idleObject)
  1922. });*/
  1923.  
  1924. }
  1925.  
  1926. function getHospitalUpgradeEffectiveness(hospital) {
  1927. var upgrade_cost = hospital.c;
  1928. var saves2 = hospital.s2;
  1929. var level = hospital.l;
  1930.  
  1931. if(upgrade_cost != -1) {
  1932. // y = (ax^2 + bx + c) * base
  1933. var a = 0.3;
  1934. var b = 0.0;
  1935. var c = 0.7;
  1936. var x = level;
  1937. var x2 = x + 1.0;
  1938. var y_old = a*x*x + b*x + c;
  1939. var y_new = a*x2*x2 + b*x2 + c;
  1940. var base = saves2/y_old
  1941. // This is what we need to multiply the base by
  1942. var upgrade_diff = y_new - y_old;
  1943.  
  1944. var cost_per_army = upgrade_cost / (upgrade_diff * base)
  1945. return cost_per_army;
  1946. }
  1947. return null;
  1948. }
  1949.  
  1950. function getArtifactRecommendations(idleObject) {
  1951. var armies_per_second = getArmiesPerSecond(idleObject);
  1952. //if(idleObject.modifiers == null || idleObject.modifiers.length == 0 || armies_per_second == null) {
  1953. if(armies_per_second == null) {
  1954. return 'Scan the Modifiers \(Statistics 2\), Change Recipe \(crafter\), and Armies Per Second pop-ups to compare artifact effects.'
  1955. }
  1956. if(artifact_rarity == "Owned" && idlePermanent.artifacts.length == 0) {
  1957. return 'Scan your artifacts to see personalized artifact results'
  1958. }
  1959.  
  1960. var army_camp_boost_bonus = 0.0;
  1961. var output = ''
  1962.  
  1963. // Set the rarity for the comparisons;
  1964. output += '<header style="font-weight:bold">' + artifact_rarity + ' Artifact Comparison \(selected artifacts\)</header>'
  1965. var mod_breakdown = getModifierBreakdown(idleObject, "Army Camp Production");
  1966. // Get the artifact boost at the test rarity
  1967. var test_art_boost = findArtifactValue("Army Camp Boost", artifact_rarity);
  1968. if(mod_breakdown != null && test_art_boost.v > 0) {
  1969.  
  1970. // Get the adjusted percent boost that the test rarity will provide
  1971. var art_bonus_percent = (test_art_boost.v)/(mod_breakdown.mod_no_a)*100;
  1972. var mod_w_artifact = mod_breakdown.mod_no_a + test_art_boost.v;
  1973. var arti_mod_acb = getEquippedArtifactModifier(idleObject, "Army Camp Boost");
  1974. army_camp_boost_bonus = armies_per_second / (mod_breakdown.mod_no_a + arti_mod_acb) * test_art_boost.v;
  1975. output += '<br/>' + colorArtifactText(test_art_boost.r) + ' Army Camp Boost: '
  1976. output += formatOutputArmies(army_camp_boost_bonus,'/sec') + ', '
  1977. output += formatOutputNumber(art_bonus_percent,2) + '% increase'
  1978. }
  1979.  
  1980. var speedy_c_test = findArtifactValue("Speedy Crafters", artifact_rarity);
  1981. var c_double = findArtifactValue("Craft Double", artifact_rarity);
  1982. if(speedy_c_test.v > 0) {
  1983. var sc_breakdown = getModifierBreakdown(idleObject, "Crafter Speed");
  1984. var best = findBestMarketRecipe(idleObject, true);
  1985. var pps = best.value;
  1986. var craft_double_w_speedy = best.calcs.m_pps_cd_arti;
  1987.  
  1988. var craft_time_w_speedy = best.time;
  1989. // The value for speedy crafters is easier to calculate if we assume it's equipped.
  1990. if(sc_breakdown.artifact != speedy_c_test.v) {
  1991. // Adjust the craft time as if speedy crafters were equipped
  1992. var time_multiplier = (1-speedy_c_test.v)/(1-sc_breakdown.artifact);
  1993. craft_time_w_speedy = best.time * time_multiplier;
  1994. pps = pps / time_multiplier;
  1995. craft_double_w_speedy = craft_double_w_speedy / time_multiplier;
  1996. }
  1997.  
  1998. var multiplier = speedy_c_test.v;
  1999. //var craft_double_w_speedy = best.sell/craft_time_w_speedy*c_double.v;
  2000.  
  2001. var name = best.name;
  2002. if(name != null && name.length > 0 && best.value > 0) {
  2003. output += '<br/><span title="Purchase ingredients for ' + name + ' from the market and craft for profit.'
  2004. output += ' This shows the value added by equipping the Speedy Crafters artifact.'
  2005. output += ' The calculation assumes that the ' + best.calcs.rarity_iv + ' Item Values artifact is equipped'
  2006. output += ' and includes a craft double modifier of ' + best.calcs.mod_cd + '.">'
  2007. output += colorArtifactText(speedy_c_test.r) + ' Speedy Crafters: '
  2008. output += '+' + formatOutputMoney(pps*multiplier)
  2009. output += ' x ' + idleObject.num_cftr + ' crafter(s) = '
  2010. output += '+' + formatOutputMoney(pps*multiplier*idleObject.num_cftr,'/sec')
  2011. output += ' for ' + name + '</span>'
  2012. output += '<br/><span title="Purchase ingredients for ' + name + ' from the market and craft for profit.'
  2013. output += ' This shows the value added by equipping the Craft Double artifact.'
  2014. output += ' The calculation assumes that the ' + best.calcs.rarity_iv + ' Item Values and ' + speedy_c_test.r + ' Speedy Crafters artifacts are equipped.">'
  2015. output += colorArtifactText(best.calcs.rarity_cd) + ' Craft Double \(if Speedy Crafters equipped\): '
  2016. output += '+' + formatOutputMoney(craft_double_w_speedy)
  2017. output += ' x ' + idleObject.num_cftr + ' = '
  2018. output += '+' + formatOutputMoney(craft_double_w_speedy*idleObject.num_cftr, '/sec')
  2019. output += ' for ' + name + '</span>'
  2020. }
  2021. }
  2022.  
  2023. if(showDevelopmentFeatures) {
  2024. var mps = getMoneyPerSecond();
  2025. var art_bmb = findArtifactValue("Bonus Money Boost", artifact_rarity);
  2026. var art_tmb = findArtifactValue("Territory Money Boost", artifact_rarity);
  2027. if(idleObject.bonusMoney != null && mps != null && mps > 0) {
  2028. if(art_bmb != null && art_bmb.r != null) {
  2029. var bmb_val = idleObject.bonusMoney * art_bmb.v;
  2030. output += '<br/>' + colorArtifactText(art_bmb.r) + ' Bonus Money Boost: '
  2031. output += '+' + formatOutputMoney(bmb_val, '/sec')
  2032. }
  2033. if(art_tmb != null && art_tmb.r != null) {
  2034. // Get the actual bonus money boost
  2035. var mfb_mod = getModifierBreakdown(idleObject, "Money from Bonuses");
  2036. var arti_mod = getEquippedArtifactModifier(idleObject, "Bonus Money Boost");
  2037. var bonusMoney = idleObject.bonusMoney * (mfb_mod.mod_no_a + arti_mod);
  2038.  
  2039. // Calculate the territory money boost
  2040. var terr_money = mps - bonusMoney;
  2041. var mft_mod = getModifierBreakdown(idleObject, "Money from Territories");
  2042. var arti_mft_mod = getEquippedArtifactModifier(idleObject, "Territory Money Boost");
  2043. var terr_money_base = terr_money/(mft_mod.mod_no_a + arti_mft_mod);
  2044.  
  2045. var tmb_val = terr_money_base * art_tmb.v;
  2046. output += '<br/>' + colorArtifactText(art_tmb.r) + ' Territory Money Boost: '
  2047. output += '+' + formatOutputMoney(tmb_val, '/sec')
  2048. }
  2049. }
  2050. }
  2051.  
  2052. var cooldown = 16*60*60;
  2053. var cooldown_rate_adj = getModifierBreakdown(idleObject, "Artifact Cooldown Speed");
  2054. if(cooldown_rate_adj != null) {
  2055. cooldown *= cooldown_rate_adj.mod;
  2056. }
  2057.  
  2058. output += '<br/><br/><header style="font-weight:bold">Activated Artifacts (for ' + formatOutputNumber(cooldown/60/60) + ' hour cooldown)</header>'
  2059.  
  2060. var supercharge_army = findArtifactValue("Supercharge Army Camp", artifact_rarity);
  2061. var best_camp = 0;
  2062. for(var i = 0; i < idleObject.camps.length; i++) {
  2063. if(idleObject.camps[i].armies_per_s > best_camp) {
  2064. best_camp = idleObject.camps[i].armies_per_s;
  2065. }
  2066. }
  2067. if(supercharge_army != null && supercharge_army.r != null && best_camp > 0) {
  2068. output += colorArtifactText(supercharge_army.r) + ' Supercharge Army Camp for best camp: '
  2069. output += '+' + formatOutputArmies(best_camp*19*supercharge_army.v/cooldown*60, '/sec')
  2070. }
  2071.  
  2072. var q_strike = findArtifactValue("Quadruple Strike", artifact_rarity);
  2073. var t_strike = findArtifactValue("Triple Strike", artifact_rarity);
  2074. var field = findArtifactValue("Field Hospital", artifact_rarity);
  2075. var joint_strike = getModifierBreakdown(idleObject, "Joint Strike");
  2076. if(joint_strike != null) {
  2077. var armies_per_cooldown = army_camp_boost_bonus * cooldown;
  2078. var js_adjusted = armies_per_cooldown / joint_strike.mod;
  2079.  
  2080. var hover = 'These are calculated based on the current values for army camps and assume only one level is being played at once. '
  2081. hover += 'Because army camps will increase over the 16 hour cooldown period, it is recommended to use these activated artifacts only '
  2082. hover += 'when the territory capture costs greatly exceed the values displayed here. Hospital retention varies by territory. Check '
  2083. hover += 'to see how many armies will be retained by hospitals. Next, add that to the territory cost to get the actual territory cost '
  2084. hover += 'that would match the current armies per second from camps over the cooldown period.'
  2085.  
  2086. output += '<br/><br/><span id="artifacts_activated_capture" title="' + hover + '">'
  2087. output += '<header style="text-decoration:underline">Territory size to match the current effect of '
  2088. output += colorArtifactText(test_art_boost.r) + ' Army Camp Boost over the cooldown period (mouse over for more info):</header>'
  2089.  
  2090. if(q_strike.v > 0) {
  2091. if(q_strike.v > 1) {
  2092. q_strike.v = 1;
  2093. }
  2094. if(q_strike != -1) {
  2095. var q_adjusted = js_adjusted / q_strike.v;
  2096. output += colorArtifactText(q_strike.r) + ' Quadruple Strike: ';
  2097. output += formatOutputArmies(q_adjusted) + ' + retained by hospitals'
  2098. }
  2099. }
  2100.  
  2101. if(t_strike.v > 0) {
  2102. if(t_strike.v > 1) {
  2103. t_strike.v = 1;
  2104. }
  2105. if(t_strike != -1) {
  2106. var t_adjusted = js_adjusted / t_strike.v;
  2107. output += '<br/>' + colorArtifactText(t_strike.r) + ' Triple Strike: '
  2108. output += formatOutputArmies(t_adjusted) + ' + retained by hospitals'
  2109. }
  2110. }
  2111.  
  2112. if(field.v > 0) {
  2113. var f_adjusted = js_adjusted / field.v;
  2114. output += '<br/>' + colorArtifactText(field.r) + ' Field Hospital: '
  2115. output += formatOutputArmies(f_adjusted) + ' + retained by hospitals'
  2116. }
  2117. output += '</span>'
  2118.  
  2119. if(idleObject.last_terr != null) {
  2120. output += '<br/><span title="Artifact Effects for the selected territory, converted to armies per second over the cooldown period. '
  2121. output += 'To obtain the amount saved, subtract armies saved from Hospitals and Joint Strike from the territory cost, then multiply the result by the artifact effect.">'
  2122. var cost_to_take = (idleObject.last_terr.c - idleObject.last_terr.h);
  2123. var q_saves = cost_to_take * joint_strike.mod * q_strike.v;
  2124. var t_saves = cost_to_take * joint_strike.mod * t_strike.v;
  2125. output += '<br/>Artifact effects for the territory ' + idleObject.last_terr.n + ':'
  2126. output += '<br/>' + colorArtifactText(q_strike.r) + ' Quadruple Strike: Saves '
  2127. output += formatOutputArmies(q_saves)
  2128. output += ' (' + formatOutputArmies(q_saves/cooldown) + '/sec)'
  2129. output += '<br/>' + colorArtifactText(t_strike.r) + ' Triple Strike: Saves '
  2130. output += formatOutputArmies(t_saves)
  2131. output += ' (' + formatOutputArmies(t_saves/cooldown) + '/sec)'
  2132. } else {
  2133. output += '<br/><br/>Select an unfogged territory on the map and press "s" to see how many armies would be saved by selected active artifacts for that territory.';
  2134. }
  2135. }
  2136.  
  2137. output += '<br/>'
  2138. output += '<br/><span style="font-style: italic">(Artifacts Last Scanned: ' + getDateString(idlePermanent.scan_times.artifacts) + ')</span>'
  2139. output += '<br/><span style="font-style: italic">(Crafter Recipes Last Scanned: ' + getDateString(idleObject.scan_times.recipe_crafter) + ')</span>'
  2140. output += '<br/><span style="font-style: italic">(Modifiers Last Scanned: ' + getDateString(idleObject.scan_times.modifiers) + ')</span>'
  2141. output += '<br/><span style="font-style: italic">(Army Stats Last Scanned: ' + getDateString(idleObject.scan_times.army_hover) + ')</span>'
  2142. return output;
  2143. }
  2144.  
  2145. function colorArtifactText(rarity) {
  2146. if(rarity == null) {
  2147. return '<span>Not Found</span>'
  2148. }
  2149. var color = "#000";
  2150. switch(rarity){
  2151. case "Insane":
  2152. color = "#FF0";
  2153. break;
  2154. case "Legendary":
  2155. color = "#F80";
  2156. break;
  2157. case "Epic":
  2158. color = "rgb(255, 0, 237)";
  2159. break;
  2160. case "Uncommon":
  2161. color = "#080";
  2162. break;
  2163. case "Common":
  2164. color = "#FFF";
  2165. break;
  2166. case "Poor":
  2167. color = "#888";
  2168. break;
  2169. }
  2170. return '<span class="artifact_' + rarity.toLowerCase() + '">' + rarity + '</span>'
  2171. }
  2172.  
  2173. function getBestOwnedArtifact(name, owned) {
  2174. var rarities = ["Poor","Common","Uncommon","Rare","Epic","Legendary","Insane"];
  2175.  
  2176. var rarity_idx = -1;
  2177. for(var r = 0; r < owned.length; r++) {
  2178. if(owned[r].n == name) {
  2179. var rarity_idx_tmp = rarities.indexOf(owned[r].r);
  2180. if(rarity_idx_tmp > rarity_idx) {
  2181. rarity_idx = rarity_idx_tmp;
  2182. }
  2183. }
  2184. }
  2185.  
  2186. if(rarity_idx == -1) {
  2187. return null;
  2188. }
  2189. return rarities[rarity_idx];
  2190. }
  2191.  
  2192. function findArtifactValue(name, rarity_in, backup_rarity) {
  2193. var rarities = ["Poor","Common","Uncommon","Rare","Epic","Legendary","Insane"];
  2194.  
  2195. var rarity = rarity_in;
  2196. if(rarity_in == "Owned") {
  2197. var owned = idlePermanent.artifacts;
  2198. rarity = getBestOwnedArtifact(name, owned);
  2199. }
  2200. var rarity_idx = rarities.indexOf(rarity);
  2201. if(rarity_idx == -1) {
  2202. return {
  2203. "n":name,
  2204. "r":null,
  2205. "v":0
  2206. };
  2207. }
  2208. var value = -1;
  2209. for (var i = 0; i < artifacts_list.length; i++) {
  2210. if(artifacts_list[i].name == name) {
  2211. if(artifacts_list[i].value.length > rarity_idx) {
  2212. value = artifacts_list[i].value[rarity_idx];
  2213. return {
  2214. "n":name,
  2215. "r":rarity,
  2216. "v":value,
  2217. "t":artifacts_list[i].type
  2218. };
  2219. } else {
  2220. value = artifacts_list[i].value[0] * Math.pow(2,rarity_idx);
  2221. return {
  2222. "n":name,
  2223. "r":rarity,
  2224. "v":value,
  2225. "t":artifacts_list[i].type
  2226. };
  2227. }
  2228. }
  2229. }
  2230. return {
  2231. "n":name,
  2232. "r":rarity,
  2233. "v":value
  2234. };
  2235. }
  2236.  
  2237. function formatOutputMoney(number, tag) {
  2238. var value = formatOutputNumber(number);
  2239. if(tag != null) {
  2240. value += tag;
  2241. }
  2242. return '<span style="color: #BDAB27">₩' + value + '</span>'
  2243. }
  2244.  
  2245. function formatOutputArmies(number, tag) {
  2246. var value = formatOutputNumber(number);
  2247. if(tag != null) {
  2248. value += tag;
  2249. }
  2250. return '<span style="color: #3DB8FF">₳' + value + '</span>'
  2251. }
  2252.  
  2253. function formatOutputNumber(number, places, show_all) {
  2254. if(!places) {
  2255. places = 4
  2256. }
  2257. var multiplier = Math.pow(10,places);
  2258. if(show_all) {
  2259. return new Intl.NumberFormat().format(Math.round( number * multiplier) / multiplier);
  2260. }
  2261. if(Math.abs(number) >= 1.0E15) {
  2262. return Math.round( number / 1.0E15 * multiplier) / multiplier + "P";
  2263. } else if(Math.abs(number) >= 1.0E12) {
  2264. return Math.round( number / 1.0E12 * multiplier) / multiplier + "T";
  2265. } else if(Math.abs(number) >= 1.0E9) {
  2266. return Math.round( number / 1.0E9 * multiplier) / multiplier + "B";
  2267. } else if(Math.abs(number) >= 1.0E6) {
  2268. return Math.round( number / 1.0E6 * multiplier) / multiplier + "M";
  2269. } else if(Math.abs(number) >= 1.0E3) {
  2270. return Math.round( number / 1.0E3 * multiplier) / multiplier + "K";
  2271. }
  2272. return new Intl.NumberFormat().format(Math.round( number * multiplier) / multiplier);
  2273. }
  2274.  
  2275. function getDateString(input) {
  2276. if(input == "Never") {
  2277. return "Never";
  2278. }
  2279. var datestring = (new Date(input)).toString();
  2280. if(datestring.indexOf(" GMT") != -1) {
  2281. datestring = datestring.substring(0, datestring.indexOf(" GMT"));
  2282. }
  2283. return datestring;
  2284. }
  2285.  
  2286. function findBestMarketRecipe(idleObject, artifact_adjust) {
  2287. var best_market_val = 0;
  2288. var best_market_name = "";
  2289. var best_market_sell_value = 0.0;
  2290. var best_market_time = 0.0;
  2291. var best_calcs = null;
  2292. for(var recipe_idx = 0; recipe_idx < idleObject.recipes.length; recipe_idx++) {
  2293. var recipe = idleObject.recipes[recipe_idx];
  2294. var calcs = getRecipeCalculations(idleObject, recipe);
  2295. if(calcs == null) {
  2296. continue;
  2297. }
  2298. var pps = calcs.m_pps;
  2299.  
  2300. if(artifact_adjust) {
  2301. // Include the contribution from craft double techs and the item values artifact
  2302. pps = calcs.m_pps_iv + calcs.m_pps_cd;
  2303. }
  2304.  
  2305. if(pps > best_market_val) {
  2306. best_market_val = pps;
  2307. best_market_name = recipe.name;
  2308. best_market_sell_value = getItemAlloySellValueById(idleObject, recipe.id);
  2309. if(artifact_adjust) {
  2310. best_market_sell_value = calcs.modified;
  2311. }
  2312. best_market_time = recipe.time_in_s;
  2313. best_calcs = calcs;
  2314. }
  2315. }
  2316. return {"name":best_market_name,"value":best_market_val,"sell":best_market_sell_value,"time":best_market_time,"calcs":best_calcs}
  2317. }
  2318.  
  2319. function getArmiesPerSecond() {
  2320. if(idleObject.armies_ps != null && idleObject.armies_ps > 0) {
  2321. return idleObject.armies_ps;
  2322. }
  2323. return null;
  2324. }
  2325.  
  2326. function getMoneyPerSecond() {
  2327. if(idleObject.money_ps != null && idleObject.money_ps > 0) {
  2328. return idleObject.money_ps;
  2329. }
  2330. return null;
  2331. }
  2332.  
  2333. function getModifierBreakdown(idleObject, name) {
  2334. var modifier = findModifier(idleObject, name);
  2335. if(modifier != null) {
  2336. var modNumberNoArtifact = 1.0;
  2337. var type = null;
  2338. var artifact_val = 0.0;
  2339. for(var i = 0; i < modifier.det.length; i++) {
  2340. var detail = modifier.det[i];
  2341. var numVal = 0;
  2342. if(detail.value.indexOf("%") != -1) {
  2343. numVal = parseIdleNumber(detail.value.substring(1,detail.value.indexOf("%")))/100;
  2344. } else {
  2345. numVal = parseIdleNumber(detail.value.substring(1));
  2346. }
  2347.  
  2348. if(detail.value.indexOf("+") == 0) {
  2349. type = "+";
  2350. } else if(detail.value.indexOf("x") == 0) {
  2351. type = "x";
  2352. }
  2353. if(detail.name.indexOf("Artifact") == -1) {
  2354. if(type == "+") {
  2355. modNumberNoArtifact += numVal;
  2356. } else if(type == "x") {
  2357. modNumberNoArtifact *= (1-numVal);
  2358. }
  2359. } else {
  2360. artifact_val = numVal;
  2361. }
  2362. }
  2363. var mod = modNumberNoArtifact;
  2364. if(type == "+") {
  2365. mod += artifact_val;
  2366. } else if(type == "x") {
  2367. mod *= (1-artifact_val);
  2368. }
  2369. return {"mod":mod,"type":type,"mod_no_a":modNumberNoArtifact,"artifact":artifact_val}
  2370. }
  2371. return {"mod":1.0,"type":"?","mod_no_a":1.0,"artifact":0.0}
  2372. }
  2373.  
  2374. function findModifier(idleObject, name) {
  2375. var list = idleObject.modifiers;
  2376. for (var i = 0; i < list.length; i++) {
  2377. var modifier = list[i];
  2378. if(modifier.name == name) {
  2379. return modifier;
  2380. }
  2381. }
  2382. return null;
  2383. }
  2384.  
  2385. // Gets the modifier from an equipped artifact
  2386. function getEquippedArtifactModifier(idleObject, name) {
  2387. var arti_mod = 0;
  2388. if(idleObject.artifacts_equipped != null) {
  2389. for(var a_count = 0; a_count < idleObject.artifacts_equipped.length; a_count++) {
  2390. var arti = idleObject.artifacts_equipped[a_count];
  2391. if(arti.n == name) {
  2392. arti_mod = findArtifactValue(arti.n, arti.r).v
  2393. }
  2394. }
  2395. }
  2396. return arti_mod;
  2397. }
  2398.  
  2399. // Add the effect of the artifact if it wasn't equipped
  2400. /*function getBestArtifactModifier(mod, name, rarity) {
  2401. if(mod.mod != mod.mod_no_a) {
  2402. // Artifact was equipped
  2403. return mod.mod;
  2404. }
  2405. if(rarity == null) {
  2406. rarity = "Owned";
  2407. }
  2408. var artifact = findArtifactValue(name, rarity);
  2409. if(artifact == null && artifact.v == null) {
  2410. return mod.mod;
  2411. }
  2412. var type = mod.type;
  2413. if(type == null) {
  2414. type = artifact.t;
  2415. }
  2416. if(type == null) {
  2417. type = "+";
  2418. }
  2419. if(type == "+") {
  2420. return mod.mod_no_a + artifact.v;
  2421. } else if (type == "x") {
  2422. return mod.mod_no_a * (1-artifact.v);
  2423. }
  2424. }*/
  2425.  
  2426. function getRecipeCalculations(idleObject, recipe) {
  2427. var ing_ids = recipe.ing_ids;
  2428. var ing_qtys = recipe.ing_qtys;
  2429. var ing_market_cost_sum = 0.0;
  2430. var ing_sell_value_sum = 0.0;
  2431. var ing_cost_sum = 0.0;
  2432. var ing_time_sum = 0.0;
  2433. var ing_cost_time_success = true;
  2434. var craft_desc = "";
  2435. var hasItemIngredient = false;
  2436. for(var i = 0; i < ing_ids.length; i++) {
  2437. var ing_id = ing_ids[i];
  2438. var num = ing_qtys[i];
  2439. var ing_qty = parseIdleNumber(num);
  2440.  
  2441. // Find the cost to buy this ingredient from the market
  2442. var market_cost = -1;
  2443. var idx = idleObject.market_resource_ids.indexOf(ing_id);
  2444. if(idx != -1 && ing_market_cost_sum >= 0) {
  2445. var ing_cost = idleObject.market_resources[idx].cost;
  2446. if(ing_cost != -1 && ing_qty != -1) {
  2447. market_cost = ing_cost*ing_qty;
  2448. // Add the value to the sum
  2449. ing_market_cost_sum += market_cost;
  2450. }
  2451. } else {
  2452. ing_market_cost_sum = -1;
  2453. }
  2454.  
  2455. // Find the sell value for this ingredient
  2456. var ing_sell_value = getItemAlloySellValueById(idleObject, ing_id)*ing_qty;
  2457. if(ing_sell_value_sum >= 0 && ing_sell_value > 0) {
  2458. // Add the value to the sum
  2459. ing_sell_value_sum += ing_sell_value;
  2460. }
  2461.  
  2462. if(ing_id.indexOf("MetalBar") == -1) {
  2463. hasItemIngredient = true;
  2464. }
  2465. // Create the complicated calculation
  2466. var childRecipe = getRecipe(ing_id);
  2467. if(childRecipe != null) {
  2468. // Item Ingredient, Make it
  2469. hasItemIngredient = true;
  2470. var childcalcs = getRecipeCalculations(idleObject, childRecipe);
  2471.  
  2472. if(craft_desc.length != 0) {
  2473. craft_desc += " + ";
  2474. }
  2475. // Buy ingredients for ingredient
  2476. var child_ing_cost = childcalcs.m_i_cost;
  2477. if(child_ing_cost != -1) {
  2478. craft_desc += child_ing_cost + " spent on ingredients for " + childRecipe.name + " *" + ing_qty;
  2479. ing_cost_sum += child_ing_cost*ing_qty;
  2480. } else {
  2481. // Can't buy ingredients, use sell value of the item.
  2482. recipe.missing_alloy = true;
  2483. var childValue = getItemAlloySellValueById(idleObject, childRecipe.id);
  2484. craft_desc += childValue + " to sell " + childRecipe.name + "*" + ing_qty;
  2485. ing_cost_sum += childValue*ing_qty;
  2486. // Skip it
  2487. ing_cost_time_success = false;
  2488. }
  2489.  
  2490. if(childRecipe.time_in_s != -1) {
  2491. ing_time_sum += childRecipe.time_in_s*ing_qty;
  2492. }
  2493. } else {
  2494. if(craft_desc.length != 0) {
  2495. craft_desc += " + ";
  2496. }
  2497. // Alloy Ingredient, Purchase it
  2498. if(market_cost != -1) {
  2499. craft_desc += market_cost + " purchased";
  2500. ing_cost_sum += market_cost;
  2501. } else if(ing_sell_value > 0) {
  2502. // If it can't be purchased, smelt it.
  2503. // Add the value to the sum
  2504. craft_desc += ing_sell_value + " smelted";
  2505. ing_cost_sum += ing_sell_value;
  2506. } else {
  2507. ing_cost_time_success = false;
  2508. }
  2509. }
  2510. }
  2511.  
  2512. var market_profit = -1;
  2513. var market_profit_per_s = -1;
  2514. var market_profit_per_s_iv = -1;
  2515. var market_profit_per_s_adj = -1;
  2516. var market_profit_per_s_cd = -1;
  2517. var market_profit_per_s_cd_artifact = -1;
  2518. var value = getItemAlloySellValueById(idleObject, recipe.id);
  2519. var base = -1;
  2520. var modified = -1;
  2521. var best_iv = findArtifactValue("Item Values", artifact_rarity);
  2522. var mod_iv = getModifierBreakdown(idleObject, "Item Sell Values");
  2523. var arti_mod = getEquippedArtifactModifier(idleObject, "Item Values");
  2524. var best_cd = findArtifactValue("Craft Double", artifact_rarity);
  2525. var mod_cd = getModifierBreakdown(idleObject, "Chance of Crafting Double");
  2526. var mod_cd_no_a = Math.round((1 - mod_cd.mod_no_a)*10000)/10000;
  2527. if(ing_market_cost_sum != -1 && value != -1) {
  2528. base = value/(mod_iv.mod_no_a + arti_mod);
  2529.  
  2530. market_profit = value - ing_market_cost_sum;
  2531. market_profit_per_s = market_profit / recipe.time_in_s;
  2532.  
  2533. if(best_iv != null && best_iv.v != null) {
  2534. modified = base * (mod_iv.mod_no_a + best_iv.v);
  2535. var market_profit_iv = modified - ing_market_cost_sum
  2536. market_profit_per_s_iv = market_profit_iv / recipe.time_in_s
  2537.  
  2538. var market_profit_from_cd = modified * mod_cd_no_a;
  2539. market_profit_per_s_cd = market_profit_from_cd / recipe.time_in_s
  2540.  
  2541. var cd_artifact_value = 1-(1-mod_cd_no_a)*(1-best_cd.v)-mod_cd_no_a
  2542. market_profit_per_s_cd_artifact = modified * cd_artifact_value / recipe.time_in_s
  2543.  
  2544. market_profit_per_s_adj = market_profit_per_s_iv + market_profit_per_s_cd;
  2545. }
  2546. }
  2547.  
  2548. var craft_pps = -1;
  2549. if(hasItemIngredient) {
  2550. if(ing_cost_time_success) {
  2551. var total_time = ing_time_sum + recipe.time_in_s;
  2552. craft_desc = "\(" + value + " - \(" + craft_desc + "\)\)/" + total_time;
  2553. var profit = value - ing_cost_sum;
  2554. craft_pps = profit/total_time
  2555. } else {
  2556. craft_desc = "Missing";
  2557. }
  2558. }
  2559.  
  2560. var calc = {
  2561. "base": base,
  2562. "modified":modified,
  2563. "i_value": ing_sell_value_sum,
  2564. "m_i_cost": ing_market_cost_sum,
  2565. "m_profit": market_profit,
  2566. "m_pps": market_profit_per_s,
  2567. "m_pps_iv": market_profit_per_s_iv,
  2568. "m_pps_cd": market_profit_per_s_cd,
  2569. "m_pps_cd_arti": market_profit_per_s_cd_artifact,
  2570. "rarity_cd": best_cd.r,
  2571. "rarity_iv": best_iv.r,
  2572. "mod_cd": mod_cd_no_a,
  2573. "m_pps_adj": market_profit_per_s_adj,
  2574. "i_craft_t": ing_time_sum,
  2575. "i_craft_c": ing_cost_sum,
  2576. "craft_pps": craft_pps,
  2577. "craft_desc": craft_desc
  2578. }
  2579. return calc;
  2580. }
  2581.  
  2582. function getItemAlloySellValueById(idleObject, item) {
  2583. var items_alloys = idleObject.items_alloys;
  2584. for(var i = 0; i < items_alloys.length; i++) {
  2585. var item_alloy = items_alloys[i];
  2586. if(item_alloy.id == item) {
  2587. return item_alloy.price;
  2588. }
  2589. }
  2590. return -1;
  2591. }
  2592.  
  2593. function getRecipe(id) {
  2594. var recipes = idleObject.recipes;
  2595. for(var r_count = 0; r_count <recipes.length; r_count++) {
  2596. var recipe = recipes[r_count];
  2597. if(recipe.id == id) {
  2598. return recipe;
  2599. }
  2600. }
  2601. return null;
  2602. }
  2603.  
  2604. // **************** Save/Load Idle Data ****************
  2605. function setIdlePermanentFromStorage() {
  2606. var jsonString = localStorage.getItem("idlePermanent");
  2607. if(jsonString != null) {
  2608. idlePermanent = JSON.parse(jsonString);
  2609. } else {
  2610. idlePermanent = getNewIdlePermanent();
  2611. saveIdlePermanentToStorage();
  2612. }
  2613. }
  2614.  
  2615. function getNewIdlePermanent() {
  2616. var scan_times = {
  2617. "artifacts":"Never",
  2618. "advancements":"Never"};
  2619.  
  2620. var idlePermanent = {
  2621. "artifacts":[],
  2622. "advancements":[],
  2623. "scan_times":scan_times
  2624. }
  2625. return idlePermanent;
  2626. }
  2627.  
  2628. function saveIdlePermanentToStorage() {
  2629. localStorage.setItem("idlePermanent", JSON.stringify(idlePermanent));
  2630. }
  2631.  
  2632.  
  2633. function getIdleObjectFromStorage() {
  2634. var jsonString = localStorage.getItem("idleObject");
  2635. if(jsonString != null) {
  2636. return JSON.parse(jsonString);
  2637. } else {
  2638. return getNewIdleObject();
  2639. }
  2640. }
  2641.  
  2642. function getNewIdleObject() {
  2643. var idleObject = {
  2644. "level":null,
  2645. "camps":[],
  2646. "hospitals":[],
  2647. "mercenaries":[],
  2648. "modifiers":[],
  2649. "mines":[],
  2650. "ores":[],
  2651. "items_alloys":[],
  2652. "market_resource_ids":[],
  2653. "market_resources":[],
  2654. "recipes":[],
  2655. "techs":[],
  2656. "powers":[],
  2657. "scan_times":createScanTimes()
  2658. }
  2659. return idleObject;
  2660. }
  2661.  
  2662. function createScanTimes() {
  2663. var scan_times = {
  2664. "tabs":"Never",
  2665. "army_hover":"Never",
  2666. "money_hover":"Never",
  2667. "modifiers":"Never",
  2668. "recipe_crafter":"Never",
  2669. "recipe_smelter":"Never"};
  2670. return scan_times;
  2671. }
  2672.  
  2673. function saveIdleObjectToStorage(jsonObject) {
  2674. localStorage.setItem("idleObject", JSON.stringify(jsonObject));
  2675. }
  2676.  
  2677. function removeIdleObjectFromArchive(level) {
  2678. var archive = getIdleObjectArchiveFromStorage();
  2679. for(var i = 0; i < archive.length; i++) {
  2680. if(archive[i].level == level) {
  2681. archive.splice(i,1);
  2682. i--;
  2683. }
  2684. }
  2685. saveIdleObjectArchiveToStorage(archive);
  2686. }
  2687.  
  2688. function viewIdleObjectFromArchive(level) {
  2689. var archive = getIdleObjectArchiveFromStorage();
  2690. for(var i = 0; i < archive.length; i++) {
  2691. if(archive[i].level == level) {
  2692. var idleString = JSON.stringify(archive[i], null, 2);
  2693. var displayBoxName = $("#json_title").text("JSON for " + archive[i].level);
  2694. var displayBox = $("#IdleJSONOutput");
  2695. displayBox.val(idleString);
  2696. displayBox.parent().show();
  2697. }
  2698. }
  2699. }
  2700.  
  2701. function archiveIdleObject(idleObject) {
  2702. if(idleObject.level == null || idleObject.level.length == 0) {
  2703. console.log("Error Archiving: Idle Object Empty");
  2704. return;
  2705. }
  2706. var archive = getIdleObjectArchiveFromStorage();
  2707. for(var i = 0; i < archive.length; i++) {
  2708. if(archive[i].level == idleObject.level) {
  2709. archive[i] = idleObject;
  2710. saveIdleObjectArchiveToStorage(archive);
  2711. return;
  2712. }
  2713. }
  2714. archive.push(idleObject);
  2715. saveIdleObjectArchiveToStorage(archive);
  2716. }
  2717.  
  2718. function getArchivedIdleObject(level) {
  2719. var archive = getIdleObjectArchiveFromStorage();
  2720. for(var i = 0; i < archive.length; i++) {
  2721. if(archive[i].level == level) {
  2722. return archive[i];
  2723. }
  2724. }
  2725. return null;
  2726. }
  2727.  
  2728. function getIdleObjectArchiveFromStorage() {
  2729. var jsonString = localStorage.getItem("idleObjectArchive");
  2730. if(jsonString != null) {
  2731. return JSON.parse(jsonString);
  2732. }
  2733. return [];
  2734. }
  2735.  
  2736. function saveIdleObjectArchiveToStorage(jsonObject) {
  2737. localStorage.setItem("idleObjectArchive", JSON.stringify(jsonObject));
  2738. // Refresh the settings when the archive changes
  2739. refreshIdleLevels();
  2740. }
  2741.  
  2742. // **************** Detect Page ****************
  2743.  
  2744. function pageIsDashboard() {
  2745. return location.href.match(/.*warzone[.]com\/MultiPlayer\/#?$/i);
  2746. }
  2747.  
  2748. function pageIsIdle() {
  2749. return location.href.match(/.*warzone[.]com\/Idle\/.*$/i);
  2750. }
  2751.  
  2752. function pageIsClanWars() {
  2753. return location.href.match(/.*warzone[.]com\/Clans\/War/i);
  2754. }
  2755.  
  2756. function pageIsTournaments() {
  2757. return location.href.match(/.*warzone[.]com\/MultiPlayer\/Tournaments\/$/i);
  2758. }
  2759.  
  2760. function pageIsPastTournaments() {
  2761. return location.href.match(/.*warzone[.]com\/MultiPlayer\/Tournaments\/Past/i);
  2762. }
  2763.  
  2764. function pageIsGame() {
  2765. return location.href.match(/.*warzone[.]com\/MultiPlayer\?GameID=/i);
  2766. }
  2767.  
  2768. function pageIsForum() {
  2769. return location.href.match(/.*warzone[.]com\/Forum/i);
  2770. }