Neverwinter Gateway - Professions Robot

Automatically selects professions for empty slots

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください。
  1. // ==UserScript==
  2. // @name Neverwinter Gateway - Professions Robot
  3. // @description Automatically selects professions for empty slots
  4. // @namespace http://userscripts.org/scripts/show/171738
  5. // @include https://gateway.playneverwinter.com
  6. // @include https://gateway.playneverwinter.com/*
  7. // @include https://gatewaysitedown.playneverwinter.com
  8. // @include https://gatewaysitedown.playneverwinter.com/*
  9. // @include http://gateway.playneverwinter.com
  10. // @include http://gateway.playneverwinter.com/*
  11. // @include http://gatewaysitedown.playneverwinter.com
  12. // @include http://gatewaysitedown.playneverwinter.com/*
  13. // @originalAuthor Mustex
  14. // @modifiedBy Bunta
  15. // @version 1.0.0.3
  16. // @license http://creativecommons.org/licenses/by-nc-sa/3.0/us/
  17. // @grant GM_getValue
  18. // @grant GM_setValue
  19. // @grant GM_listValues
  20. // @grant GM_deleteValue
  21. // ==/UserScript==
  22.  
  23. /* RELEASE NOTES
  24. 1.0.0.3
  25. - Fix some gem trading tasks not being filtered correctly
  26. - Add check for gateway disconnected
  27. 1.0.0.2
  28. - Fix leadership tasks not creating assets correctly
  29. - Add option to save task lists per character (experimental)
  30. 1.0.0.1
  31. - Rewrite script using client.dataModel methods to massively improve reliability and performance (thanks Msc)
  32. - AD refining will now only attempt to refine if you are able to collect diamonds
  33. - Change task lists to use exact task names so no ambiguity exists (no longer requires excluderare option)
  34. - Asset resources are now trained as needed (only for required slots)
  35. 0.3.0.5
  36. - Fix resources not buying correctly in all cases
  37. - Fix pause button state saving correctly in firefox
  38. 0.3.0.4
  39. - Add page timeout reloading functions outside of main function (thanks Kreese and Frabtik)
  40. - Add check to ensure tasks are being started for the correct character
  41. - Alter next run resolve function to use delay parameter to allow for unique delay timers to be used in certain cases
  42. 0.3.0.3
  43. - Fix ingredient task selection to correctly iterate through all ingredient tasks
  44. - Alter character selection to pick only exact character name matches
  45. - Update leadership tasks
  46. 0.3.0.2
  47. - Exclude alchemy from rare task exclusions due to Aqua Regia (thanks Eversor)
  48. - Reduce GM_setValue calls to avoid tampermonkey failing to save settings (thanks miah)
  49. 0.3.0.1
  50. - Altered mutichar selector to be faster (thanks miah)
  51. - Updated rare tasks selector (thanks Traktor)
  52. - Add option to refine AD during character switching (thanks Eversor)
  53. - Added some level 20 gather tasks
  54. - Increased supply buying to 100 units
  55. 0.3.0.0
  56. - Added Multi-Character support
  57. - Added function to clear all saved settings for script
  58. - Remove disable sound functionality (now configurable in gateway)
  59. 0.2.0.1.8
  60. - Added pause button to allow easy on/off switching
  61. 0.2.0.1.7
  62. - Added option to enable/disable filling optional asset slots
  63. - Added batch potions tasks to be skipped in ingredient selection
  64. - Added timer to reload page if stuck loading for too long
  65. - Added option to disable page sounds
  66. - Updated license to by-nc-sa
  67. 0.2.0.1.6
  68. - Add configurable option for excluding rare tasks
  69. 0.2.0.1.5
  70. - Add ability to specify specific level for tasks and configure same named artificing resource tasks to request correct level of task
  71. - Remove purchase notification that never times out
  72. 0.2.0.1.4
  73. - Added functionality to purchase required resources from gateway shop
  74. 0.2.0.1.3
  75. - Add Artificing and Weaponsmithing to Robot
  76. (Artificing will not work properly yet as all three tiers of gather and craft tasks have the same task name)
  77. 0.2.0.1.2
  78. - Update reload process
  79. - Fix optional asset selector with gateway update
  80. 0.2.0.1.1
  81. - Simplify asset selection after they fixed bug in previous gateway update
  82. - Update level 20 leadership tasks
  83. - Update with changes in Mustex's script (version 15)
  84. * Added a secondary timer that will reload the gateway every few hours. This should help with disconnects from the server
  85. * Implemented tooltips for settings panel
  86. 0.1.9.1.15
  87. - Repeat task reordering for +2 armor
  88. 0.1.9.1.14
  89. - Fix selection of assets after gateway update
  90. - Skip intensive gather tasks added after gateway update
  91. 0.1.9.1.13
  92. - Change ordering of tasks and ingredient checks
  93. The purpose of this is to allow crafting of +4 armors if you have +2 ingredients in your inv but to not create them if you don't.
  94. Creating the ingredients for them is less efficient than crafting ingredients for pants but is more efficient if you already have the ingredients from earlier tasks.
  95. 0.1.9.1.12
  96. - Optimise crafting tasks for highest exp/min gains due to ingredient requirements
  97. 0.1.9.1.11
  98. - Add extra craft tasks for when residuum runs out
  99. 0.1.9.1.10
  100. - Only allow rare tasks to be selected for Leadership
  101. This avoids craft loops where higher quality rare crafts require ingredients with the same name
  102. 0.1.9.1.9
  103. - Alter craft tasks to favour armor to optimise inventory space
  104. 0.1.9.1.8
  105. - Fix script restart bug when no tasks found
  106. 0.1.9.1.7
  107. - Update search string for Potions (After the task names for elxiirs have been changed)
  108. - Remove logon error skips to avoid logons sometimes failing on first load (ensure logon details are correct!)
  109. 0.1.9.1.6
  110. - Update tasks for all professions
  111. - Update ingredient search lists for all professions
  112. 0.1.9.1.5
  113. - Fix regular expression used in potion ingredient search
  114. 0.1.9.1.4
  115. - Alter default timeouts (makes script a lot more stable and less prone to errors)
  116. - Remove unused variable
  117. - Add extra logging for task ingredient searches
  118. 0.1.9.1.3
  119. - Fix bug with required resource checks getting stuck on non craftable resources
  120. 0.1.9.1.2
  121. - Added method to check for required task ingredients and choose tasks to create them
  122. Method is currently hard coded to specify certain search strings for ingredient types
  123. Currently working for all Alchemy tasks
  124. There is a current problem that if you have the required potion ingredient but it is in your belt slots
  125. the task is uncraftable but the ingredients show as available and it will not craft a new one
  126. 0.1.9.1
  127. - Update with changes in Mustex's script (version 12)
  128. * Added tasks for Platesmithing, Leatherworking, Tailoring
  129. * Added detection for the gateway being down
  130. 0.1.8.3.8
  131. - Update asset selection to avoid using coloured assets in junk slots for leadership
  132. 0.1.8.3.7
  133. - Update leadership tasks table due to task reward/duration alterations
  134. 0.1.8.3.6
  135. - Add option to enable/disable automation process
  136. - Update alchemy tasks some more
  137. 0.1.8.3.5
  138. - Add ability to select from multiple tasks with same name (eg Alchemical Research)
  139. - Add craft options for alchemy potions (need to be manually switched since they use the same ingredients)
  140. 0.1.8.3.4
  141. - Add alchemy tasks up to level 20
  142. 0.1.8.3.3
  143. - Change task slot selection to be user configurable options in settings window
  144. - Add level 1 alchemical research
  145. 0.1.8.3.2
  146. - Added ability to specify how many tasks of each profession to train multiple professions at once
  147. - Updated mailsmithing level 0 tasks
  148. 0.1.8.3.1
  149. - Changed asset selection to only update Junk assets
  150. - Leadership asset selection for bronze tier picks lowest asset first
  151. - Modified Leadership tasks
  152. 0.1.8.3
  153. - Tweaked Leadership tasks grid
  154. - Added task grid for Alchemy (Partial)
  155. 0.1.8.2
  156. - onsave handlers for settings are now called before the settings values are saved
  157. - Added onsave handler for console to enable/disable using the window console
  158. 0.1.8.1
  159. - Added checking for errors (using the window title) and will navigate back to the main login page if autologin is enabled
  160. 0.1.8
  161. - Added popup for altering settings
  162. - Settings are saved to script cache
  163. - Added mailsmithing tasks to task grid
  164. 0.1.7
  165. - Added lower level leadership tasks to grid
  166. - Added hiring tasks to leadership task
  167. - Uses saved values to determine which profession type to level (Defaults to Leadership, currently no way to change it)
  168.  
  169. 0.1.5
  170. - Is now able to recover from missing assets
  171. - Uses a configurable grid to determine what the next task is to complete
  172.  
  173. 0.1.0
  174. - Is now able to select some hard coded leadership tasks
  175. - Can now collect from any completed slot
  176. */
  177.  
  178. // Make sure it's running on the main page, no frames
  179. if (window.self !== window.top) {
  180. throw "";
  181. }
  182.  
  183. // Set global console variables
  184. var fouxConsole = {log:function(){},info:function(){},error:function(){},warn:function(){}};
  185. var console = unsafeWindow.console || fouxConsole;
  186.  
  187. // Page Reloading function
  188. // Every second the page is idle or loading is tracked
  189. var loading_reset = false; // Enables a periodic reload if this is toggled on by the Auto Reload check box on the settings panel
  190. var s_paused = false; // extend the paused setting to the Page Reloading function
  191.  
  192. (function() {
  193. var $ = unsafeWindow.$;
  194. var state_loading = 0; // If "Page Loading" takes longer than 30 seconds, reload page (maybe a javascript error)
  195. var state_loading_time = 30; // default of 30 seconds
  196.  
  197. var state_idle = 0; // If the page is idle for longer than 60 seconds, reload page (maybe a javascript error)
  198. var state_idle_time = 120; // default of 120 seconds
  199. var reload_hours = [2,5,8,11,14,17,20,23]; // logout and reload every three hours - 2:29 - 5:29 - 8:29 - 11:29 - 14:29 - 17:29 - 20:29 - 23:29
  200. var last_location = ""; // variable to track reference to page URL
  201. var reload_timer = setInterval(function() {
  202. if (!s_paused) {
  203. if (loading_reset) {
  204. var loading_date = new Date();
  205. var loading_sec = Number(loading_date.getSeconds());
  206. var loading_min = Number(loading_date.getMinutes());
  207. var loading_hour = Number(loading_date.getHours());
  208. if (reload_hours.indexOf(loading_hour) >= 0 && loading_min == 29 && loading_sec < 2) {
  209. console.log("Auto Reload");
  210. unsafeWindow.location.href = "http://gateway.playneverwinter.com";
  211. return;
  212. }
  213. }
  214. // check for errors
  215. if ($("title").text().match(/Error/) || $("div.modal-content h3").text().match(/Disconnected/)) {
  216. console.log("Error detected - relogging");
  217. unsafeWindow.location.href = "http://gateway.playneverwinter.com";
  218. return;
  219. }
  220.  
  221. if ($("div.loading-image:visible").length) {
  222. last_location = location.href;
  223. state_idle = 0;
  224. if (state_loading >= state_loading_time) {
  225. console.log("Page Loading too long");
  226. state_loading = 0;
  227. location.reload();
  228. }
  229. else {
  230. state_loading++;
  231. console.log("Page Loading ...", state_loading + "s");
  232. }
  233. }
  234. // TODO: Add check for Gateway disconnected
  235. //<div class="modal-content" id="modal_content"><h3>Disconnected from Gateway</h3><p>You have been disconnected.</p><button type="button" class="modal-button" onclick="window.location.reload(true);">Close</button>
  236.  
  237. /* Can't use idle check with dataModel methods
  238. else if (location.href == last_location) {
  239. state_loading = 0;
  240. if (state_idle >= state_idle_time) {
  241. console.log("Page Idle too long");
  242. state_idle = 0;
  243. unsafeWindow.location.href = "http://gateway.playneverwinter.com";
  244. }
  245. else {
  246. state_idle++;
  247. // comment out to avoid console spam
  248. //console.log("Page Idle ...", state_idle + "s");
  249. }
  250. }
  251. */
  252. else {
  253. last_location = location.href;
  254. state_loading = 0;
  255. state_idle = 0;
  256. }
  257. }
  258. },1000);
  259. })();
  260.  
  261. (function() {
  262.  
  263. /**
  264. * Add a string of CSS to the main page
  265. *
  266. * @param {String} cssString The CSS to add to the main page
  267. */
  268. function AddCss(cssString) {
  269. var head = document.getElementsByTagName('head')[0];
  270. if (!head)
  271. return;
  272. var newCss = document.createElement('style');
  273. newCss.type = "text/css";
  274. newCss.innerHTML = cssString;
  275. head.appendChild(newCss);
  276. }
  277. function countLeadingSpaces(str) {
  278. return str.match(/^(\s*)/)[1].length;
  279. }
  280.  
  281. var image_pause = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAY" +
  282. "AAAAf8/9hAAAACXBIWXMAAAsTAAALEwEAmpwYAAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2" +
  283. "ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG" +
  284. "8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfACAyWSDNR" +
  285. "NYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/SMBAPh+PDwrIsAHvgABeNMLCADATZvAMBy" +
  286. "H/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCdmCZTAKAEAGDLY2LjAFAtAGAnf+bTAI" +
  287. "Cd+Jl7AQBblCEVAaCRACATZYhEAGg7AKzPVopFAFgwABRmS8Q5ANgtADBJV2ZIALC3AMDOE" +
  288. "AuyAAgMADBRiIUpAAR7AGDIIyN4AISZABRG8lc88SuuEOcqAAB4mbI8uSQ5RYFbCC1xB1dX" +
  289. "Lh4ozkkXKxQ2YQJhmkAuwnmZGTKBNA/g88wAAKCRFRHgg/P9eM4Ors7ONo62Dl8t6r8G/yJ" +
  290. "iYuP+5c+rcEAAAOF0ftH+LC+zGoA7BoBt/qIl7gRoXgugdfeLZrIPQLUAoOnaV/Nw+H48PE" +
  291. "WhkLnZ2eXk5NhKxEJbYcpXff5nwl/AV/1s+X48/Pf14L7iJIEyXYFHBPjgwsz0TKUcz5IJh" +
  292. "GLc5o9H/LcL//wd0yLESWK5WCoU41EScY5EmozzMqUiiUKSKcUl0v9k4t8s+wM+3zUAsGo+" +
  293. "AXuRLahdYwP2SycQWHTA4vcAAPK7b8HUKAgDgGiD4c93/+8//UegJQCAZkmScQAAXkQkLlT" +
  294. "Ksz/HCAAARKCBKrBBG/TBGCzABhzBBdzBC/xgNoRCJMTCQhBCCmSAHHJgKayCQiiGzbAdKm" +
  295. "Av1EAdNMBRaIaTcA4uwlW4Dj1wD/phCJ7BKLyBCQRByAgTYSHaiAFiilgjjggXmYX4IcFIB" +
  296. "BKLJCDJiBRRIkuRNUgxUopUIFVIHfI9cgI5h1xGupE7yAAygvyGvEcxlIGyUT3UDLVDuag3" +
  297. "GoRGogvQZHQxmo8WoJvQcrQaPYw2oefQq2gP2o8+Q8cwwOgYBzPEbDAuxsNCsTgsCZNjy7E" +
  298. "irAyrxhqwVqwDu4n1Y8+xdwQSgUXACTYEd0IgYR5BSFhMWE7YSKggHCQ0EdoJNwkDhFHCJy" +
  299. "KTqEu0JroR+cQYYjIxh1hILCPWEo8TLxB7iEPENyQSiUMyJ7mQAkmxpFTSEtJG0m5SI+ksq" +
  300. "Zs0SBojk8naZGuyBzmULCAryIXkneTD5DPkG+Qh8lsKnWJAcaT4U+IoUspqShnlEOU05QZl" +
  301. "mDJBVaOaUt2ooVQRNY9aQq2htlKvUYeoEzR1mjnNgxZJS6WtopXTGmgXaPdpr+h0uhHdlR5" +
  302. "Ol9BX0svpR+iX6AP0dwwNhhWDx4hnKBmbGAcYZxl3GK+YTKYZ04sZx1QwNzHrmOeZD5lvVV" +
  303. "gqtip8FZHKCpVKlSaVGyovVKmqpqreqgtV81XLVI+pXlN9rkZVM1PjqQnUlqtVqp1Q61MbU" +
  304. "2epO6iHqmeob1Q/pH5Z/YkGWcNMw09DpFGgsV/jvMYgC2MZs3gsIWsNq4Z1gTXEJrHN2Xx2" +
  305. "KruY/R27iz2qqaE5QzNKM1ezUvOUZj8H45hx+Jx0TgnnKKeX836K3hTvKeIpG6Y0TLkxZVx" +
  306. "rqpaXllirSKtRq0frvTau7aedpr1Fu1n7gQ5Bx0onXCdHZ4/OBZ3nU9lT3acKpxZNPTr1ri" +
  307. "6qa6UbobtEd79up+6Ynr5egJ5Mb6feeb3n+hx9L/1U/W36p/VHDFgGswwkBtsMzhg8xTVxb" +
  308. "zwdL8fb8VFDXcNAQ6VhlWGX4YSRudE8o9VGjUYPjGnGXOMk423GbcajJgYmISZLTepN7ppS" +
  309. "TbmmKaY7TDtMx83MzaLN1pk1mz0x1zLnm+eb15vft2BaeFostqi2uGVJsuRaplnutrxuhVo" +
  310. "5WaVYVVpds0atna0l1rutu6cRp7lOk06rntZnw7Dxtsm2qbcZsOXYBtuutm22fWFnYhdnt8" +
  311. "Wuw+6TvZN9un2N/T0HDYfZDqsdWh1+c7RyFDpWOt6azpzuP33F9JbpL2dYzxDP2DPjthPLK" +
  312. "cRpnVOb00dnF2e5c4PziIuJS4LLLpc+Lpsbxt3IveRKdPVxXeF60vWdm7Obwu2o26/uNu5p" +
  313. "7ofcn8w0nymeWTNz0MPIQ+BR5dE/C5+VMGvfrH5PQ0+BZ7XnIy9jL5FXrdewt6V3qvdh7xc" +
  314. "+9j5yn+M+4zw33jLeWV/MN8C3yLfLT8Nvnl+F30N/I/9k/3r/0QCngCUBZwOJgUGBWwL7+H" +
  315. "p8Ib+OPzrbZfay2e1BjKC5QRVBj4KtguXBrSFoyOyQrSH355jOkc5pDoVQfujW0Adh5mGLw" +
  316. "34MJ4WHhVeGP45wiFga0TGXNXfR3ENz30T6RJZE3ptnMU85ry1KNSo+qi5qPNo3ujS6P8Yu" +
  317. "ZlnM1VidWElsSxw5LiquNm5svt/87fOH4p3iC+N7F5gvyF1weaHOwvSFpxapLhIsOpZATIh" +
  318. "OOJTwQRAqqBaMJfITdyWOCnnCHcJnIi/RNtGI2ENcKh5O8kgqTXqS7JG8NXkkxTOlLOW5hC" +
  319. "epkLxMDUzdmzqeFpp2IG0yPTq9MYOSkZBxQqohTZO2Z+pn5mZ2y6xlhbL+xW6Lty8elQfJa" +
  320. "7OQrAVZLQq2QqboVFoo1yoHsmdlV2a/zYnKOZarnivN7cyzytuQN5zvn//tEsIS4ZK2pYZL" +
  321. "Vy0dWOa9rGo5sjxxedsK4xUFK4ZWBqw8uIq2Km3VT6vtV5eufr0mek1rgV7ByoLBtQFr6wt" +
  322. "VCuWFfevc1+1dT1gvWd+1YfqGnRs+FYmKrhTbF5cVf9go3HjlG4dvyr+Z3JS0qavEuWTPZt" +
  323. "Jm6ebeLZ5bDpaql+aXDm4N2dq0Dd9WtO319kXbL5fNKNu7g7ZDuaO/PLi8ZafJzs07P1SkV" +
  324. "PRU+lQ27tLdtWHX+G7R7ht7vPY07NXbW7z3/T7JvttVAVVN1WbVZftJ+7P3P66Jqun4lvtt" +
  325. "Xa1ObXHtxwPSA/0HIw6217nU1R3SPVRSj9Yr60cOxx++/p3vdy0NNg1VjZzG4iNwRHnk6fc" +
  326. "J3/ceDTradox7rOEH0x92HWcdL2pCmvKaRptTmvtbYlu6T8w+0dbq3nr8R9sfD5w0PFl5Sv" +
  327. "NUyWna6YLTk2fyz4ydlZ19fi753GDborZ752PO32oPb++6EHTh0kX/i+c7vDvOXPK4dPKy2" +
  328. "+UTV7hXmq86X23qdOo8/pPTT8e7nLuarrlca7nuer21e2b36RueN87d9L158Rb/1tWeOT3d" +
  329. "vfN6b/fF9/XfFt1+cif9zsu72Xcn7q28T7xf9EDtQdlD3YfVP1v+3Njv3H9qwHeg89HcR/c" +
  330. "GhYPP/pH1jw9DBY+Zj8uGDYbrnjg+OTniP3L96fynQ89kzyaeF/6i/suuFxYvfvjV69fO0Z" +
  331. "jRoZfyl5O/bXyl/erA6xmv28bCxh6+yXgzMV70VvvtwXfcdx3vo98PT+R8IH8o/2j5sfVT0" +
  332. "Kf7kxmTk/8EA5jz/GMzLdsAAAAgY0hSTQAAeiUAAICDAAD5/wAAgOkAAHUwAADqYAAAOpgA" +
  333. "ABdvkl/FRgAAAZ9JREFUeNqU0z+LE2EQBvDfvsuZ3IkoFzSJiuCfeAkWFmJnkz5wjVjlK4i" +
  334. "tnR9BrP0E4uewE/bQwKko2CjR88+BuSMhycbm3RjjNk41z7szz8w8O5Motzqu4iwW+Ir3+L" +
  335. "YemKzh07iLGziJPL4HjPAKz3FcRnAJD3AKXzBb+b7ABhr4jscYQhoDzuBhrDQsIU9iNz9j7" +
  336. "G28wLQg6OMyhrVaLd3Z2dFoNBwdHdna2tJut9XrdZPJJIzH4xHOo4rXAU3cjJXTfr8vyzJZ" +
  337. "lul2u3q9nizL7O3t2d3dLbr+jFvYDuiggjlMp9Nl3/P53Gw2W+IVfxZFbgecw7SYOc/zZUK" +
  338. "e5//gNU22QxRu4f9tgSTE5ThRkIQQ/kifJJIk+QuvJKc4DHizOsLm5uYyoVKpqFarS7zipx" +
  339. "jjXUF5P4o5bDabodVqgcFgIE1TnU4H7O/vOzg4yHEBL/G0IGjgUVzXX1GXMsvjIm3E+B/FI" +
  340. "o3wEXfi7zkuRFoVLBYKeIJPZcd0EfdwLc5ZaLMR/bd4Fm+l9BoLu44rsd0FDuM5f1gP/D0A" +
  341. "BNp57TyT3+MAAAAASUVORK5CYII=";
  342. var image_play = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYA" +
  343. "AAAf8/9hAAAACXBIWXMAAAsTAAALEwEAmpwYAAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2Z" +
  344. "pbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8" +
  345. "igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfACAyWSDNRN" +
  346. "YAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/SMBAPh+PDwrIsAHvgABeNMLCADATZvAMByH" +
  347. "/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCdmCZTAKAEAGDLY2LjAFAtAGAnf+bTAIC" +
  348. "d+Jl7AQBblCEVAaCRACATZYhEAGg7AKzPVopFAFgwABRmS8Q5ANgtADBJV2ZIALC3AMDOEA" +
  349. "uyAAgMADBRiIUpAAR7AGDIIyN4AISZABRG8lc88SuuEOcqAAB4mbI8uSQ5RYFbCC1xB1dXL" +
  350. "h4ozkkXKxQ2YQJhmkAuwnmZGTKBNA/g88wAAKCRFRHgg/P9eM4Ors7ONo62Dl8t6r8G/yJi" +
  351. "YuP+5c+rcEAAAOF0ftH+LC+zGoA7BoBt/qIl7gRoXgugdfeLZrIPQLUAoOnaV/Nw+H48PEW" +
  352. "hkLnZ2eXk5NhKxEJbYcpXff5nwl/AV/1s+X48/Pf14L7iJIEyXYFHBPjgwsz0TKUcz5IJhG" +
  353. "Lc5o9H/LcL//wd0yLESWK5WCoU41EScY5EmozzMqUiiUKSKcUl0v9k4t8s+wM+3zUAsGo+A" +
  354. "XuRLahdYwP2SycQWHTA4vcAAPK7b8HUKAgDgGiD4c93/+8//UegJQCAZkmScQAAXkQkLlTK" +
  355. "sz/HCAAARKCBKrBBG/TBGCzABhzBBdzBC/xgNoRCJMTCQhBCCmSAHHJgKayCQiiGzbAdKmA" +
  356. "v1EAdNMBRaIaTcA4uwlW4Dj1wD/phCJ7BKLyBCQRByAgTYSHaiAFiilgjjggXmYX4IcFIBB" +
  357. "KLJCDJiBRRIkuRNUgxUopUIFVIHfI9cgI5h1xGupE7yAAygvyGvEcxlIGyUT3UDLVDuag3G" +
  358. "oRGogvQZHQxmo8WoJvQcrQaPYw2oefQq2gP2o8+Q8cwwOgYBzPEbDAuxsNCsTgsCZNjy7Ei" +
  359. "rAyrxhqwVqwDu4n1Y8+xdwQSgUXACTYEd0IgYR5BSFhMWE7YSKggHCQ0EdoJNwkDhFHCJyK" +
  360. "TqEu0JroR+cQYYjIxh1hILCPWEo8TLxB7iEPENyQSiUMyJ7mQAkmxpFTSEtJG0m5SI+ksqZ" +
  361. "s0SBojk8naZGuyBzmULCAryIXkneTD5DPkG+Qh8lsKnWJAcaT4U+IoUspqShnlEOU05QZlm" +
  362. "DJBVaOaUt2ooVQRNY9aQq2htlKvUYeoEzR1mjnNgxZJS6WtopXTGmgXaPdpr+h0uhHdlR5O" +
  363. "l9BX0svpR+iX6AP0dwwNhhWDx4hnKBmbGAcYZxl3GK+YTKYZ04sZx1QwNzHrmOeZD5lvVVg" +
  364. "qtip8FZHKCpVKlSaVGyovVKmqpqreqgtV81XLVI+pXlN9rkZVM1PjqQnUlqtVqp1Q61MbU2" +
  365. "epO6iHqmeob1Q/pH5Z/YkGWcNMw09DpFGgsV/jvMYgC2MZs3gsIWsNq4Z1gTXEJrHN2Xx2K" +
  366. "ruY/R27iz2qqaE5QzNKM1ezUvOUZj8H45hx+Jx0TgnnKKeX836K3hTvKeIpG6Y0TLkxZVxr" +
  367. "qpaXllirSKtRq0frvTau7aedpr1Fu1n7gQ5Bx0onXCdHZ4/OBZ3nU9lT3acKpxZNPTr1ri6" +
  368. "qa6UbobtEd79up+6Ynr5egJ5Mb6feeb3n+hx9L/1U/W36p/VHDFgGswwkBtsMzhg8xTVxbz" +
  369. "wdL8fb8VFDXcNAQ6VhlWGX4YSRudE8o9VGjUYPjGnGXOMk423GbcajJgYmISZLTepN7ppST" +
  370. "bmmKaY7TDtMx83MzaLN1pk1mz0x1zLnm+eb15vft2BaeFostqi2uGVJsuRaplnutrxuhVo5" +
  371. "WaVYVVpds0atna0l1rutu6cRp7lOk06rntZnw7Dxtsm2qbcZsOXYBtuutm22fWFnYhdnt8W" +
  372. "uw+6TvZN9un2N/T0HDYfZDqsdWh1+c7RyFDpWOt6azpzuP33F9JbpL2dYzxDP2DPjthPLKc" +
  373. "RpnVOb00dnF2e5c4PziIuJS4LLLpc+Lpsbxt3IveRKdPVxXeF60vWdm7Obwu2o26/uNu5p7" +
  374. "ofcn8w0nymeWTNz0MPIQ+BR5dE/C5+VMGvfrH5PQ0+BZ7XnIy9jL5FXrdewt6V3qvdh7xc+" +
  375. "9j5yn+M+4zw33jLeWV/MN8C3yLfLT8Nvnl+F30N/I/9k/3r/0QCngCUBZwOJgUGBWwL7+Hp" +
  376. "8Ib+OPzrbZfay2e1BjKC5QRVBj4KtguXBrSFoyOyQrSH355jOkc5pDoVQfujW0Adh5mGLw3" +
  377. "4MJ4WHhVeGP45wiFga0TGXNXfR3ENz30T6RJZE3ptnMU85ry1KNSo+qi5qPNo3ujS6P8YuZ" +
  378. "lnM1VidWElsSxw5LiquNm5svt/87fOH4p3iC+N7F5gvyF1weaHOwvSFpxapLhIsOpZATIhO" +
  379. "OJTwQRAqqBaMJfITdyWOCnnCHcJnIi/RNtGI2ENcKh5O8kgqTXqS7JG8NXkkxTOlLOW5hCe" +
  380. "pkLxMDUzdmzqeFpp2IG0yPTq9MYOSkZBxQqohTZO2Z+pn5mZ2y6xlhbL+xW6Lty8elQfJa7" +
  381. "OQrAVZLQq2QqboVFoo1yoHsmdlV2a/zYnKOZarnivN7cyzytuQN5zvn//tEsIS4ZK2pYZLV" +
  382. "y0dWOa9rGo5sjxxedsK4xUFK4ZWBqw8uIq2Km3VT6vtV5eufr0mek1rgV7ByoLBtQFr6wtV" +
  383. "CuWFfevc1+1dT1gvWd+1YfqGnRs+FYmKrhTbF5cVf9go3HjlG4dvyr+Z3JS0qavEuWTPZtJ" +
  384. "m6ebeLZ5bDpaql+aXDm4N2dq0Dd9WtO319kXbL5fNKNu7g7ZDuaO/PLi8ZafJzs07P1SkVP" +
  385. "RU+lQ27tLdtWHX+G7R7ht7vPY07NXbW7z3/T7JvttVAVVN1WbVZftJ+7P3P66Jqun4lvttX" +
  386. "a1ObXHtxwPSA/0HIw6217nU1R3SPVRSj9Yr60cOxx++/p3vdy0NNg1VjZzG4iNwRHnk6fcJ" +
  387. "3/ceDTradox7rOEH0x92HWcdL2pCmvKaRptTmvtbYlu6T8w+0dbq3nr8R9sfD5w0PFl5SvN" +
  388. "UyWna6YLTk2fyz4ydlZ19fi753GDborZ752PO32oPb++6EHTh0kX/i+c7vDvOXPK4dPKy2+" +
  389. "UTV7hXmq86X23qdOo8/pPTT8e7nLuarrlca7nuer21e2b36RueN87d9L158Rb/1tWeOT3dv" +
  390. "fN6b/fF9/XfFt1+cif9zsu72Xcn7q28T7xf9EDtQdlD3YfVP1v+3Njv3H9qwHeg89HcR/cG" +
  391. "hYPP/pH1jw9DBY+Zj8uGDYbrnjg+OTniP3L96fynQ89kzyaeF/6i/suuFxYvfvjV69fO0Zj" +
  392. "RoZfyl5O/bXyl/erA6xmv28bCxh6+yXgzMV70VvvtwXfcdx3vo98PT+R8IH8o/2j5sfVT0K" +
  393. "f7kxmTk/8EA5jz/GMzLdsAAAAgY0hSTQAAeiUAAICDAAD5/wAAgOkAAHUwAADqYAAAOpgAA" +
  394. "Bdvkl/FRgAAAYZJREFUeNqk08+KklEYBvDf9+lIEYZDZQ0OIrQZahEuBoLuQqiWIl5BG2k5" +
  395. "W5dzA15AF9EFJOiiRRNkSIw4lTAfCQNmzrToOIkc2nRW5z3n/fe8z/Mm4mcfD3EfCb5hhC/" +
  396. "bjsmWXcJLPMJNLMP7DhY4wRt8jyWo4hVu4Qyrjf8rpKGjJY7xCXLB4TZeB/ssBCaRTn+ggG" +
  397. "d4h4s0fDRQxAy5arWq0+nEZpMiQx7P1w938SRUzkGWZbrdrsFgoFarxZJ8xWPspzgIuH+tP" +
  398. "ZbLpfl8rl6vG41GWq3WdpLLAOUgxb0QfI05Sf7CT9NUr9fT7/dVKpXNmSxRSv3nSQOn+UDV" +
  399. "H86urq9Wq5V2u+3w8NBkMrFB6w7O80EcFyHJCgqFgmKxaDgcajQaxuNxrPBPnORC8IOgvgx" +
  400. "puVw2nU41m01ZlsUGuIf3eJtsCOko0DjbEFgsuBQYOMJs7bjABzzFndDVZUTKe8E+xmlsmX" +
  401. "bxIsC5sZ5J6GiBj/9aptg67wafc3yOrfPvAQDwi2sWVdJBsgAAAABJRU5ErkJggg==";
  402. var image_prefs = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQC" +
  403. "AMAAAAoLQ9TAAAAllBMVEUAGQASEhIfHx8fJy8pKSk2NjZBQUFJR0ZQUE9RUVFSUlJNX3No" +
  404. "aGhsaWdramlycG1meY98fHx+fn5wgpV0iqKKh4R4jaR9jJx8kad9kad/mbONmaWEnrmEnrq" +
  405. "koZy3t7fIx8bKyMHT0c3S0dDU09DV1NPP1t3W1dXY2Njb2tfe29bf3tzj4uHr6+js6+r39/" +
  406. "f5+PgAAABrL3yvAAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxMAAAsTA" +
  407. "QCanBgAAAAHdElNRQfWBRoFKh31UQ8DAAAAgUlEQVQY022OxxLCMAwFRSc4BEIPJZQQ08v+" +
  408. "/8+RsTExDDpIe3ijfSJ/hx9g62Dt4GaAI+8YT0t27+BxxvvE/no5pYT10lGFrE34Ja40W3g" +
  409. "1oMGmW7YZ6hnCYexKTPVkXivuvWe1Cz1aKqPNI3N0slI2TNYZiARJX30qERc7wBPKC4WRDz" +
  410. "WdWHfmAAAAAElFTkSuQmCC";
  411. var image_close = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQC" +
  412. "AQAAAC1+jfqAAAAAmJLR0QA/4ePzL8AAAAJcEhZcwAACxMAAAsTAQCanBgAAAAHdElNRQfW" +
  413. "BRkTNhxuPxLkAAAAHXRFWHRDb21tZW50AENyZWF0ZWQgd2l0aCBUaGUgR0lNUO9kJW4AAAE" +
  414. "KSURBVCjPhdGxSgNBFAXQMzpgYWwsLEQUDBJBQgqFIChZEPR7/DA/QCGQTgQtJE1ENoWohY" +
  415. "UgbGKQyFjErNv52nObe19wqGWg7z0l5YVgVdOu+wUt507tqIVQ4Zodp861ooELe15M5KFI6" +
  416. "Zfr9u25MIj6Jl4cmSIPBWrq2o5cufO4aOJDYSozNTa2pK4t03PtwUdMKRRykAmW0dTRcyNX" +
  417. "pBQpI8GJDTR050zkNzK0bMMZLvUNZ8yCfy6Wvbc1NVyi4dloXjqWvds6uvp41pFmpVOKJWd" +
  418. "6bgwxkmTMIotWKpwrfBkZl7uMonUHf5wSlV2+fUZrjnXdzrmyy7djD8GWTW9e51z557o1Tz" +
  419. "85FH/WkOkaHQAAAABJRU5ErkJggg==";
  420.  
  421.  
  422. // Setup global closure variables
  423. var $ = unsafeWindow.jQuery;
  424. var timerHandle = 0;
  425. var dfdNextRun = $.Deferred();
  426. var charcurrent = 0; // current character counter
  427. var settingwipe = false; // Use to wipe stored settings
  428. var delay = {
  429. SHORT : 1000,
  430. MEDIUM : 5000,
  431. LONG : 30000,
  432. MINS : 300000,
  433. DEFAULT : 10000, // default delay
  434. TIMEOUT : 60000, // delay for cycle processing timeout
  435. };
  436.  
  437. /*
  438. * Tasklist can be modified to configure the training you want to perform.
  439. * The configurable options window sets how many profession slots you want to use for each profession.
  440. * The level array below for each professions specifies the tasks you want to learn at each crafting level.
  441. * Each craft slot will pick the first task that meets requirements.
  442. * See http://pastebin.com/VaGntEha for Task Name Map.
  443. * Some names above do not match, use below code to check:
  444. * var tasks = client.dataModel.model.craftinglist['craft_' + profname].entries.filter(function(entry) { return entry.def && entry.def.displayname == taskname; }); tasks[0].def.name;
  445. */
  446. var tasklist;
  447. var defaultTasklist = [
  448. {
  449. taskName:"Leadership",
  450. level: {
  451. 0:["Leadership_Tier0_Intro_1"],
  452. 1:["Leadership_Tier0_Intro_5", "Leadership_Tier0_Intro_4","Leadership_Tier0_Intro_3", "Leadership_Tier0_Intro_2"],
  453. 2:["Leadership_Tier1_2_Guardduty"],
  454. 3:["Leadership_Tier1_2_Guardduty"],
  455. 4:["Leadership_Tier1_4_Protect"],
  456. 5:["Leadership_Tier1_4_Protect","Leadership_Tier1_5_Explore"],
  457. 6:["Leadership_Tier1_4_Protect","Leadership_Tier1_5_Explore"],
  458. 7:["Leadership_Tier1_4_Protect","Leadership_Tier1_5_Explore"],
  459. 8:["Leadership_Tier1_4_Protect","Leadership_Tier1_5_Explore"],
  460. 9:["Leadership_Tier1_4_Protect","Leadership_Tier2_9_Chart","Leadership_Tier1_5_Explore"],
  461. 10:["Leadership_Tier1_4_Protect","Leadership_Tier2_9_Chart","Leadership_Tier1_5_Explore","Leadership_Tier2_10_Battle"],
  462. 11:["Leadership_Tier1_4_Protect","Leadership_Tier2_9_Chart","Leadership_Tier1_5_Explore","Leadership_Tier2_10_Battle"],
  463. 12:["Leadership_Tier1_4_Protect","Leadership_Tier2_9_Chart","Leadership_Tier1_5_Explore","Leadership_Tier2_10_Battle"],
  464. // Current model
  465. 13:["Leadership_Tier3_13_Patrol","Leadership_Tier2_9_Chart","Leadership_Tier1_4_Protect","Leadership_Tier1_5_Explore","Leadership_Tier2_10_Battle"],
  466. 14:["Leadership_Tier3_13_Patrol","Leadership_Tier2_9_Chart","Leadership_Tier1_4_Protect","Leadership_Tier1_5_Explore","Leadership_Tier2_10_Battle"],
  467. 15:["Leadership_Tier3_13_Patrol","Leadership_Tier2_9_Chart","Leadership_Tier1_4_Protect","Leadership_Tier1_5_Explore","Leadership_Tier2_10_Battle"],
  468. 16:["Leadership_Tier3_13_Patrol","Leadership_Tier2_9_Chart","Leadership_Tier3_16_Fight","Leadership_Tier1_5_Explore","Leadership_Tier2_10_Battle"],
  469. 17:["Leadership_Tier3_13_Patrol","Leadership_Tier2_9_Chart","Leadership_Tier3_17_Deliver","Leadership_Tier3_16_Fight","Leadership_Tier1_5_Explore","Leadership_Tier2_12_Taxes","Leadership_Tier2_10_Battle"],
  470. 18:["Leadership_Tier3_13_Patrol","Leadership_Tier2_9_Chart","Leadership_Tier3_17_Deliver","Leadership_Tier3_16_Fight","Leadership_Tier1_5_Explore","Leadership_Tier2_12_Taxes","Leadership_Tier2_10_Battle"],
  471. 19:["Leadership_Tier3_13_Patrol","Leadership_Tier2_9_Chart","Leadership_Tier3_17_Deliver","Leadership_Tier3_16_Fight","Leadership_Tier1_5_Explore","Leadership_Tier2_12_Taxes","Leadership_Tier2_10_Battle"],
  472. 20:["Leadership_Tier3_20r_Master2","Leadership_Tier3_20r_Master1","Leadership_Tier3_20r_Master3","Leadership_Tier3_20_Destroy","Leadership_Tier3_17_Deliver","Leadership_Tier3_13r_Protectdiamonds","Leadership_Tier2_12_Taxes","Leadership_Tier3_16_Fight","Leadership_Tier3_13_Patrol","Leadership_Tier2_9_Chart","Leadership_Tier1_5_Explore"],
  473. //19:["Patrol the Mines","Chart Region","Deliver Metals","Fight Off Spellplagued","Explore Local Area","Collect Taxes","Train a Guard","Battle Undead","Hire a Mercenary"],
  474. //20:["Assault Enemy Stronghold","Follow Map to an Unknown Location","Recover Large Mineral Claim","Destroy Enemy Camp","Deliver Metals","Protect Diamond Shipment","Collect Taxes","Fight Off Spellplagued","Patrol the Mines","Chart Region","Explore Local Area"],
  475. // Training Mode
  476. /*
  477. 13:["Leadership_Tier3_13_Recruit","Leadership_Tier2_7_Recruit","Leadership_Tier1_2_Recruit"],
  478. 14:["Leadership_Tier3_13_Recruit","Leadership_Tier2_7_Recruit","Leadership_Tier1_2_Recruit"],
  479. 15:["Leadership_Tier3_13_Recruit","Leadership_Tier2_7_Recruit","Leadership_Tier1_2_Recruit"],
  480. 16:["Leadership_Tier3_13_Recruit","Leadership_Tier2_7_Recruit","Leadership_Tier1_2_Recruit"],
  481. 17:["Leadership_Tier3_13_Recruit","Leadership_Tier2_7_Recruit","Leadership_Tier1_2_Recruit"],
  482. */
  483. },
  484. },
  485. {
  486. // Mailsmithing
  487. taskName:"Armorsmithing_Med",
  488. level: {
  489. 0:["Med_Armorsmithing_Tier0_Intro"],
  490. 1:["Med_Armorsmithing_Tier1_Chain_Boots_1","Med_Armorsmithing_Tier1_Chain_Shirt_1"],
  491. 2:["Med_Armorsmithing_Tier1_Chain_Armor_1","Med_Armorsmithing_Tier1_Chain_Pants_1"],
  492. 3:["Med_Armorsmithing_Tier1_Chain_Armor_1","Med_Armorsmithing_Tier1_Chain_Boots_Set_1"],
  493. 4:["Med_Armorsmithing_Tier1_Chain_Armor_1","Med_Armorsmithing_Tier1_Chain_Boots_Set_1"],
  494. 5:["Med_Armorsmithing_Tier1_Chain_Armor_Set_1","Med_Armorsmithing_Tier1_Chain_Boots_Set_1"],
  495. 6:["Med_Armorsmithing_Tier1_Chain_Armor_Set_1","Med_Armorsmithing_Tier1_Chain_Boots_Set_1"],
  496. 7:["Med_Armorsmithing_Tier1_Chain_Armor_Set_1","Med_Armorsmithing_Tier2_Chain_Boots_Set_1","Med_Armorsmithing_Tier2_Chain_Shirt"],
  497. 8:["Med_Armorsmithing_Tier2_Chain_Armor_Set_1","Med_Armorsmithing_Tier2_Chain_Pants_1","Med_Armorsmithing_Tier2_Chain_Boots_Set_1","Med_Armorsmithing_Tier2_Chain_Shirt"],
  498. 9:["Med_Armorsmithing_Tier2_Chain_Armor_Set_1","Med_Armorsmithing_Tier2_Chain_Pants_1","Med_Armorsmithing_Tier2_Chain_Boots_Set_1","Med_Armorsmithing_Tier2_Chain_Shirt"],
  499. 10:["Med_Armorsmithing_Tier2_Chain_Armor_Set_1","Med_Armorsmithing_Tier2_Chain_Pants_1","Med_Armorsmithing_Tier2_Chain_Boots_Set_1","Med_Armorsmithing_Tier2_Chain_Shirt_2"],
  500. 11:["Med_Armorsmithing_Tier2_Chain_Armor_Set_1","Med_Armorsmithing_Tier2_Chain_Pants_2","Med_Armorsmithing_Tier2_Chain_Boots_Set_1","Med_Armorsmithing_Tier2_Chain_Shirt_2","Med_Armorsmithing_Tier2_Chain_Pants_1"],
  501. 12:["Med_Armorsmithing_Tier2_Chain_Armor_Set_1","Med_Armorsmithing_Tier2_Chain_Pants_2","Med_Armorsmithing_Tier2_Chain_Boots_Set_1","Med_Armorsmithing_Tier2_Chain_Shirt_2","Med_Armorsmithing_Tier2_Chain_Pants_1"],
  502. 13:["Med_Armorsmithing_Tier2_Chain_Armor_Set_1","Med_Armorsmithing_Tier2_Chain_Pants_2","Med_Armorsmithing_Tier2_Chain_Boots_Set_1","Med_Armorsmithing_Tier2_Chain_Shirt_2","Med_Armorsmithing_Tier2_Chain_Pants_1"],
  503. 14:["Med_Armorsmithing_Tier2_Chain_Armor_Set_1","Med_Armorsmithing_Tier2_Chain_Pants_2","Med_Armorsmithing_Tier3_Chain_Shirt","Med_Armorsmithing_Tier3_Chain_Boots_Set_1"],
  504. 15:["Med_Armorsmithing_Tier3_Chain_Armor_Set_1","Med_Armorsmithing_Tier3_Chain_Pants","Med_Armorsmithing_Tier3_Chain_Shirt2","Med_Armorsmithing_Tier3_Chain_Boots_Set_1"],
  505. 16:["Med_Armorsmithing_Tier3_Chain_Armor_Set_1","Med_Armorsmithing_Tier3_Chain_Pants2","Med_Armorsmithing_Tier3_Chain_Shirt2","Med_Armorsmithing_Tier3_Chain_Helm_Set_1","Med_Armorsmithing_Tier3_Chain_Pants"],
  506. 17:["Med_Armorsmithing_Tier3_Chain_Armor_Set_1","Med_Armorsmithing_Tier3_Chain_Pants2","Med_Armorsmithing_Tier3_Chain_Shirt2","Med_Armorsmithing_Tier3_Chain_Helm_Set_1","Med_Armorsmithing_Tier3_Chain_Pants"],
  507. 18:["Med_Armorsmithing_Tier3_Chain_Armor_Set_1","Med_Armorsmithing_Tier3_Chain_Pants2","Med_Armorsmithing_Tier3_Chain_Shirt2","Med_Armorsmithing_Tier3_Chain_Helm_Set_1","Med_Armorsmithing_Tier3_Chain_Pants"],
  508. 19:["Med_Armorsmithing_Tier3_Chain_Armor_Set_1","Med_Armorsmithing_Tier3_Chain_Pants2","Med_Armorsmithing_Tier3_Chain_Shirt2","Med_Armorsmithing_Tier3_Chain_Helm_Set_1","Med_Armorsmithing_Tier3_Chain_Pants"],
  509. 20:["Med_Armorsmithing_Tier2_Refine_Basic"],
  510. //19:["Chain Armor +4","Fancy Chain Pants","Fancy Chain Shirt","Chain Helm +4","Ornate Chain Pants","Upgrade Blacksmith","Upgrade Prospector","Hire an additional Prospector"],
  511. //20:["Forge Steel Rings and Scales"],
  512. },
  513. },
  514. {
  515. // Platesmithing
  516. taskName:"Armorsmithing_Heavy",
  517. level: {
  518. 0:["Hvy_Armorsmithing_Tier0_Intro"],
  519. 1:["Hvy_Armorsmithing_Tier1_Plate_Boots_1","Hvy_Armorsmithing_Tier1_Plate_Shirt_1","Hvy_Armorsmithing_Tier1_Shield_1"],
  520. 2:["Hvy_Armorsmithing_Tier1_Plate_Armor_1","Hvy_Armorsmithing_Tier1_Plate_Pants_1"],
  521. 3:["Hvy_Armorsmithing_Tier1_Plate_Armor_1","Hvy_Armorsmithing_Tier1_Plate_Boots_Set_1"],
  522. 4:["Hvy_Armorsmithing_Tier1_Plate_Armor_1","Hvy_Armorsmithing_Tier1_Plate_Boots_Set_1"],
  523. 5:["Hvy_Armorsmithing_Tier1_Plate_Armor_Set_1","Hvy_Armorsmithing_Tier1_Plate_Boots_Set_1"],
  524. 6:["Hvy_Armorsmithing_Tier1_Plate_Armor_Set_1","Hvy_Armorsmithing_Tier1_Plate_Boots_Set_1"],
  525. 7:["Hvy_Armorsmithing_Tier1_Plate_Armor_Set_1","Hvy_Armorsmithing_Tier2_Plate_Boots_Set_1","Hvy_Armorsmithing_Tier2_Plate_Shirt","Hvy_Armorsmithing_Tier2_Shield_Set_1"],
  526. 8:["Hvy_Armorsmithing_Tier2_Plate_Armor_Set_1","Hvy_Armorsmithing_Tier2_Plate_Pants_1","Hvy_Armorsmithing_Tier2_Plate_Boots_Set_1","Hvy_Armorsmithing_Tier2_Plate_Shirt"],
  527. 9:["Hvy_Armorsmithing_Tier2_Plate_Armor_Set_1","Hvy_Armorsmithing_Tier2_Plate_Pants_1","Hvy_Armorsmithing_Tier2_Plate_Boots_Set_1","Hvy_Armorsmithing_Tier2_Plate_Shirt"],
  528. 10:["Hvy_Armorsmithing_Tier2_Plate_Armor_Set_1","Hvy_Armorsmithing_Tier2_Plate_Pants_1","Hvy_Armorsmithing_Tier2_Plate_Boots_Set_1","Hvy_Armorsmithing_Tier2_Plate_Shirt_2"],
  529. 11:["Hvy_Armorsmithing_Tier2_Plate_Armor_Set_1","Hvy_Armorsmithing_Tier2_Plate_Pants_2","Hvy_Armorsmithing_Tier2_Plate_Boots_Set_1","Hvy_Armorsmithing_Tier2_Plate_Shirt_2","Hvy_Armorsmithing_Tier2_Plate_Pants_1"],
  530. 12:["Hvy_Armorsmithing_Tier2_Plate_Armor_Set_1","Hvy_Armorsmithing_Tier2_Plate_Pants_2","Hvy_Armorsmithing_Tier2_Plate_Boots_Set_1","Hvy_Armorsmithing_Tier2_Plate_Shirt_2","Hvy_Armorsmithing_Tier2_Plate_Pants_1"],
  531. 13:["Hvy_Armorsmithing_Tier2_Plate_Armor_Set_1","Hvy_Armorsmithing_Tier2_Plate_Pants_2","Hvy_Armorsmithing_Tier2_Plate_Boots_Set_1","Hvy_Armorsmithing_Tier2_Plate_Shirt_2","Hvy_Armorsmithing_Tier2_Plate_Pants_1"],
  532. 14:["Hvy_Armorsmithing_Tier2_Plate_Armor_Set_1","Hvy_Armorsmithing_Tier2_Plate_Pants_2","Hvy_Armorsmithing_Tier3_Plate_Shirt","Hvy_Armorsmithing_Tier3_Plate_Boots_Set_1"],
  533. 15:["Hvy_Armorsmithing_Tier3_Plate_Armor_Set_1","Hvy_Armorsmithing_Tier3_Plate_Pants","Hvy_Armorsmithing_Tier3_Plate_Shirt2","Hvy_Armorsmithing_Tier3_Plate_Boots_Set_1"],
  534. 16:["Hvy_Armorsmithing_Tier3_Plate_Armor_Set_1","Hvy_Armorsmithing_Tier3_Plate_Pants2","Hvy_Armorsmithing_Tier3_Plate_Shirt2","Hvy_Armorsmithing_Tier3_Plate_Helm_Set_1","Hvy_Armorsmithing_Tier3_Plate_Pants"],
  535. 17:["Hvy_Armorsmithing_Tier3_Plate_Armor_Set_1","Hvy_Armorsmithing_Tier3_Plate_Pants2","Hvy_Armorsmithing_Tier3_Plate_Shirt2","Hvy_Armorsmithing_Tier3_Plate_Helm_Set_1","Hvy_Armorsmithing_Tier3_Plate_Pants"],
  536. 18:["Hvy_Armorsmithing_Tier3_Plate_Armor_Set_1","Hvy_Armorsmithing_Tier3_Plate_Pants2","Hvy_Armorsmithing_Tier3_Plate_Shirt2","Hvy_Armorsmithing_Tier3_Plate_Helm_Set_1","Hvy_Armorsmithing_Tier3_Plate_Pants"],
  537. 19:["Hvy_Armorsmithing_Tier3_Plate_Armor_Set_1","Hvy_Armorsmithing_Tier3_Plate_Pants2","Hvy_Armorsmithing_Tier3_Plate_Shirt2","Hvy_Armorsmithing_Tier3_Plate_Helm_Set_1","Hvy_Armorsmithing_Tier3_Plate_Pants"],
  538. 20:["Hvy_Armorsmithing_Tier2_Refine_Basic"],
  539. //19:["Plate Armor +4","Fancy Plate Pants","Fancy Plate Shirt","Plate Helm +4","Ornate Plate Pants","Upgrade Armorer","Upgrade Miner","Hire an additional Miner"],
  540. //20:["Forge Steel Plates"],
  541. },
  542. },
  543. {
  544. taskName:"Leatherworking",
  545. level: {
  546. 0:["Leatherworking_Tier0_Intro_1"],
  547. 1:["Leatherworking_Tier1_Leather_Boots_1","Leatherworking_Tier1_Leather_Shirt_1"],
  548. 2:["Leatherworking_Tier1_Leather_Armor_1","Leatherworking_Tier1_Leather_Pants_1"],
  549. 3:["Leatherworking_Tier1_Leather_Armor_1","Leatherworking_Tier1_Leather_Boots_Set_1"],
  550. 4:["Leatherworking_Tier1_Leather_Armor_1","Leatherworking_Tier1_Leather_Boots_Set_1"],
  551. 5:["Leatherworking_Tier1_Leather_Armor_Set_1","Leatherworking_Tier1_Leather_Boots_Set_1"],
  552. 6:["Leatherworking_Tier1_Leather_Armor_Set_1","Leatherworking_Tier1_Leather_Boots_Set_1"],
  553. 7:["Leatherworking_Tier1_Leather_Armor_Set_1","Leatherworking_Tier2_Leather_Boots_Set_1","Leatherworking_Tier2_Leather_Shirt"],
  554. 8:["Leatherworking_Tier2_Leather_Armor_Set_1","Leatherworking_Tier2_Leather_Pants_1","Leatherworking_Tier2_Leather_Boots_Set_1","Leatherworking_Tier2_Leather_Shirt"],
  555. 9:["Leatherworking_Tier2_Leather_Armor_Set_1","Leatherworking_Tier2_Leather_Pants_1","Leatherworking_Tier2_Leather_Boots_Set_1","Leatherworking_Tier2_Leather_Shirt"],
  556. 10:["Leatherworking_Tier2_Leather_Armor_Set_1","Leatherworking_Tier2_Leather_Pants_1","Leatherworking_Tier2_Leather_Boots_Set_1","Leatherworking_Tier2_Leather_Shirt_2"],
  557. 11:["Leatherworking_Tier2_Leather_Armor_Set_1","Leatherworking_Tier2_Leather_Pants_2","Leatherworking_Tier2_Leather_Boots_Set_1","Leatherworking_Tier2_Leather_Shirt_2","Leatherworking_Tier2_Leather_Pants_1"],
  558. 12:["Leatherworking_Tier2_Leather_Armor_Set_1","Leatherworking_Tier2_Leather_Pants_2","Leatherworking_Tier2_Leather_Boots_Set_1","Leatherworking_Tier2_Leather_Shirt_2","Leatherworking_Tier2_Leather_Pants_1"],
  559. 13:["Leatherworking_Tier2_Leather_Armor_Set_1","Leatherworking_Tier2_Leather_Pants_2","Leatherworking_Tier2_Leather_Boots_Set_1","Leatherworking_Tier2_Leather_Shirt_2","Leatherworking_Tier2_Leather_Pants_1"],
  560. 14:["Leatherworking_Tier2_Leather_Armor_Set_1","Leatherworking_Tier2_Leather_Pants_2","Ornate Leatherworking_Tier1_Leather_Shirt_1","Leatherworking_Tier3_Leather_Boots_Set_1"],
  561. 15:["Leatherworking_Tier3_Leather_Armor_Set_1","Leatherworking_Tier3_Leather_Pants","Leatherworking_Tier3_Leather_Shirt2","Leatherworking_Tier3_Leather_Boots_Set_1"],
  562. 16:["Leatherworking_Tier3_Leather_Armor_Set_1","Leatherworking_Tier3_Leather_Pants2","Leatherworking_Tier3_Leather_Shirt2","Leatherworking_Tier3_Leather_Helm_Set_1","Leatherworking_Tier3_Leather_Pants"],
  563. 17:["Leatherworking_Tier3_Leather_Armor_Set_1","Leatherworking_Tier3_Leather_Pants2","Leatherworking_Tier3_Leather_Shirt2","Leatherworking_Tier3_Leather_Helm_Set_1","Leatherworking_Tier3_Leather_Pants"],
  564. 18:["Leatherworking_Tier3_Leather_Armor_Set_1","Leatherworking_Tier3_Leather_Pants2","Leatherworking_Tier3_Leather_Shirt2","Leatherworking_Tier3_Leather_Helm_Set_1","Leatherworking_Tier3_Leather_Pants"],
  565. 19:["Leatherworking_Tier3_Leather_Armor_Set_1","Leatherworking_Tier3_Leather_Pants2","Leatherworking_Tier3_Leather_Shirt2","Leatherworking_Tier3_Leather_Helm_Set_1","Leatherworking_Tier3_Leather_Pants"],
  566. 20:["Leatherworking_Tier2_Refine_Basic"],
  567. //19:["Leather Armor +4","Fancy Leather Pants","Fancy Leather Shirt","Leather Helm +4","Ornate Leather Pants","Upgrade Tanner","Upgrade Skinner","Hire an additional Skinner"],
  568. //20:["Cure Tough Pelts"],
  569. },
  570. },
  571. {
  572. taskName:"Tailoring",
  573. level: {
  574. 0:["Tailoring_Tier0_Intro"],
  575. 1:["Tailoring_Tier1_Cloth_Boots_1","Tailoring_Tier1_Cloth_Shirt_1"],
  576. 2:["Tailoring_Tier1_Cloth_Armor_1","Tailoring_Tier1_Cloth_Pants_1"],
  577. 3:["Tailoring_Tier1_Cloth_Armor_1","Tailoring_Tier1_Cloth_Boots_Set_1"],
  578. 4:["Tailoring_Tier1_Cloth_Armor_1","Tailoring_Tier1_Cloth_Boots_Set_1"],
  579. 5:["Tailoring_Tier1_Cloth_Armor_Set_1","Tailoring_Tier1_Cloth_Boots_Set_1"],
  580. 6:["Tailoring_Tier1_Cloth_Armor_Set_1","Tailoring_Tier1_Cloth_Boots_Set_1"],
  581. 7:["Tailoring_Tier1_Cloth_Armor_Set_1","Tailoring_Tier2_Cloth_Boots_Set_1","Tailoring_Tier2_Cloth_Shirt"],
  582. 8:["Tailoring_Tier2_Cloth_Armor_Set_1","Tailoring_Tier2_Cloth_Pants_1","Tailoring_Tier2_Cloth_Boots_Set_1","Tailoring_Tier2_Cloth_Shirt"],
  583. 9:["Tailoring_Tier2_Cloth_Armor_Set_1","Tailoring_Tier2_Cloth_Pants_1","Tailoring_Tier2_Cloth_Boots_Set_1","Tailoring_Tier2_Cloth_Shirt"],
  584. 10:["Tailoring_Tier2_Cloth_Armor_Set_1","Tailoring_Tier2_Cloth_Pants_1","Tailoring_Tier2_Cloth_Boots_Set_1","Tailoring_Tier2_Cloth_Shirt_2"],
  585. 11:["Tailoring_Tier2_Cloth_Armor_Set_1","Tailoring_Tier2_Cloth_Pants_2","Tailoring_Tier2_Cloth_Boots_Set_1","Tailoring_Tier2_Cloth_Shirt_2","Tailoring_Tier2_Cloth_Pants_1"],
  586. 12:["Tailoring_Tier2_Cloth_Armor_Set_1","Tailoring_Tier2_Cloth_Pants_2","Tailoring_Tier2_Cloth_Boots_Set_1","Tailoring_Tier2_Cloth_Shirt_2","Tailoring_Tier2_Cloth_Pants_1"],
  587. 13:["Tailoring_Tier2_Cloth_Armor_Set_1","Tailoring_Tier2_Cloth_Pants_2","Tailoring_Tier2_Cloth_Boots_Set_1","Tailoring_Tier2_Cloth_Shirt_2","Tailoring_Tier2_Cloth_Pants_1"],
  588. 14:["Tailoring_Tier2_Cloth_Armor_Set_1","Tailoring_Tier2_Cloth_Pants_2", "Tailoring_Tier3_Cloth_Shirt","Tailoring_Tier3_Cloth_Boots_Set_1"],
  589. 15:["Tailoring_Tier3_Cloth_Armor_Set_1","Tailoring_Tier3_Cloth_Pants","Tailoring_Tier3_Cloth_Shirt2","Tailoring_Tier3_Cloth_Boots_Set_1"],
  590. 16:["Tailoring_Tier3_Cloth_Armor_Set_1","Tailoring_Tier3_Cloth_Pants2","Tailoring_Tier3_Cloth_Shirt2","Tailoring_Tier3_Cloth_Helm_Set_1","Tailoring_Tier3_Cloth_Pants"],
  591. 17:["Tailoring_Tier3_Cloth_Armor_Set_1","Tailoring_Tier3_Cloth_Pants2","Tailoring_Tier3_Cloth_Shirt2","Tailoring_Tier3_Cloth_Helm_Set_1","Tailoring_Tier3_Cloth_Pants"],
  592. 18:["Tailoring_Tier3_Cloth_Armor_Set_1","Tailoring_Tier3_Cloth_Pants2","Tailoring_Tier3_Cloth_Shirt2","Tailoring_Tier3_Cloth_Helm_Set_1","Tailoring_Tier3_Cloth_Pants"],
  593. 19:["Tailoring_Tier3_Cloth_Armor_Set_1","Tailoring_Tier3_Cloth_Pants2","Tailoring_Tier3_Cloth_Shirt2","Tailoring_Tier3_Cloth_Helm_Set_1","Tailoring_Tier3_Cloth_Pants"],
  594. 20:["Tailoring_Tier2_Refine_Basic"],
  595. //19:["Cloth Robes +4","Fancy Cloth Pants","Fancy Cloth Shirt","Cloth Cap +4","Ornate Cloth Pants","Upgrade Outfitter","Upgrade Weaver","Hire an additional Weaver"],
  596. //20:["Weave Cotton Cloth"],
  597. },
  598. },
  599. {
  600. taskName:"Artificing",
  601. level: {
  602. 0:["Artificing_Tier0_Intro_1"],
  603. 1:["Artificing_Tier1_Symbol_Virtuous_1"],
  604. 2:["Artificing_Tier1_Icon_Virtuous_1"],
  605. 3:["Artificing_Tier1_Icon_Virtuous_1"],
  606. 4:["Artificing_Tier1_Icon_Virtuous_2"],
  607. 5:["Artificing_Tier1_Icon_Virtuous_2"],
  608. 6:["Artificing_Tier1_Icon_Virtuous_2"],
  609. 7:["Artificing_Tier1_Icon_Virtuous_2"],
  610. 8:["Artificing_Tier2_Icon_Virtuous_3"],
  611. 9:["Artificing_Tier2_Icon_Virtuous_3"],
  612. 10:["Artificing_Tier2_Icon_Virtuous_3"],
  613. 11:["Artificing_Tier2_Icon_Virtuous_3"],
  614. 12:["Artificing_Tier2_Icon_Virtuous_3"],
  615. 13:["Artificing_Tier2_Icon_Virtuous_3"],
  616. 14:["Artificing_Tier3_Icon_Virtuous_4"],
  617. 15:["Artificing_Tier3_Icon_Virtuous_4"],
  618. 16:["Artificing_Tier3_Icon_Virtuous_4"],
  619. 17:["Artificing_Tier3_Icon_Virtuous_5"],
  620. 18:["Artificing_Tier3_Icon_Virtuous_5"],
  621. 19:["Artificing_Tier3_Icon_Virtuous_5"],
  622. 20:["Artificing_Tier2_Refine_Basic"],
  623. //19:["Virtuous Icon +5","Upgrade Engraver","Upgrade Carver","Hire an additional Carver"],
  624. //20:["7:Craft Ornamental metal and Carved Wood"],
  625. },
  626. },
  627. {
  628. taskName:"Weaponsmithing",
  629. level: {
  630. 0:["Weaponsmithing_Tier0_Intro"],
  631. 1:["Weaponsmithing_Tier1_Dagger_1"],
  632. 2:["Weaponsmithing_Tier1_Dagger_1"],
  633. 3:["Weaponsmithing_Tier1_Dagger_1"],
  634. 4:["Weaponsmithing_Tier1_Dagger_2"],
  635. 5:["Weaponsmithing_Tier1_Dagger_2"],
  636. 6:["Weaponsmithing_Tier1_Dagger_2"],
  637. 7:["Weaponsmithing_Tier2_Dagger_3"],
  638. 8:["Weaponsmithing_Tier2_Dagger_3"],
  639. 9:["Weaponsmithing_Tier2_Dagger_3"],
  640. 10:["Weaponsmithing_Tier2_Dagger_3"],
  641. 11:["Weaponsmithing_Tier2_Dagger_3"],
  642. 12:["Weaponsmithing_Tier2_Dagger_3"],
  643. 13:["Weaponsmithing_Tier2_Dagger_3"],
  644. 14:["Weaponsmithing_Tier3_Dagger_4"],
  645. 15:["Weaponsmithing_Tier3_Dagger_4"],
  646. 16:["Weaponsmithing_Tier3_Dagger_4"],
  647. 17:["Weaponsmithing_Tier3_Dagger_4"],
  648. 18:["Weaponsmithing_Tier3_Dagger_4"],
  649. 19:["Weaponsmithing_Tier3_Dagger_4"],
  650. 20:["Weaponsmithing_Tier2_Refine_Basic"],
  651. //19:["Dagger+4","Upgrade Grinder","Upgrade Smelter","Hire an additional Smelter"],
  652. //20:["Craft Steel Blades and Barausk Hafts"],
  653. },
  654. },
  655. {
  656. taskName:"Alchemy",
  657. level: {
  658. 0:["Alchemy_Tier0_Intro_1"],
  659. 1:["Alchemy_Tier1_Experiment_Rank2","Alchemy_Tier1_Experimentation_Rank1",],
  660. 2:["Alchemy_Tier1_Experiment_Rank3","Alchemy_Tier1_Experimentation_Rank2"],
  661. 3:["Alchemy_Tier1_Experiment_Rank4","Alchemy_Tier1_Experimentation_Rank3"],
  662. 4:["Alchemy_Tier1_Experiment_Rank5","Alchemy_Tier1_Experimentation_Rank4"],
  663. 5:["Alchemy_Tier1_Experiment_Rank6","Alchemy_Tier1_Experimentation_Rank5"],
  664. 6:["Alchemy_Tier1_Experiment_Rank7","Alchemy_Tier1_Experimentation_Rank6"],
  665. 7:["Alchemy_Tier2_Experiment_Rank08","Alchemy_Tier2_Experimentation_Rank07"],
  666. 8:["Alchemy_Tier2_Experiment_Rank09","Alchemy_Tier2_Experimentation_Rank08"],
  667. 9:["Alchemy_Tier2_Experiment_Rank10","Alchemy_Tier2_Experimentation_Rank09"],
  668. 10:["Alchemy_Tier2_Experiment_Rank11","Alchemy_Tier2_Experimentation_Rank10"],
  669. 11:["Alchemy_Tier2_Experiment_Rank12","Alchemy_Tier2_Experimentation_Rank11"],
  670. 12:["Alchemy_Tier2_Experiment_Rank13","Alchemy_Tier2_Experimentation_Rank12"],
  671. 13:["Alchemy_Tier2_Experiment_Rank14","Alchemy_Tier2_Experimentation_Rank13"],
  672. 14:["Alchemy_Tier3_Experiment_Rank15","Alchemy_Tier3_Experimentation_Rank14"],
  673. 15:["Alchemy_Tier3_Experiment_Rank16","Alchemy_Tier3_Experimentation_Rank15"],
  674. 16:["Alchemy_Tier3_Experiment_Rank17","Alchemy_Tier3_Experimentation_Rank16"],
  675. 17:["Alchemy_Tier3_Experiment_Rank18","Alchemy_Tier3_Experimentation_Rank17"],
  676. 18:["Alchemy_Tier3_Experiment_Rank19","Alchemy_Tier3_Experimentation_Rank18"],
  677. 19:["Alchemy_Tier3_Experiment_Rank20","Alchemy_Tier3_Experimentation_Rank19"],
  678. 20:["Alchemy_Tier3_Experimentation_Rank20"],
  679. //19:["Alchemical Research","Rank 20 Experimentation","Upgrade Mixologist","Upgrade Apothecary","Hire an additional Apothecary"],
  680. //20:["Rank 20 Experimentation"],
  681. },
  682. },
  683. ];
  684. // Load Settings
  685. var settingnames = [
  686. {name: 'paused', title: 'Pause Script', def: false, type:'checkbox', tooltip:'Disable All Automation'},
  687. {name: 'debug', title: 'Enable Debug', def: false, type:'checkbox', tooltip:'Enable all debug output to console', onsave: function(newValue, oldValue) {console=newValue?unsafeWindow.console||fouxConsole:fouxConsole;}},
  688. {name: 'optionals', title: 'Fill Optional Assets', def: true, type:'checkbox', tooltip:'Enable to include selecting the optional assets of tasks'},
  689. {name: 'autopurchase', title: 'Auto Purchase Resources', def: true, type:'checkbox', tooltip:'Automatically purchase required resources from gateway shop (100 at a time)'},
  690. {name: 'trainassets', title: 'Train Assets', def: true, type:'checkbox', tooltip:'Enable training/upgrading of asset worker resources'},
  691. {name: 'refinead', title: 'Refine AD', def: true, type:'checkbox', tooltip:'Enable refining of AD on character switch'},
  692. {name: 'autoreload', title: 'Auto Reload', def: false, type:'checkbox', tooltip:'Enabling this will reload the gateway periodically. (Ensure Auto Login is enabled)'},
  693. {name: 'autologin', title: 'Attempt to login automatically', def: false, type:'checkbox', tooltip:'Automatically attempt to login to the neverwinter gateway site'},
  694. {name: 'nw_username', title: ' Neverwinter Username', def: '', type:'text', tooltip:''},
  695. {name: 'nw_password', title: ' Neverwinter Password', def: '', type:'password', tooltip:''},
  696. {name: 'charcount', title: ' Number of Characters', def: '2', type:'text', tooltip:'Enter number of characters to use (reload page to update settings form)'},
  697. ];
  698. // Load local settings cache (unsecured)
  699. var settings = {};
  700. for (var i = 0; i < settingnames.length; i++) {
  701. // Ignore label types
  702. if (settingnames[i].type === 'label') {
  703. continue;
  704. }
  705. settings[settingnames[i].name] = GM_getValue(settingnames[i].name, settingnames[i].def);
  706. // call the onsave for the setting if it exists
  707. if (typeof(settingnames[i].onsave) === "function") {
  708. console.log("Calling 'onsave' for", settingnames[i].name);
  709. settingnames[i].onsave(settings[settingnames[i].name], settings[settingnames[i].name]);
  710. }
  711. }
  712. if (settings["charcount"]<1) { settings["charcount"] = 1; }
  713. if (settings["charcount"]>99) { settings["charcount"] = 99; }
  714.  
  715. var charSettings = [];
  716. for (var i = 0; i < settings["charcount"]; i++) {
  717. charSettings.push({name: 'nw_charname'+i, title: 'Character', def: 'Character '+(i+1), type:'text', tooltip:'Characters Name'});
  718. charSettings.push({name: 'Leadership'+i, title: 'Leadership', def: '9', type:'text', tooltip:'Number of slots to assign to Leadership'});
  719. charSettings.push({name: 'Armorsmithing_Med'+i, title: 'Mailsmithing', def: '0', type:'text', tooltip:'Number of slots to assign to Mailsmithing'});
  720. charSettings.push({name: 'Armorsmithing_Heavy'+i, title: 'Platesmithing', def: '0', type:'text', tooltip:'Number of slots to assign to Platesmithing'});
  721. charSettings.push({name: 'Leatherworking'+i, title: 'Leatherworking', def: '0', type:'text', tooltip:'Number of slots to assign to Leatherworking'});
  722. charSettings.push({name: 'Tailoring'+i, title: 'Tailoring', def: '0', type:'text', tooltip:'Number of slots to assign to Tailoring'});
  723. charSettings.push({name: 'Artificing'+i, title: 'Artificing', def: '0', type:'text', tooltip:'Number of slots to assign to Artificing'});
  724. charSettings.push({name: 'Weaponsmithing'+i, title: 'Weaponsmithing', def: '0', type:'text', tooltip:'Number of slots to assign to Weaponsmithing'});
  725. charSettings.push({name: 'Alchemy'+i, title: 'Alchemy', def: '0', type:'text', tooltip:'Number of slots to assign to Alchemy'});
  726.  
  727. // task settings are slightly different
  728. charSettings.push({name: 'tasklist'+i, title: 'Task List', def: '', type:'void', tooltip:''});
  729. }
  730. for (var i = 0; i < charSettings.length; i++) {
  731. settings[charSettings[i].name] = GM_getValue(charSettings[i].name, charSettings[i].def);
  732. }
  733. // Page Settings
  734. var PAGES = Object.freeze({
  735. LOGIN : { name: "Login", path: "div#login"},
  736. GUARD : { name: "Account Guard", path: "div#page-accountguard"},
  737. });
  738.  
  739. /**
  740. * Uses the page settings to determine which page is currently displayed
  741. */
  742. function GetCurrentPage() {
  743. for (var i = 0; i < PAGES.length; i++) {
  744. if ($(PAGES[i]["path"]).filter(":visible").length) {
  745. return PAGES[i];
  746. }
  747. }
  748. }
  749. /**
  750. * Logs in to gateway
  751. * No client.dataModel exists at this stage
  752. */
  753. function page_LOGIN() {
  754. //if (!$("form > p.error:visible").length && settings["autologin"]) {
  755. // No previous log in error - attempt to log in
  756. console.log("Setting username");
  757. $("input#user").val(settings["nw_username"]);
  758. console.log("Setting password");
  759. $("input#pass").val(settings["nw_password"]);
  760. console.log("Clicking Login Button");
  761. $("div#login > input").click();
  762. //}
  763. dfdNextRun.resolve(delay.LONG);
  764. }
  765. /**
  766. * Action to perform on account guard page
  767. */
  768. function page_GUARD() {
  769. // Do nothing on the guard screen
  770. dfdNextRun.resolve(delay.LONG);
  771. }
  772.  
  773. /**
  774. * Collects rewards for tasks or starts new tasks
  775. * Function is called once per new task and returns true if an action is created
  776. * If no action is started function returns false to switch characters
  777. */
  778. function processCharacter() {
  779. // Switch to professions page to show task progression
  780. unsafeWindow.location.hash="#char("+encodeURI(unsafeWindow.client.getCurrentCharAtName())+")/professions";
  781. // Collect rewards for completed tasks and restart
  782. if (unsafeWindow.client.dataModel.model.ent.main.itemassignments.complete) {
  783. unsafeWindow.client.dataModel.model.ent.main.itemassignments.assignments.forEach(function(entry) {
  784. if (entry.hascompletedetails) { unsafeWindow.client.professionTaskCollectRewards(entry.uassignmentid); }
  785. });
  786. dfdNextRun.resolve();
  787. return true;
  788. }
  789. // Check for available slots and start new task
  790. if (unsafeWindow.client.dataModel.model.ent.main.itemassignments.assignments.filter(function(entry) { return (!entry.islockedslot && !entry.uassignmentid); }).length) {
  791. // Go through the professions to assign tasks until specified slots filled
  792. for (var i = 0; i < tasklist.length; i++) {
  793. var currentTasks = unsafeWindow.client.dataModel.model.ent.main.itemassignments.assignments.filter(function(entry) { return entry.category == tasklist[i].taskName; });
  794. if (currentTasks.length < settings[tasklist[i].taskName]) {
  795. unsafeWindow.client.professionFetchTaskList('craft_' + tasklist[i].taskName);
  796. unsafeWindow.client.dataModel.fetchVendor('Nw_Gateway_Professions_Merchant');
  797. window.setTimeout(function() { createNextTask(tasklist[i], 0); }, delay.SHORT);
  798. return true;
  799. }
  800. }
  801. console.log("All task counts assigned");
  802. }
  803. else {
  804. console.log("No available task slots");
  805. }
  806. // TODO: Add code to get next task finish time
  807. return false;
  808. }
  809.  
  810. /**
  811. * Iterative approach to finding the next task to assign to an open slot.
  812. *
  813. * @param {Array} prof The tasklist for the profession being used
  814. * @param {int} i The current task number being attempted
  815. */
  816. function createNextTask(prof, i) {
  817. // TODO: Use callback function
  818. if (!unsafeWindow.client.dataModel.model.craftinglist || unsafeWindow.client.dataModel.model.craftinglist === null || !unsafeWindow.client.dataModel.model.craftinglist['craft_' + prof.taskName] || unsafeWindow.client.dataModel.model.craftinglist['craft_' + prof.taskName] === null) {
  819. console.log('Task list not loaded for:', prof.taskName);
  820. window.setTimeout(function() { createNextTask(prof, i); }, delay.SHORT);
  821. return false;
  822. }
  823.  
  824. // Check level
  825. var level = unsafeWindow.client.dataModel.model.ent.main.itemassignmentcategories.categories.filter(function(entry) { return entry.name == prof.taskName; })[0].currentrank;
  826. var list = prof.level[level];
  827. if (list.length <=i) {
  828. console.log("Nothing Found");
  829. switchChar();
  830. return false;
  831. }
  832. console.log(prof.taskName, "is level", level);
  833. console.log("createNextTask", list.length, i);
  834.  
  835. var taskName = list[i];
  836. console.log("Searching for task:", taskName);
  837. // Search for task to start
  838. var task = searchForTask(taskName, prof.taskName);
  839.  
  840. /** TODO: Use this code once below can be replaced properly
  841. if (task === null) {
  842. console.log("Skipping task selection to purchase resources");
  843. dfdNextRun.resolve();
  844. }
  845. else if (task) {
  846. startTask(task);
  847. dfdNextRun.resolve();
  848. }
  849. else {
  850. console.log('Finding next task');
  851. createNextTask(prof, i+1);
  852. }
  853. **/
  854.  
  855.  
  856. // Finish createNextTask function
  857. if (task === null) {
  858. console.log("Skipping task selection to purchase resources");
  859. dfdNextRun.resolve();
  860. return true;
  861. }
  862. if (task) {
  863. task = '/professions-tasks/' + prof.taskName + '/' + task.def.name;
  864. console.log('Task Found');
  865. unsafeWindow.location.hash = unsafeWindow.location.hash.replace(/\)\/.+/,')' + task);
  866. WaitForState("div.page-professions-taskdetails").done(function() {
  867. // Click all buttons and select an item to use in the slot
  868. var def = $.Deferred();
  869. var buttonList = $("h3:contains('Optional Assets:')").closest("div").find("button");
  870. if (buttonList.length && settings["optionals"]) {
  871. SelectItemFor(buttonList, 0, def, prof);
  872. }
  873. else {
  874. def.resolve();
  875. }
  876. def.done(function() {
  877. // All items are populated
  878. console.log("Items Populated");
  879. // Click the Start Task Button
  880. //Get the start task button if it is enabled
  881. var enabledButton = $("div.footer-body > div.input-field.button:not('.disabled') > button:contains('Start Task')");
  882. if (enabledButton.length) {
  883. console.log("Clicking Start Task Button");
  884. enabledButton.click();
  885. WaitForState("").done(function() {
  886. // Done
  887. dfdNextRun.resolve(delay.SHORT);
  888. });
  889. return true;
  890. }
  891. else { // Button not enabled, something required was probably missing
  892. // Go back
  893. $("div.footer-body > div.input-field.button > button:contains('Back')").click();
  894. WaitForState("").done(function() {
  895. // continue with the next one
  896. console.log('Finding next task');
  897. createNextTask(prof, i+1);
  898. });
  899. }
  900. });
  901. });
  902. }
  903. else {
  904. console.log('Finding next task');
  905. createNextTask(prof, i+1);
  906. }
  907. }
  908. /**
  909. * Checks task being started for requirements and initiates beginning task if found
  910. *
  911. * @param {string} taskname The name of the task being started
  912. * @param {string} profname The name of the profession being used
  913. * @param {Deferred} dfd Deferred object to process on return
  914. */
  915. function searchForTask(taskname, profname) {
  916. // Return first object that matches exact craft name
  917. var thisTask = unsafeWindow.client.dataModel.model.craftinglist['craft_' + profname].entries.filter(function(entry) {
  918. return entry.def && entry.def.name == taskname;
  919. })[0];
  920. // If no task is returned we either have three of this task already, the task is a rare that doesn't exist currently, or we have the name wrong in tasklist
  921. if (!thisTask) {
  922. console.log('Could not find task for:', taskname);
  923. return false;
  924. }
  925. // start task if requirements are met
  926. if (!thisTask.failedrequirementsreasons.length) {
  927. return thisTask;
  928. }
  929. // Too high level
  930. if (thisTask.failslevelrequirements) {
  931. console.log("Task level is too high:", taskname);
  932. return false;
  933. }
  934. var searchItem = null;
  935. var searchAsset = false;
  936. // Missing assets or ingredients
  937. if (thisTask.failsresourcesrequirements) {
  938. var failedAssets = thisTask.required.filter(function(entry) { return !entry.fillsrequirements; });
  939. // Missing required assets
  940. if (failedAssets.length) {
  941. var failedCrafter = failedAssets.filter(function(entry) { return entry.categories.indexOf("Person") >= 0; });
  942. if (failedCrafter.length && settings["trainassets"]) {
  943. console.log("Found required asset:", failedCrafter[0].icon);
  944. searchItem = failedCrafter[0].icon;
  945. searchAsset = true;
  946. }
  947. else {
  948. // TODO: Automatically purchase item assets from shop
  949. console.log("Not enough assets for task:", taskname);
  950. return false;
  951. }
  952. }
  953.  
  954. // Check for craftable or buyable ingredients
  955. else {
  956. var failedResources = thisTask.consumables.filter(function(entry) { return entry.required && !entry.fillsrequirements; });
  957. // Check first required ingredient only
  958. // If it fails to buy or craft task cannot be completed anyway
  959. // If it succeeds script will search for tasks anew
  960. var itemName = failedResources[0].hdef.match(/\[(\w+)\]/)[1];
  961. // purchase buyable resources
  962. if (itemName.match(/^Crafting_Resource_(Charcoal|Rocksalt|Spool_Thread|Porridge|Solvent|Brimstone|Coal|Moonseasalt|Quicksilver|Spool_Threadsilk)$/)) {
  963. if (settings["autopurchase"]) {
  964. buyResource(itemName);
  965. return null;
  966. }
  967. else {
  968. console.log("Buyable resource required for:", taskname);
  969. return false;
  970. }
  971. }
  972. // craft ingredient items
  973. else {
  974. console.log("Found required ingredient:", itemName);
  975. searchItem = itemName;
  976. }
  977. }
  978. }
  979. // either no craftable items/assets found or other task requirements are not met
  980. // Skip crafting ingredient tasks for Leadership
  981. if (searchItem === null || !searchItem.length || (profname == 'Leadership' && !searchAsset && !searchItem.match(/Crafting_Asset_Craftsman/))) {
  982. console.log("Failed to resolve item requirements for task:", taskname);
  983. return false;
  984. }
  985.  
  986. // Generate list of available tasks to search ingredients/assets from
  987. console.log("Searching ingredient tasks for:", profname);
  988. var taskList = unsafeWindow.client.dataModel.model.craftinglist['craft_' + profname].entries.filter(function(entry) {
  989. // remove header lines first to avoid null def
  990. if (entry.isheader) { return false; }
  991. // Too high level
  992. if (entry.failslevelrequirements) { return false; }
  993. // Rewards do not contain item we want to make
  994. if (searchAsset) {
  995. if (entry.def.icon != searchItem || !entry.def.name.match(/Recruit/) || entry.def.requiredrank > 14) { return false; }
  996. }
  997. else {
  998. if (!(entry.rewards.some(function (itm) { try { return itm.hdef.match(/\[(\w+)\]/)[1] == searchItem; } catch(e) {} }))) { return false; }
  999. }
  1000. // Skip mass production tasks
  1001. if (entry.def.displayname.match(/^(Batch|Mass|Deep|Intensive) /)) { return false; }
  1002. // Skip trading tasks
  1003. if (entry.def.displayname.match(/rading$/)) { return false; }
  1004. // Skip looping Transmute tasks
  1005. if (entry.def.displayname.match(/^(Transmute|Create) /)) { return false; }
  1006. return true;
  1007. });
  1008. if (!taskList.length) {
  1009. console.log("No ingredient tasks found for:", taskname, searchItem);
  1010. return false;
  1011. }
  1012. // Use more efficient Empowered task for Aqua Vitae if available.
  1013. if (searchItem == "Crafting_Resource_Aquavitae" && taskList.length > 1) { taskList.shift(); }
  1014. // Should really only be one result now but lets iterate through anyway.
  1015. for (var i = 0; i < taskList.length; i++) {
  1016. console.log("Attempting search for ingredient task:", taskList[i].def.name);
  1017. var task = searchForTask(taskList[i].def.name, profname);
  1018. if (task === null || task) {
  1019. return task;
  1020. }
  1021. }
  1022. return false;
  1023. }
  1024. /**
  1025. * Fills resource slots and begins a profession task
  1026. *
  1027. * @param {string} taskDetail The craftindetail object for the task to be started
  1028. */
  1029. function startTask(taskDetail) {
  1030. return;
  1031. unsafeWindow.client.professionFetchTaskDetail(taskDetail.def.name);
  1032. //client.dataModel.addDefaultResources();
  1033. client.professionStartAssignment(taskDetail.def.name);
  1034. }
  1035.  
  1036. /**
  1037. * Selects the highest level asset for the i'th button in the list. Uses an iterative approach
  1038. * in order to apply a sufficient delay after the asset is assigned
  1039. *
  1040. * @param {Array} The list of buttons to use to click and assign assets for
  1041. * @param {int} i The current iteration number. Will select assets for the i'th button
  1042. * @param {Deferred} jQuery Deferred object to resolve when all of the assets have been assigned
  1043. */
  1044. function SelectItemFor(buttonListIn, i, def, prof) {
  1045. buttonListIn[i].click();
  1046. WaitForState("").done(function() {
  1047. var specialItems = $("div.modal-item-list a.Special");
  1048. var goldItems = $("div.modal-item-list a.Gold");
  1049. var silverItems = $("div.modal-item-list a.Silver");
  1050. var bronzeItems = $("div.modal-item-list a.Bronze");
  1051. var clicked = false;
  1052.  
  1053. // Try to avoid using up higher rank assets needlessly
  1054. if (prof.taskName === "Leadership") {
  1055. var mercenarys = $("div.modal-item-list a.Bronze:contains('Mercenary')");
  1056. var guards = $("div.modal-item-list a.Bronze:contains('Guard')");
  1057. var footmen = $("div.modal-item-list a.Bronze:contains('Footman')");
  1058.  
  1059. if (mercenarys.length) { clicked = true; mercenarys[0].click(); }
  1060. else if (guards.length) { clicked = true; guards[0].click(); }
  1061. else if (footmen.length) { clicked = true; footmen[0].click(); }
  1062. }
  1063. // TODO: add remaining professions in the same way for bronze tier assets.
  1064.  
  1065. if (!clicked) {
  1066. // Click the highest slot
  1067. if (specialItems.length) { specialItems[0].click(); }
  1068. else if (goldItems.length) { goldItems[0].click(); }
  1069. else if (silverItems.length) { silverItems[0].click(); }
  1070. else if (bronzeItems.length) { bronzeItems[0].click(); }
  1071. else { $("button.close-button").click(); }
  1072. }
  1073.  
  1074. console.log("Clicked item");
  1075. WaitForState("").done(function() {
  1076. // Get the new set of select buttons created since the other ones are removed when the asset loads
  1077. var buttonList = $("h3:contains('Optional Assets:')").closest("div").find("button");
  1078. if (i < buttonList.length - 1) {
  1079. SelectItemFor(buttonList, i+1, def, prof);
  1080. }
  1081. else {
  1082. // Let main loop continue
  1083. def.resolve();
  1084. }
  1085. });
  1086. });
  1087. }
  1088. /**
  1089. * Will buy a given purchasable resource
  1090. *
  1091. * @param {String} item The data-tt-item id of the Resource to purchase
  1092. */
  1093. function buyResource(item) {
  1094. console.log("Purchasing resources:", item);
  1095. var resourceID = {
  1096. Crafting_Resource_Charcoal : 0,
  1097. Crafting_Resource_Rocksalt : 1,
  1098. Crafting_Resource_Spool_Thread : 2,
  1099. Crafting_Resource_Porridge : 3,
  1100. Crafting_Resource_Solvent : 4,
  1101. Crafting_Resource_Brimstone : 5,
  1102. Crafting_Resource_Coal : 6,
  1103. Crafting_Resource_Moonseasalt : 7,
  1104. Crafting_Resource_Quicksilver : 8,
  1105. Crafting_Resource_Spool_Threadsilk : 9,
  1106. };
  1107. // Make purchase
  1108. unsafeWindow.client.sendCommand("GatewayVendor_PurchaseVendorItem",{vendor:'Nw_Gateway_Professions_Merchant',store:'Store_Crafting_Resources',idx:resourceID[item],count:100});
  1109. WaitForState("button.closeNotification").done(function() {
  1110. $("button.closeNotification").click();
  1111. });
  1112. }
  1113. function switchChar() {
  1114. if (settings["refinead"]) {
  1115. var _currencies = unsafeWindow.client.dataModel.model.ent.main.currencies;
  1116. if (_currencies.diamondsconvertleft && _currencies.roughdiamonds) {
  1117. console.log("Refining AD");
  1118. unsafeWindow.client.sendCommand('Gateway_ConvertNumeric', 'Astral_Diamonds');
  1119. }
  1120. }
  1121.  
  1122. console.log("Switching Characters");
  1123. if (++charcurrent >= settings["charcount"]) { charcurrent = 0; }
  1124. GM_setValue("charcurrent", charcurrent);
  1125. dfdNextRun.resolve(delay.SHORT);
  1126. }
  1127. /**
  1128. * Waits for the loading symbol to be hidden.
  1129. *
  1130. * @return {Deferred} A jQuery defferred object that will be resolved when loading is complete
  1131. */
  1132. function WaitForLoad() {
  1133. return WaitForState("");
  1134. }
  1135. /**
  1136. * Creates a deferred object that will be resolved when the state is reached
  1137. *
  1138. * @param {string} query The query for the state to wait for
  1139. * @return {Deferred} A jQuery defferred object that will be resolved when the state is reached
  1140. */
  1141. function WaitForState(query) {
  1142. var dfd = $.Deferred();
  1143. window.setTimeout(function() {AttemptResolve(query, dfd);}, delay.SHORT); // Doesn't work without a short delay
  1144. return dfd;
  1145. }
  1146. /**
  1147. * Will continually test for the given query state and resolve the given deferred object when the state is reached
  1148. * and the loading symbol is not visible
  1149. *
  1150. * @param {string} query The query for the state to wait for
  1151. * @param {Deferred} dfd The jQuery defferred object that will be resolved when the state is reached
  1152. */
  1153. function AttemptResolve(query, dfd) {
  1154. if ((query === "" || $(query).length) && $("div.loading-image:visible").length === 0) {
  1155. dfd.resolve();
  1156. }
  1157. else {
  1158. window.setTimeout(function() {AttemptResolve(query, dfd);}, delay.SHORT); // Try again in a little bit
  1159. }
  1160. }
  1161.  
  1162. /**
  1163. * The main process loop:
  1164. * - Determine which page we are on and call the page specific logic
  1165. * - When processing is complete, process again later
  1166. * - Use a short timer when something changed last time through
  1167. * - Use a longer timer when waiting for tasks to complete
  1168. */
  1169. function process() {
  1170. // Make sure the settings button exists
  1171. addSettings();
  1172.  
  1173. // Enable/Disable the unconditional page reload depending on settings
  1174. loading_reset = settings["autoreload"];
  1175.  
  1176. // Check if timer is paused
  1177. s_paused = settings["paused"]; // let the Page Reloading function know the pause state
  1178. if (settings["paused"]) {
  1179. // Just continue later - the deferred object is still set and nothing will resolve it until we get past this point
  1180. var timerHandle = window.setTimeout(function() {process();}, delay.DEFAULT);
  1181. return;
  1182. }
  1183.  
  1184. // Check for Gateway down
  1185. if (window.location.href.indexOf("gatewaysitedown") > -1) {
  1186. // Do a long delay and then retry the site
  1187. console.log("Gateway down detected - relogging in " + (delay.MINS/1000) + " seconds");
  1188. window.setTimeout(function() {unsafeWindow.location.href = "http://gateway.playneverwinter.com";}, delay.MINS);
  1189. return;
  1190. }
  1191.  
  1192. // Check for login or account guard and process accordingly
  1193. var currentPage = GetCurrentPage();
  1194. if (currentPage == PAGES.LOGIN) { page_LOGIN(); return; }
  1195. else if (currentPage == PAGES.GUARD) { page_GUARD(); return; }
  1196. window.setTimeout(function() {loginProcess();}, delay.SHORT);
  1197. // Continue again later
  1198. dfdNextRun.done(function(delayTimer) {
  1199. dfdNextRun = $.Deferred();
  1200. timerHandle = window.setTimeout(function() {process();}, typeof delayTimer!== 'undefined' ? delayTimer:delay.DEFAULT);
  1201. });
  1202. }
  1203. function loginProcess() {
  1204. // Get logged on account details
  1205. var accountName;
  1206. try {
  1207. accountName = unsafeWindow.client.dataModel.model.loginInfo.publicaccountname;
  1208. }
  1209. catch (e) {
  1210. // TODO: Use callback function
  1211. window.setTimeout(function() {loginProcess();}, delay.SHORT);
  1212. return;
  1213. }
  1214. // Check if timer is paused again to avoid starting new task between timers
  1215. s_paused = settings["paused"]; // let the Page Reloading function know the pause state
  1216. if (settings["paused"]) {
  1217. // Just continue later - the deferred object is still set and nothing will resolve it until we get past this point
  1218. var timerHandle = window.setTimeout(function() {process();}, delay.DEFAULT);
  1219. return;
  1220. }
  1221.  
  1222. if (accountName) {
  1223. // load current character position and values
  1224. charcurrent = GM_getValue("charcurrent", 0);
  1225. for (var i = 0; i < (charSettings.length/settings["charcount"]); i++) {
  1226. j = i + (charcurrent*charSettings.length/settings["charcount"]);
  1227. settings[charSettings[j].name.replace(new RegExp(charcurrent+"$"),'')] = settings[charSettings[j].name];
  1228. }
  1229. // Load task list from settings if saved
  1230. if (settings["tasklist"].length) {
  1231. tasklist = JSON.parse(settings["tasklist"]);
  1232. }
  1233. else {
  1234. tasklist = defaultTasklist;
  1235. }
  1236.  
  1237. var charName = settings["nw_charname"];
  1238. var fullCharName = charName + '@' + accountName;
  1239.  
  1240. if (unsafeWindow.client.getCurrentCharAtName() != fullCharName) {
  1241. loadCharacter(fullCharName);
  1242. return;
  1243. }
  1244.  
  1245. // Try to start tasks
  1246. if (processCharacter()) { return; }
  1247.  
  1248. // Switch characters as necessary
  1249. switchChar();
  1250. }
  1251. }
  1252.  
  1253. function loadCharacter(charname) {
  1254. // Load character and restart next load loop
  1255. console.log("Loading gateway script for", charname);
  1256. unsafeWindow.client.dataModel.loadEntityByName(charname);
  1257. dfdNextRun.resolve();
  1258. }
  1259. function addSettings() {
  1260. if ($("#settingsButton").length)
  1261. return;
  1262. // Add the required CSS
  1263. AddCss("\
  1264. #settingsButton{border-bottom: 1px solid rgb(102, 102, 102); border-right: 1px solid rgb(102, 102, 102); background: none repeat scroll 0% 0% rgb(238, 238, 238); display: block; position: fixed; overflow: auto; right: 0px; top: 0px; padding: 3px; z-index: 1000;}\
  1265. #pauseButton{border-bottom: 1px solid rgb(102, 102, 102); border-right: 1px solid rgb(102, 102, 102); background: none repeat scroll 0% 0% rgb(238, 238, 238); display: block; position: fixed; overflow: auto; right: 23px; top: 0px; padding: 3px; z-index: 1000;}\
  1266. #settingsPanel{border-bottom: 1px solid rgb(102, 102, 102); border-right: 1px solid rgb(102, 102, 102); background: none repeat scroll 0% 0% rgb(238, 238, 238); color: rgb(0, 0, 0); position: fixed; overflow: auto; right: 0px; top: 0px; width: 350px;max-height:750px;font: 12px sans-serif; text-align: left; display: block; z-index: 1000;}\
  1267. #settings_title{font-weight: bolder; background: none repeat scroll 0% 0% rgb(204, 204, 204); border-bottom: 1px solid rgb(102, 102, 102); padding: 3px;}\
  1268. #settingsPanelButtonContainer {background: none repeat scroll 0% 0% rgb(204, 204, 204); border-top: 1px solid rgb(102, 102, 102);padding: 3px;text-align:center} \
  1269. #settingsPanel label.purple {font-weight:bold;color:#7C37F6}\
  1270. #settingsPanel label.blue {font-weight:bold;color:#007EFF}\
  1271. #settingsPanel label.green {font-weight:bold;color:#8AFF00}\
  1272. #settingsPanel label.white {font-weight:bold;color:#FFFFFF}\
  1273. #charPanel {width:340px;max-height:400px;overflow:auto;display:block;padding:3px;}\
  1274. ");
  1275.  
  1276. // Add settings panel to page body
  1277. $("body").append(
  1278. '<div id="settingsPanel">\
  1279. <div id="settings_title">\
  1280. <img src='+image_prefs+' style="float: left; vertical-align: text-bottom;"\>\
  1281. <img id="settings_close" src='+image_close+' title="Click to hide preferences" style="float: right; vertical-align: text-bottom; cursor: pointer; display: block;"\>\
  1282. <span style="margin:3px">Settings</span>\
  1283. </div>\
  1284. <form style="margin: 0px; padding: 0px">\
  1285. <ul style="list-style: none outside none; max-height: 500px; overflow: auto; margin: 3px; padding: 0px;">\
  1286. </ul>\
  1287. </form>\
  1288. </div>'
  1289. );
  1290.  
  1291. // Add each setting input
  1292. var settingsList = $("#settingsPanel form ul");
  1293. for (var i = 0; i < settingnames.length; i++) {
  1294. var id = 'settings_' + settingnames[i].name;
  1295. var indent = countLeadingSpaces(settingnames[i].title) * 2;
  1296. switch(settingnames[i].type) {
  1297. case "checkbox":
  1298. settingsList.append('<li title="'+settingnames[i].tooltip+'" style="margin-left:'+indent+'em"><input style="margin:4px" name="'+id+'" id="'+id+'" type="checkbox" /><label class="'+settingnames[i].class+'" for="'+id+'">'+settingnames[i].title+'</label></li>')
  1299. $('#'+id).prop('checked', settings[settingnames[i].name]);
  1300. break;
  1301. case "text":
  1302. settingsList.append('<li title="'+settingnames[i].tooltip+'" style="margin-left:'+indent+'em"><label class="'+settingnames[i].class+'" for="'+id+'">'+settingnames[i].title+'</label><input style="margin:4px" name="'+id+'" id="'+id+'" type="text" /></li>')
  1303. $('#'+id).val(settings[settingnames[i].name]);
  1304. break;
  1305. case "password":
  1306. settingsList.append('<li title="'+settingnames[i].tooltip+'" style="margin-left:'+indent+'em"><label class="'+settingnames[i].class+'" for="'+id+'">'+settingnames[i].title+'</label><input style="margin:4px" name="'+id+'" id="'+id+'" type="password" /></li>')
  1307. $('#'+id).val(settings[settingnames[i].name]);
  1308. break;
  1309. case "select":
  1310. settingsList.append('<li title="'+settingnames[i].tooltip+'" style="margin-left:'+indent+'em"><label class="'+settingnames[i].class+'" style="padding-left:4px" for="'+id+'">'+settingnames[i].title+'</label><select style="margin:4px" name="'+id+'" id="'+id+'" /></li>')
  1311. var options = settingnames[i].opts;
  1312. var select = $('#'+id);
  1313. for (var j = 0; j < options.length; j++) {
  1314. if (settings[settingnames[i].name] == options[j].path)
  1315. select.append('<option value="'+options[j].path+'" selected="selected">'+options[j].name+'</option>');
  1316. else
  1317. select.append('<option value="'+options[j].path+'">'+options[j].name+'</option>');
  1318. }
  1319. break;
  1320. case "label":
  1321. settingsList.append('<li title="'+settingnames[i].tooltip+'" style="margin-left:'+indent+'em;><label class="'+settingnames[i].class+'">'+settingnames[i].title+'</label></li>')
  1322. break;
  1323. }
  1324. }
  1325. // Add character settings for each char
  1326. var addText = '\
  1327. <script type="text/javascript">\
  1328. <!--\
  1329. function click_position(obj)\
  1330. {\
  1331. change_position(obj.value)\
  1332. }\
  1333. \
  1334. function change_position(val)\
  1335. {\
  1336. for (var i = 0; i < '+settings["charcount"]+'; i++)\
  1337. {\
  1338. document.getElementById("charContainer"+i).style.display="none";\
  1339. }\
  1340. document.getElementById("charContainer"+val).style.display="block";\
  1341. }\
  1342. //-->\
  1343. </script>\
  1344. <div id="charPanel">\
  1345. <div style="width:150px;float:left;max-height:400px;overflow:auto;">\
  1346. ';
  1347. for (var i = 0; i < settings["charcount"]; i++) {
  1348. addText += '\
  1349. <div><input autocomplete="off" type="radio" name="radio_position" onclick="click_position(this)" id="value_'+i+'" value="'+i+'" /><label for="value_'+i+'">'+settings["nw_charname"+i]+'</label></div>\
  1350. ';
  1351. }
  1352. addText += '\
  1353. </div>\
  1354. <div style="width:170px;float:right;">\
  1355. ';
  1356. for (var i = 0; i < settings["charcount"]; i++) {
  1357. addText += '\
  1358. <div id="charContainer'+i+'" style="display:none">\
  1359. <ul style="list-style: none outside none; max-height: 500px; overflow: auto;">\
  1360. ';
  1361. var k = 0 + (i*charSettings.length/settings["charcount"]);
  1362. var id = 'settings_' + charSettings[k].name;
  1363. addText += '<li title="'+charSettings[k].tooltip+'"><input style="margin:4px" name="'+id+'" id="'+id+'" type="text" /></li>';
  1364. for (var j = 1; j < (charSettings.length/settings["charcount"]); j++) {
  1365. k = j + (i*charSettings.length/settings["charcount"]);
  1366. if (charSettings[k].type == 'void') { continue; }
  1367. id = 'settings_' + charSettings[k].name;
  1368. addText += '<li title="'+charSettings[k].tooltip+'"><input maxlength="2" size="1" style="margin:4px" name="'+id+'" id="'+id+'" type="text" /><label class="'+charSettings[k].class+'" for="'+id+'">'+charSettings[k].title+'</label></li>';
  1369. }
  1370. addText += '</ul>'
  1371.  
  1372. // Add task list save buttons
  1373. addText += '\
  1374. <input id="save_tasklist'+i+'" type="button" value="Save Tasks" title="Saves current task list in script to this character">\
  1375. <input id="clear_tasklist'+i+'" type="button" value="Clear Tasks" title="Clears the saved task list for this character to use defaults">\
  1376. </div>';
  1377. }
  1378. addText += '\
  1379. </div>\
  1380. </div>\
  1381. ';
  1382. $("#settingsPanel form").append(addText);
  1383.  
  1384. // Add values to character input fields
  1385. for (var i = 0; i < charSettings.length; i++) {
  1386. id = 'settings_' + charSettings[i].name;
  1387. $('#'+id).val(settings[charSettings[i].name]);
  1388. }
  1389. // Add code to tasklist buttons
  1390. for (var i = 0; i < settings["charcount"]; i++) {
  1391. $("#save_tasklist"+i).click(function() {
  1392. var num = this.id.replace("save_tasklist", "");
  1393. charSettings["tasklist"+num] = tasklist;
  1394. setTimeout(function() { GM_setValue("tasklist"+num, JSON.stringify(defaultTasklist)); }, 0);
  1395. });
  1396. $("#clear_tasklist"+i).click(function() {
  1397. var num = this.id.replace("clear_tasklist", "");
  1398. charSettings["tasklist"+num] = "";
  1399. setTimeout(function() { GM_setValue("tasklist"+num, ""); }, 0);
  1400. });
  1401. }
  1402.  
  1403. // Add save/cancel buttons to panel
  1404. $("#settingsPanel form").append('\
  1405. <div id="settingsPanelButtonContainer">\
  1406. <input id="settings_save" type="button" value="Save and Apply">\
  1407. <input id="settings_close" type="button" value="Close">\
  1408. </div>');
  1409.  
  1410. // Add open settings button to page
  1411. $("body").append('<div id="settingsButton"><img src="'+image_prefs+'" title="Click to show preferences" style="cursor: pointer; display: block;"></div>');
  1412.  
  1413. // Add pause button to page
  1414. $("body").append('<div id="pauseButton"><img src="'+(settings["paused"]?image_play:image_pause)+'" title="Click to '+(settings["paused"]?"resume":"pause")+' task script" style="cursor: pointer; display: block;"></div>');
  1415.  
  1416. // Add the javascript
  1417. $("#settingsPanel").hide();
  1418. $("#settingsButton").click(function() {
  1419. $("#settingsButton").hide();
  1420. $("#pauseButton").hide();
  1421. $("#settingsPanel").show();
  1422. });
  1423. $("#settings_close,settings_cancel").click(function() {
  1424. $("#settingsButton").show();
  1425. $("#pauseButton").show();
  1426. $("#settingsPanel").hide();
  1427. });
  1428. $("#pauseButton").click(function() {
  1429. settings["paused"] = !settings["paused"]
  1430. setTimeout(function() { GM_setValue("paused", settings["paused"]); }, 0);
  1431. $("#settings_paused").prop("checked", settings["paused"]);
  1432. $("#pauseButton img").attr("src",(settings["paused"]?image_play:image_pause));
  1433. $("#pauseButton img").attr("title","Click to "+(settings["paused"]?"resume":"pause")+" task script");
  1434. });
  1435.  
  1436. // Use setTimeout to workaround permission issues when calling GM functions from main window
  1437. $("#settings_save").click(function() { setTimeout(function() { SaveSettings();}, 0)});
  1438. }
  1439.  
  1440. function SaveSettings() {
  1441. var charcount = settings["charcount"];
  1442.  
  1443. // Get each value from the UI
  1444. for (var i = 0; i < settingnames.length; i++) {
  1445. var name = settingnames[i].name;
  1446. var el = $('#settings_' + name);
  1447. var value = false;
  1448. switch(settingnames[i].type) {
  1449. case "checkbox":
  1450. value = el.prop("checked");
  1451. break;
  1452. case "text":
  1453. value = el.val();
  1454. break;
  1455. case "password":
  1456. value = el.val();
  1457. break;
  1458. case "select":
  1459. value = el.val();
  1460. break;
  1461. case "label": // Labels don't have values
  1462. continue;
  1463. }
  1464. if (typeof(settingnames[i].onsave) === "function") {
  1465. console.log("Calling 'onsave' for", name);
  1466. settingnames[i].onsave(value, settings[name]);
  1467. }
  1468. if (settings[name] !== value) { settings[name] = value; } // Save to local cache
  1469. if (GM_getValue(name) !== value) { GM_setValue(name, value); } // Save to GM cache
  1470. }
  1471.  
  1472. // Get character settings from UI
  1473. for (var i = 0; i < charSettings.length; i++) {
  1474. if (charSettings[i].type == 'void') { continue; }
  1475. var name = charSettings[i].name;
  1476. var el = $('#settings_' + name);
  1477. var value = el.val();
  1478. if (settings[name] !== value) { settings[name] = value; } // Save to local cache
  1479. if (GM_getValue(name) !== value) { GM_setValue(name, value); } // Save to GM cache
  1480. }
  1481. // If character numbers have changed reload page
  1482. if (charcount != settings["charcount"]) {
  1483. console.log("Reloading Gateway to update character count");
  1484. unsafeWindow.location.href = "http://gateway.playneverwinter.com";
  1485. return;
  1486. }
  1487.  
  1488. // Delete all saved settings
  1489. if (settingwipe) {
  1490. var keys = GM_listValues();
  1491. for (var i = 0, key = null; key = keys[i]; i++) {
  1492. GM_deleteValue(key);
  1493. }
  1494. }
  1495. // Close the panel
  1496. $("#settingsButton").show();
  1497. $("#pauseButton img").attr("src",(settings["paused"]?image_play:image_pause));
  1498. $("#pauseButton img").attr("title","Click to "+(settings["paused"]?"resume":"pause")+" task script");
  1499. $("#pauseButton").show();
  1500. $("#settingsPanel").hide();
  1501. }
  1502.  
  1503. // Add the settings button and start a process timer
  1504. addSettings();
  1505. timerHandle = window.setTimeout(function() {process();}, delay.SHORT);
  1506. })();