Hordes UI Mod

Various UI mods for Hordes.io.

目前为 2021-05-12 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Hordes UI Mod
  3. // @version 1.5.1
  4. // @description Various UI mods for Hordes.io.
  5. // @author Sakaiyo & Chandog#6373 & Cullen & RevoGen
  6. // @match https://hordes.io/play
  7. // @grant GM_addStyle
  8. // @namespace https://greasyfork.org/users/160017
  9. // ==/UserScript==
  10.  
  11. GM_addStyle(`.uimod-skill-tooltip {
  12. width: 260px;
  13. position: fixed;
  14. display: none; }
  15. .uimod-skill-tooltip .description {
  16. /* Mirrors color of normal tooltip description */
  17. color: #5b858e; }
  18. .uimod-skill-tooltip .uimod-skill-tooltip-text {
  19. color: white; }
  20. /* Custom chat context menu, invisible by default */
  21. .js-chat-context-menu {
  22. display: none; }
  23.  
  24. .js-chat-context-menu .name {
  25. color: white;
  26. padding: 2px 4px; }
  27.  
  28. /* Allow names in chat to be clicked (textf1 = BL, textf0 = VG) */
  29. #chat .name,
  30. .textwhisper .textf1,
  31. .textwhisper .textf0 {
  32. pointer-events: all !important; }
  33. /* Custom chat filter colors */
  34. .js-chat-gm {
  35. color: #a6dcd5; }
  36.  
  37. /* Class that hides chat lines */
  38. .js-line-hidden,
  39. .js-line-blocked {
  40. display: none; }
  41. /* Custom chat tabs */
  42. .uimod-chat-tabs {
  43. position: fixed;
  44. margin-top: -22px;
  45. left: 5px;
  46. pointer-events: all;
  47. color: #5b858e;
  48. font-size: 12px;
  49. font-weight: bold; }
  50.  
  51. .uimod-chat-tabs > div {
  52. cursor: pointer;
  53. background-color: rgba(0, 0, 0, 0.4);
  54. border-top-right-radius: 4px;
  55. border-top-left-radius: 4px;
  56. display: inline-block;
  57. border: 1px black solid;
  58. border-bottom: 0;
  59. margin-right: 2px;
  60. padding: 3px 5px; }
  61.  
  62. .uimod-chat-tabs > div:not(.js-selected-tab):hover {
  63. border-color: #aaa; }
  64.  
  65. .uimod-chat-tabs > .js-selected-tab {
  66. color: #fff; }
  67.  
  68. /* Chat tab custom config */
  69. .uimod-chat-tab-config {
  70. position: absolute;
  71. z-index: 9999999;
  72. background-color: rgba(0, 0, 0, 0.6);
  73. color: white;
  74. border-radius: 3px;
  75. text-align: center;
  76. padding: 8px 12px 8px 6px;
  77. width: 175px;
  78. font-size: 14px;
  79. border: 1px solid black;
  80. display: none; }
  81.  
  82. .uimod-chat-tab-config-grid {
  83. grid-template-columns: 35% 65%;
  84. display: grid;
  85. grid-gap: 6px;
  86. align-items: center; }
  87.  
  88. .uimod-chat-tab-config h1 {
  89. font-size: 16px;
  90. margin-top: 0; }
  91.  
  92. .uimod-chat-tab-config .btn,
  93. .uimod-chat-tab-config input {
  94. font-size: 12px; }
  95. /* Lazy way to get tables to display side by side, given they share their container with various other elements */
  96. .uimod-clan-lastseen-table {
  97. float: right;
  98. width: 25%;
  99. /* Make the last seen table look like its part of the main clan members table */
  100. position: relative;
  101. right: 1px;
  102. border-top-left-radius: 0;
  103. border-bottom-left-radius: 0; }
  104. .uimod-clan-lastseen-table tr.js-offline-member {
  105. opacity: 0.5; }
  106.  
  107. .uimod-clan-members-table {
  108. float: left;
  109. width: 75%; }
  110. /* Allows windows and frames to be moved */
  111. .window,
  112. .partyframes,
  113. #ufplayer,
  114. #uftarget,
  115. #skillbar,
  116. .js-map {
  117. position: relative; }
  118.  
  119. /* Retaining the default party frame with so we can override the "style" property */
  120. .partyframes {
  121. width: 200px; }
  122.  
  123. /* All purpose hidden class */
  124. .js-hidden {
  125. display: none; }
  126. /* Friends list CSS, similar to settings but supports 4 columns */
  127. .uimod-friends {
  128. display: grid;
  129. grid-template-columns: 2fr 1.1fr 1.5fr 0.33fr 3fr;
  130. grid-gap: 8px;
  131. align-items: center;
  132. max-height: 390px;
  133. margin: 0 20px;
  134. overflow-y: auto; }
  135.  
  136. /* Helps imitate normal UI window */
  137. .uimod-friends-list-helper.titleframe {
  138. line-height: 1em;
  139. display: flex;
  140. align-items: start;
  141. position: relative;
  142. letter-spacing: 0.5px;
  143. margin-top: 8px; }
  144.  
  145. .uimod-friends-list-helper.titleicon {
  146. margin: 3px; }
  147.  
  148. .uimod-friends-list-helper.title {
  149. width: 100%;
  150. padding-left: 4px;
  151. font-weight: bold; }
  152.  
  153. .uimod-friends-intro {
  154. width: 100%;
  155. margin: 4px 0 14px;
  156. text-align: center;
  157. border-bottom: 2px solid #999;
  158. padding-bottom: 6px;
  159. font-weight: bold;
  160. user-select: none; }
  161. .uimod-locked-slot {
  162. pointer-events: all;
  163. z-index: 10;
  164. background: rgba(255, 0, 0, 0.4);
  165. position: absolute;
  166. width: 46px;
  167. height: 46px; }
  168. .js-map-btns {
  169. position: absolute;
  170. top: 8px;
  171. right: 8px;
  172. z-index: 999;
  173. width: 100px;
  174. height: 100px;
  175. text-align: right;
  176. display: none;
  177. pointer-events: all; }
  178.  
  179. .js-map-btns:hover {
  180. display: block; }
  181.  
  182. .js-map-btns button {
  183. border-radius: 10px;
  184. font-size: 18px;
  185. padding: 0 5px;
  186. background: rgba(0, 0, 0, 0.4);
  187. border: 0;
  188. color: white;
  189. font-weight: bold;
  190. cursor: pointer; }
  191.  
  192. /* On hover of map, show opacity controls */
  193. .js-map:hover .js-map-btns {
  194. display: block; }
  195. /* Mirror styles of other merchant inputs */
  196. .uidom-merchant-input {
  197. margin: 4px 0;
  198. align-self: center; }
  199.  
  200. /* Add 225px column for new filters input */
  201. .uidom-merchant-with-filters .search {
  202. grid-template-columns: 120px auto 50px auto 50px 225px 1fr auto auto; }
  203. .js-chat-resize {
  204. resize: both;
  205. overflow: auto; }
  206. .js-map {
  207. /* This makes sure scroll bars don't appear when resizing the map */
  208. overflow: hidden; }
  209.  
  210. .js-map-resize:hover {
  211. resize: both;
  212. overflow: auto;
  213. direction: rtl; }
  214. /* Screenshot Mod Warning CSS. Similar to the warning you get in chrome when entering full-screen since that's familiar and positioned to be below full-screen warning */
  215. .uimod-screenshot-warning {
  216. margin: auto;
  217. display: block;
  218. text-align: center;
  219. margin-top: 100px;
  220. width: 250px;
  221. padding: 13px;
  222. color: #fff;
  223. background: rgba(39, 41, 45, 0.74); }
  224.  
  225. .uimod-screenshot-warning-container {
  226. width: 100%;
  227. position: absolute; }
  228.  
  229. /* Applied to warning after a short delay to fadeout */
  230. .uimod-screenshot-warning-fadeout {
  231. visibility: hidden;
  232. opacity: 0;
  233. transition: visibility 0s 1s, opacity 1s linear; }
  234. /* Allows last clicked window to appear above all other windows */
  235. .js-is-top {
  236. z-index: 9998 !important; }
  237.  
  238. .panel.context:not(.commandlist) {
  239. z-index: 9999 !important; }
  240.  
  241. /* The item icon being dragged in the inventory */
  242. .container.svelte-snq3jh {
  243. z-index: 9999 !important; }
  244. .js-cooldown-num {
  245. position: absolute;
  246. bottom: 10px;
  247. left: 0;
  248. width: 40px;
  249. text-align: center;
  250. font-weight: bold;
  251. color: white;
  252. pointer-events: none; }
  253. .container.uimod-xpmeter-1 {
  254. z-index: 6; }
  255.  
  256. .window.uimod-xpmeter-2 {
  257. padding: 5px;
  258. height: 100%;
  259. display: grid;
  260. grid-template-rows: 30px 1fr;
  261. grid-gap: 4px;
  262. transform-origin: inherit;
  263. min-width: fit-content; }
  264.  
  265. .titleframe.uimod-xpmeter-2 {
  266. line-height: 1em;
  267. display: flex;
  268. align-items: center;
  269. position: relative;
  270. letter-spacing: 0.5px; }
  271.  
  272. .titleicon.uimod-xpmeter-2 {
  273. margin: 3px; }
  274.  
  275. .title.uimod-xpmeter-2 {
  276. width: 100%;
  277. padding-left: 4px;
  278. font-weight: bold; }
  279.  
  280. .slot.uimod-xpmeter-2 {
  281. min-height: 0; }
  282.  
  283. .wrapper.uimod-xpmeter-1 {
  284. width: 200px; }
  285.  
  286. .bar.uimod-xpmeter-3 {
  287. background-color: rgba(45, 66, 71, 0.7);
  288. border-radius: 1.5px;
  289. position: relative;
  290. color: #DAE8EA;
  291. overflow: hidden;
  292. text-shadow: 1px 1px 2px #10131d;
  293. white-space: nowrap;
  294. text-transform: capitalize;
  295. font-weight: bold; }
  296.  
  297. .buttons.uimod-xpmeter-1 {
  298. line-height: 1;
  299. font-size: 13px; }
  300.  
  301. .left.uimod-xpmeter-3 {
  302. padding-left: 4px;
  303. position: relative;
  304. z-index: 1; }
  305.  
  306. .right.uimod-xpmeter-3 {
  307. position: absolute;
  308. right: 7px;
  309. z-index: 1; }
  310. /* Custom css for settings page, duplicates preexisting settings pane grid */
  311. .uimod-settings,
  312. .uimod-mod-toggler {
  313. user-select: none;
  314. display: grid;
  315. grid-template-columns: 2fr 3fr;
  316. grid-gap: 8px;
  317. align-items: center;
  318. max-height: 390px;
  319. margin: 0 20px;
  320. overflow-y: auto; }
  321.  
  322. .uimod-mod-toggler-window {
  323. max-height: 525px !important; }
  324.  
  325. .uimod-mod-toggler {
  326. grid-template-columns: 1fr 3fr 1.5fr 1.5fr;
  327. grid-gap: 12px 6px; }
  328. .uimod-mod-toggler .uimod-mod-name {
  329. font-weight: bold;
  330. font-size: 16px; }
  331. .uimod-mod-toggler .uimod-mod-desc {
  332. font-style: italic; }
  333. .uimod-mod-toggler .uimod-mod-state {
  334. color: #ffffff;
  335. font-weight: bold; }
  336.  
  337. .uimod-disclaimer {
  338. font-size: 13px;
  339. font-weight: bold;
  340. margin-bottom: 8px; }
  341. /* This file is for CSS mods that don't fit in any other individual mod folder */
  342. /* Transparent chat bg color */
  343. .frame.svelte-1vrlsr3 {
  344. background: rgba(0, 0, 0, 0.4); }
  345.  
  346. /* Our mod's chat message color */
  347. .textuimod {
  348. color: #00dd33; }
  349.  
  350. /* The browser resize icon */
  351. *::-webkit-resizer {
  352. background: linear-gradient(to right, rgba(51, 77, 80, 0), rgba(203, 202, 165, 0.5));
  353. border-radius: 8px;
  354. box-shadow: 0 1px 1px black; }
  355.  
  356. *::-moz-resizer {
  357. background: linear-gradient(to right, rgba(51, 77, 80, 0), rgba(203, 202, 165, 0.5));
  358. border-radius: 8px;
  359. box-shadow: 0 1px 1px black; }
  360.  
  361. /* Our custom window, closely mirrors main settings window */
  362. .uimod-custom-window {
  363. position: absolute;
  364. top: 100px;
  365. left: 50%;
  366. transform: translate(-50%, 0);
  367. min-width: 350px;
  368. max-width: 600px;
  369. width: 90%;
  370. height: 80%;
  371. min-height: 350px;
  372. max-height: 500px;
  373. z-index: 9;
  374. padding: 0px 10px 5px; }
  375. }
  376. `);
  377.  
  378. (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
  379. "use strict";
  380.  
  381. var _mods = _interopRequireDefault(require("./mods"));
  382.  
  383. var _state = require("./utils/state");
  384.  
  385. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  386.  
  387. function initialize() {
  388. // If the Hordes.io tab isn't active for long enough, it reloads the entire page, clearing this mod
  389. // We check for that and reinitialize the mod if that happens
  390. const $layout = document.querySelector('.layout');
  391.  
  392. if ($layout.classList.contains('uimod-initd')) {
  393. return;
  394. }
  395.  
  396. $layout.classList.add('uimod-initd');
  397. (0, _state.loadState)();
  398. const state = (0, _state.getState)();
  399. const rerunning = {
  400. // MutationObserver running whenever .layout changes
  401. onDomChange: [],
  402. // Mutation observer running whenever #chat changes
  403. onChatChange: [],
  404. // `click` Event listener running on document.body
  405. onLeftClick: [],
  406. // `contextmenu` Event listener running on document.body
  407. onRightClick: []
  408. }; // Run all our mods
  409.  
  410. const registerOnDomChange = callback => rerunning.onDomChange.push(callback);
  411.  
  412. const registerOnChatChange = callback => rerunning.onChatChange.push(callback);
  413.  
  414. const registerOnLeftClick = callback => rerunning.onLeftClick.push(callback);
  415.  
  416. const registerOnRightClick = callback => rerunning.onRightClick.push(callback);
  417.  
  418. const disabledMods = state.disabledMods;
  419.  
  420. _mods.default.forEach(mod => {
  421. if (disabledMods.includes(mod.name) || mod.disabled) return;
  422.  
  423. try {
  424. mod.run({
  425. registerOnDomChange,
  426. registerOnChatChange,
  427. registerOnLeftClick,
  428. registerOnRightClick
  429. });
  430. } catch (modError) {
  431. console.error(`UI Mod Error: Problem running mod ${mod.name}, error:`, modError);
  432. }
  433. }); // Continuously re-run specific mods methods that need to be executed on UI change
  434.  
  435.  
  436. const rerunObserver = new MutationObserver(mutations => {
  437. // If new window appears, e.g. even if window is closed and reopened, we need to rewire it
  438. // Fun fact: Some windows always exist in the DOM, even when hidden, e.g. Inventory
  439. // But some windows only exist in the DOM when open, e.g. Interaction
  440. rerunning.onDomChange.forEach(callback => callback(mutations));
  441. });
  442. Array.from(document.querySelectorAll('.layout > .container, .actionbarcontainer, .partyframes, .targetframes')).forEach($container => {
  443. rerunObserver.observe($container, {
  444. attributes: false,
  445. childList: true
  446. });
  447. }); // Rerun only on chat messages changing
  448.  
  449. const chatRerunObserver = new MutationObserver(mutations => {
  450. rerunning.onChatChange.forEach(callback => callback(mutations));
  451. });
  452. chatRerunObserver.observe(document.querySelector('#chat'), {
  453. attributes: false,
  454. childList: true
  455. }); // Event listeners for document.body might be kept when the game reloads, so don't reinitialize them
  456.  
  457. if (!document.body.classList.contains('js-uimod-initd')) {
  458. document.body.classList.add('js-uimod-initd');
  459. rerunning.onLeftClick.forEach(callback => document.body.addEventListener('click', callback));
  460. rerunning.onRightClick.forEach(callback => document.body.addEventListener('contextmenu', callback));
  461. }
  462. } // Initialize mods once UI DOM has loaded
  463. // Rerunning updates on every call to initialize
  464.  
  465.  
  466. const pageObserver = new MutationObserver(() => {
  467. const isUiLoaded = !!document.querySelector('.layout');
  468.  
  469. if (isUiLoaded) {
  470. initialize();
  471. }
  472. });
  473. pageObserver.observe(document.body, {
  474. attributes: true,
  475. childList: true
  476. });
  477.  
  478. },{"./mods":27,"./utils/state":52}],2:[function(require,module,exports){
  479. "use strict";
  480.  
  481. Object.defineProperty(exports, "__esModule", {
  482. value: true
  483. });
  484. exports.registerSettingsMenuItem = registerSettingsMenuItem;
  485. exports.default = void 0;
  486.  
  487. var _misc = require("../../utils/misc");
  488.  
  489. var _ui = require("../../utils/ui");
  490.  
  491. var _modTogglerUi = require("./modTogglerUi");
  492.  
  493. var _modSettingsUi = require("./modSettingsUi");
  494.  
  495. const registeredSettings = [];
  496.  
  497. function customSettings() {
  498. const $settings = document.querySelector('.divide:not(.js-settings-initd)');
  499.  
  500. if (!$settings) {
  501. return;
  502. }
  503.  
  504. $settings.classList.add('js-settings-initd');
  505. const $settingsChoiceList = $settings.querySelector('.choice').parentNode; // Append all the registered settings links
  506.  
  507. registeredSettings.forEach(({
  508. windowName,
  509. label
  510. }) => {
  511. $settingsChoiceList.appendChild((0, _misc.makeElement)({
  512. element: 'div',
  513. class: `choice js-${windowName}-open`,
  514. content: label
  515. }));
  516. }); // TODO: Make this a setting in the new settings window
  517.  
  518. $settingsChoiceList.appendChild((0, _misc.makeElement)({
  519. element: 'div',
  520. class: 'choice js-reset-ui-pos',
  521. content: 'Reset UI Positions'
  522. })); // Reset positions immediately upon click
  523.  
  524. document.querySelector('.js-reset-ui-pos').addEventListener('click', _ui.resetUiPositions); // Upon settings item click, open window
  525.  
  526. registeredSettings.forEach(({
  527. windowName,
  528. handleOpenWindow
  529. }) => {
  530. document.querySelector(`.js-${windowName}-open`).addEventListener('click', handleOpenWindow);
  531. }); // If it was open when the game last closed keep it open
  532.  
  533. registeredSettings.forEach(({
  534. windowName,
  535. handleOpenWindow
  536. }) => {
  537. if ((0, _ui.isWindowOpen)(windowName) && !document.querySelector(`.js-${windowName}`)) {
  538. handleOpenWindow();
  539. }
  540. });
  541. } // `windowName` is used to create class names and check if the window is open in the UI
  542. // Pass `ui.WindowNames.x` to this argument.
  543. // Setting the window name in ui.js WindowNames ensure other mods can check if the window is open, just in case they need to
  544. // `handleOpenWindow` is a callback that is triggered when the user clicks the settings item.
  545. // The window it opens must have a css class matching `js-${windowName}`, e.g. if windowName is `block-list`, the CSS class for your created window must be `js-block-list`
  546. // `label` is the text visible in the Settings menu
  547.  
  548.  
  549. function registerSettingsMenuItem({
  550. windowName,
  551. handleOpenWindow,
  552. label
  553. }) {
  554. registeredSettings.push({
  555. windowName,
  556. handleOpenWindow,
  557. label
  558. });
  559. } // TODO: function to register settings ption in the custom mod settings window
  560.  
  561.  
  562. var _default = {
  563. name: '[REQUIRED] Custom settings',
  564. description: 'Do not disable this Adds Reset UI Position, Mod Toggler, and Mod Settings to Hordes settings window. Allows for custom settings to be added',
  565. run: ({
  566. registerOnDomChange
  567. }) => {
  568. // Register ui.js window names
  569. _ui.WindowNames.modToggler = 'mod-toggler';
  570. _ui.WindowNames.uiModSettings = 'mod-settings'; // TODO: Finish
  571. // // Register settings
  572. // registerSettingsMenuItem({
  573. // windowName: WindowNames.uiModSettings,
  574. // handleOpenWindow: createModSettings,
  575. // label: 'UI Mod Settings',
  576. // });
  577.  
  578. registerSettingsMenuItem({
  579. windowName: _ui.WindowNames.modToggler,
  580. handleOpenWindow: _modTogglerUi.createModToggler,
  581. label: 'Toggle Mods'
  582. });
  583. customSettings(); // If the settings window becomes visible/invisible, we want to update it
  584.  
  585. registerOnDomChange(customSettings);
  586. },
  587. required: true
  588. };
  589. exports.default = _default;
  590.  
  591. },{"../../utils/misc":50,"../../utils/ui":53,"./modSettingsUi":3,"./modTogglerUi":4}],3:[function(require,module,exports){
  592. "use strict";
  593.  
  594. Object.defineProperty(exports, "__esModule", {
  595. value: true
  596. });
  597. exports.createModSettings = createModSettings;
  598. exports.removeModSettings = removeModSettings;
  599.  
  600. var _misc = require("../../utils/misc");
  601.  
  602. var _ui = require("../../utils/ui");
  603.  
  604. // TODO Should have 4 configs:
  605. // Toggle for state.enableWindowDragging,
  606. // state.enableFrameDragging,
  607. // state.healthBarFadeColor = 'orange',
  608. // state.healthBarFadeColor = 'red'
  609. // state.healthBarFadePercent = 50,
  610. // state.healthBarFadePercent = 100,
  611. function createModSettings() {
  612. let modSettingsHTML = '';
  613. const customSettingsHTML = `
  614. <h3 class="textprimary">UI Mod Settings</h3>
  615. <div class="settings uimod-mod-settings js-mod-settings-list">${modSettingsHTML}</div>
  616. <p></p>
  617. <div class="btn purp js-close-mod-settings">Close</div>
  618. `;
  619. const $customSettings = (0, _misc.makeElement)({
  620. element: 'div',
  621. class: 'menu panel-black uimod-mod-settings-window uimod-custom-window js-mod-settings',
  622. content: customSettingsHTML
  623. });
  624. document.body.appendChild($customSettings);
  625. (0, _ui.setWindowOpen)(_ui.WindowNames.modSettings); // And the close button for our custom UI
  626.  
  627. document.querySelector('.js-close-mod-settings').addEventListener('click', removeModSettings);
  628. }
  629.  
  630. function removeModSettings() {
  631. const $customSettingsWindow = document.querySelector('.js-mod-settings');
  632. $customSettingsWindow.parentNode.removeChild($customSettingsWindow);
  633. (0, _ui.setWindowClosed)(_ui.WindowNames.modSettings);
  634. }
  635.  
  636. },{"../../utils/misc":50,"../../utils/ui":53}],4:[function(require,module,exports){
  637. "use strict";
  638.  
  639. Object.defineProperty(exports, "__esModule", {
  640. value: true
  641. });
  642. exports.createModToggler = createModToggler;
  643. exports.removeModToggler = removeModToggler;
  644.  
  645. var _state = require("../../utils/state");
  646.  
  647. var _misc = require("../../utils/misc");
  648.  
  649. var _mods = _interopRequireDefault(require("../../mods"));
  650.  
  651. var _ui = require("../../utils/ui");
  652.  
  653. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  654.  
  655. function createModToggler() {
  656. const state = (0, _state.getState)();
  657. let modTogglerHTML = '';
  658.  
  659. _mods.default.forEach(mod => {
  660. if (mod.required || mod.disabled) return; // Don't allow toggling of required mods
  661.  
  662. const isEnabled = !state.disabledMods.includes(mod.name);
  663. modTogglerHTML += `
  664. <div class="uimod-mod-name">${mod.name}</div>
  665. <div class="uimod-mod-desc">${mod.description}</div>
  666. <div class="uimod-mod-state">${isEnabled ? 'Turned on' : 'Turned off'}</div>
  667. ${isEnabled ? `<div class="btn orange js-disable-mod" data-mod-name="${mod.name}">Turn OFF</div>` : `<div class="btn blue js-enable-mod" data-mod-name="${mod.name}">Turn ON</div>`}
  668. `;
  669. });
  670.  
  671. const customSettingsHTML = `
  672. <h3 class="textprimary">UI Mods</h3>
  673. <div class="uimod-disclaimer">Disclaimer: You MUST refresh the game after you enable/disable a mod for it to take effect.</div>
  674. <div class="settings uimod-mod-toggler js-mod-toggler-list">${modTogglerHTML}</div>
  675. <p></p>
  676. <div class="btn purp js-close-mod-toggler">Close</div>
  677. `;
  678. const $customSettings = (0, _misc.makeElement)({
  679. element: 'div',
  680. class: 'menu panel-black uimod-mod-toggler-window uimod-custom-window js-mod-toggler',
  681. content: customSettingsHTML
  682. });
  683. document.body.appendChild($customSettings);
  684. (0, _ui.setWindowOpen)(_ui.WindowNames.modToggler); // Wire up all the disable/enable mod buttons
  685.  
  686. Array.from(document.querySelectorAll('.js-disable-mod')).forEach($button => {
  687. $button.addEventListener('click', clickEvent => {
  688. const name = clickEvent.target.getAttribute('data-mod-name');
  689.  
  690. if (!state.disabledMods.includes(name)) {
  691. // It should never include the mod already, but juuust in case, we don't want to push it twice
  692. state.disabledMods.push(name);
  693. (0, _state.saveState)();
  694. } // Refresh the window, retaining scroll position
  695.  
  696.  
  697. let $modList = document.querySelector('.js-mod-toggler-list');
  698. const tempScrollPos = $modList.scrollTop;
  699. removeModToggler();
  700. createModToggler();
  701. $modList = document.querySelector('.js-mod-toggler-list');
  702. $modList.scrollTop = tempScrollPos;
  703. });
  704. });
  705. Array.from(document.querySelectorAll('.js-enable-mod')).forEach($button => {
  706. $button.addEventListener('click', clickEvent => {
  707. const name = clickEvent.target.getAttribute('data-mod-name');
  708.  
  709. if (state.disabledMods.includes(name)) {
  710. state.disabledMods.splice(state.disabledMods.indexOf(name), 1);
  711. (0, _state.saveState)();
  712. } // Refresh the window, retaining scroll position
  713.  
  714.  
  715. let $modList = document.querySelector('.js-mod-toggler-list');
  716. const tempScrollPos = $modList.scrollTop;
  717. removeModToggler();
  718. createModToggler();
  719. $modList = document.querySelector('.js-mod-toggler-list');
  720. $modList.scrollTop = tempScrollPos;
  721. });
  722. }); // And the close button for our custom UI
  723.  
  724. document.querySelector('.js-close-mod-toggler').addEventListener('click', removeModToggler);
  725. }
  726.  
  727. function removeModToggler() {
  728. const $customSettingsWindow = document.querySelector('.js-mod-toggler');
  729. $customSettingsWindow.parentNode.removeChild($customSettingsWindow);
  730. (0, _ui.setWindowClosed)(_ui.WindowNames.modToggler);
  731. }
  732.  
  733. },{"../../mods":27,"../../utils/misc":50,"../../utils/state":52,"../../utils/ui":53}],5:[function(require,module,exports){
  734. "use strict";
  735.  
  736. Object.defineProperty(exports, "__esModule", {
  737. value: true
  738. });
  739. exports.default = void 0;
  740.  
  741. var _state = require("../../utils/state");
  742.  
  743. // Note: For a split second after these event handlers are added,
  744. // They may not actually be listening.
  745. // e.g. Refresh page with inventory open, immediately control+right click item
  746. // to copy its stats. It won't work because `keydown` didn't register the keydown event yet
  747. // Doesn't look like there's anything we can do about it, just something to keep in mind.
  748. function keyPressTracker() {
  749. const tempState = (0, _state.getTempState)();
  750. window.addEventListener('keydown', keyEvent => {
  751. if (keyEvent.key === 'Control') {
  752. tempState.keyModifiers.control = true;
  753. } else if (keyEvent.key === 'Alt') {
  754. tempState.keyModifiers.alt = true;
  755. } else if (keyEvent.key === 'Shift') {
  756. // Shouldn't set keyModifiers.shift if we're programatically doing it while getting tooltip content
  757. // tempState.gettingTooltipContentShiftPress should only be `true` if user already isn't pressing shift
  758. // See game.js `getTooltipContent` for more details
  759. if (tempState.gettingTooltipContentShiftPress) {
  760. return;
  761. }
  762.  
  763. tempState.keyModifiers.shift = true;
  764. }
  765. });
  766. window.addEventListener('keyup', keyEvent => {
  767. if (keyEvent.key === 'Control') {
  768. tempState.keyModifiers.control = false;
  769. } else if (keyEvent.key === 'Alt') {
  770. tempState.keyModifiers.alt = false;
  771. } else if (keyEvent.key === 'Shift') {
  772. tempState.keyModifiers.shift = false;
  773. }
  774. }); // If page ever regains focus, e.g. tabbing back in after tabbing out, make sure we reset our modifiers.
  775. // This prevents things like holding control, leaving the tab without releasing it, then coming back in and
  776. // the game will think you are still holding it, even if you're not.
  777.  
  778. window.addEventListener('focus', () => {
  779. tempState.keyModifiers.control = false;
  780. tempState.keyModifiers.alt = false;
  781. tempState.keyModifiers.shift = false;
  782. });
  783. }
  784.  
  785. var _default = {
  786. name: '[REQUIRED] Key press tracker',
  787. description: 'Identifies when you are pressing Ctrl/etc key modifiers, which is used by some other mods',
  788. run: keyPressTracker,
  789. required: true
  790. };
  791. exports.default = _default;
  792.  
  793. },{"../../utils/state":52}],6:[function(require,module,exports){
  794. "use strict";
  795.  
  796. Object.defineProperty(exports, "__esModule", {
  797. value: true
  798. });
  799. exports.default = void 0;
  800.  
  801. var chat = _interopRequireWildcard(require("../../utils/chat"));
  802.  
  803. var _version = require("../../utils/version");
  804.  
  805. var _state = require("../../utils/state");
  806.  
  807. function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
  808.  
  809. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
  810.  
  811. function modStart() {
  812. chat.addChatMessage(`Hordes UI Mod v${_version.VERSION} is now running.`);
  813. setInterval(() => {
  814. (0, _state.testSaveState)();
  815. }, 2000);
  816. }
  817.  
  818. var _default = {
  819. name: '[REQUIRED] UI Mod Startup',
  820. description: 'Do not remove this! This displays a welcome message and includes misc styles.',
  821. run: modStart,
  822. required: true
  823. };
  824. exports.default = _default;
  825.  
  826. },{"../../utils/chat":48,"../../utils/state":52,"../../utils/version":54}],7:[function(require,module,exports){
  827. "use strict";
  828.  
  829. Object.defineProperty(exports, "__esModule", {
  830. value: true
  831. });
  832. exports.createBlockList = createBlockList;
  833. exports.removeBlockList = removeBlockList;
  834.  
  835. var _misc = require("../../utils/misc");
  836.  
  837. var player = _interopRequireWildcard(require("../../utils/player"));
  838.  
  839. var _state = require("../../utils/state");
  840.  
  841. var _ui = require("../../utils/ui");
  842.  
  843. function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
  844.  
  845. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
  846.  
  847. function createBlockList() {
  848. const state = (0, _state.getState)();
  849. let blockedPlayersHTML = '';
  850. Object.keys(state.blockList).sort().forEach(blockedName => {
  851. blockedPlayersHTML += `
  852. <div data-player-name="${blockedName}">${blockedName}</div>
  853. <div class="btn orange js-unblock-player" data-player-name="${blockedName}">Unblock player</div>
  854. `;
  855. });
  856. const customSettingsHTML = `
  857. <h3 class="textprimary">Blocked players</h3>
  858. <div class="settings uimod-settings">${blockedPlayersHTML}</div>
  859. <p></p>
  860. <div class="btn purp js-close-custom-settings">Close</div>
  861. `;
  862. const $customSettings = (0, _misc.makeElement)({
  863. element: 'div',
  864. class: 'menu panel-black uimod-custom-window js-block-list',
  865. content: customSettingsHTML
  866. });
  867. document.body.appendChild($customSettings);
  868. (0, _ui.setWindowOpen)(_ui.WindowNames.blockList); // Wire up all the unblock buttons
  869.  
  870. Array.from(document.querySelectorAll('.js-unblock-player')).forEach($button => {
  871. $button.addEventListener('click', clickEvent => {
  872. const name = clickEvent.target.getAttribute('data-player-name');
  873. player.unblockPlayer(name); // Remove the blocked player from the list
  874.  
  875. Array.from(document.querySelectorAll(`.js-block-list [data-player-name="${name}"]`)).forEach($element => {
  876. $element.parentNode.removeChild($element);
  877. });
  878. });
  879. }); // And the close button for our custom UI
  880.  
  881. document.querySelector('.js-close-custom-settings').addEventListener('click', removeBlockList);
  882. }
  883.  
  884. function removeBlockList() {
  885. const $customSettingsWindow = document.querySelector('.js-block-list');
  886. $customSettingsWindow.parentNode.removeChild($customSettingsWindow);
  887. (0, _ui.setWindowClosed)(_ui.WindowNames.blockList);
  888. }
  889.  
  890. },{"../../utils/misc":50,"../../utils/player":51,"../../utils/state":52,"../../utils/ui":53}],8:[function(require,module,exports){
  891. "use strict";
  892.  
  893. Object.defineProperty(exports, "__esModule", {
  894. value: true
  895. });
  896. Object.defineProperty(exports, "createBlockList", {
  897. enumerable: true,
  898. get: function () {
  899. return _blockListUi.createBlockList;
  900. }
  901. });
  902. Object.defineProperty(exports, "removeBlockList", {
  903. enumerable: true,
  904. get: function () {
  905. return _blockListUi.removeBlockList;
  906. }
  907. });
  908. exports.default = void 0;
  909.  
  910. var _blockListUi = require("./blockListUi");
  911.  
  912. var _customSettings = require("../_customSettings");
  913.  
  914. var _ui = require("../../utils/ui");
  915.  
  916. var _chatContextMenu = require("../chatContextMenu");
  917.  
  918. var _player = require("../../utils/player");
  919.  
  920. var _state = require("../../utils/state");
  921.  
  922. function blockList() {
  923. const tempState = (0, _state.getTempState)();
  924. _ui.WindowNames.blockList = 'block-list';
  925. (0, _customSettings.registerSettingsMenuItem)({
  926. windowName: _ui.WindowNames.blockList,
  927. handleOpenWindow: _blockListUi.createBlockList,
  928. label: 'Blocked players'
  929. });
  930. (0, _chatContextMenu.registerChatMenuItem)({
  931. id: 'block',
  932. label: 'Block',
  933. handleClick: () => {
  934. (0, _player.blockPlayer)(tempState.chatName);
  935. }
  936. });
  937. }
  938.  
  939. var _default = {
  940. name: 'Block list',
  941. description: 'Allows you to block players by clicking their names in chat. View/unblock players in Settings -> Blocked players',
  942. run: blockList
  943. };
  944. exports.default = _default;
  945.  
  946. },{"../../utils/player":51,"../../utils/state":52,"../../utils/ui":53,"../_customSettings":2,"../chatContextMenu":13,"./blockListUi":7}],9:[function(require,module,exports){
  947. "use strict";
  948.  
  949. Object.defineProperty(exports, "__esModule", {
  950. value: true
  951. });
  952. exports.handleBuffArrayChange = handleBuffArrayChange;
  953.  
  954. var _skills = _interopRequireDefault(require("./skills"));
  955.  
  956. var _misc = require("../../utils/misc");
  957.  
  958. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  959.  
  960. function _getSkillId(url) {
  961. const regex = new RegExp('skills/([a-zA-Z0-9]+).');
  962. const matches = url.match(regex);
  963. return Array.isArray(matches) ? matches[1] : null;
  964. }
  965.  
  966. function _getSkillIdFromBuff($buff) {
  967. const $skillImg = $buff.querySelector('img');
  968. if (!$skillImg) return;
  969. return _getSkillId($skillImg.getAttribute('src'));
  970. }
  971.  
  972. function _addBuffTooltip(mouseEvent, $buff) {
  973. const skillId = _getSkillIdFromBuff($buff);
  974.  
  975. if (!skillId) return;
  976. const $buffTooltip = document.querySelector('.js-skill-tooltip');
  977. const skillData = _skills.default[skillId]; // This shouldn't happen, but just in case it does, don't show the buff tooltip
  978.  
  979. if (!skillData) return;
  980. $buffTooltip.querySelector('.js-tooltip-name').textContent = skillData.name;
  981. $buffTooltip.querySelector('.js-tooltip-desc').textContent = skillData.description; // Reset current tooltip stats and add current skill's stats
  982.  
  983. const $tooltipStats = $buffTooltip.querySelector('.js-tooltip-stats');
  984. $tooltipStats.innerHTML = '';
  985.  
  986. if (skillData.stats) {
  987. $buffTooltip.setAttribute('data-skill-id', skillId);
  988. $tooltipStats.style.display = 'block';
  989. $buffTooltip.querySelector('.js-buff-tooltip-effects').style.display = 'block';
  990. skillData.stats.forEach(statText => {
  991. $tooltipStats.appendChild((0, _misc.makeElement)({
  992. element: 'div',
  993. class: 'textgreen',
  994. content: statText
  995. }));
  996. });
  997. } else {
  998. $buffTooltip.setAttribute('data-skill-id', '');
  999. $tooltipStats.style.display = 'none';
  1000. $buffTooltip.querySelector('.js-buff-tooltip-effects').style.display = 'none';
  1001. } // Make tooltip visible near mouse
  1002.  
  1003.  
  1004. $buffTooltip.setAttribute('style', `left: ${mouseEvent.pageX}px; top: ${mouseEvent.pageY - 50}px; display: block;`);
  1005. }
  1006.  
  1007. function _removeBuffTooltip() {
  1008. const $buffTooltip = document.querySelector('.js-skill-tooltip');
  1009.  
  1010. if ($buffTooltip) {
  1011. $buffTooltip.style.display = 'none';
  1012. }
  1013. }
  1014.  
  1015. function _handleBuffTooltipDisplay(mouseEvent, $buff) {
  1016. // TODO: This method should NOT be being called constantly on mouse move of the entire game
  1017. // Maybe a debounced timeout that rebounces on every mousemove of the buffarray, and once it finishes,
  1018. // that means they're no longer hovered over buffarray, so delete the tooltip
  1019. const $elementMouseIsOver = document.elementFromPoint(mouseEvent.clientX, mouseEvent.clientY); // If mouse is over cooldown overlay or icon image of buff icon
  1020.  
  1021. if ($elementMouseIsOver.classList.contains('cd') || $elementMouseIsOver.classList.contains('icon')) {
  1022. // If there is no $buff but we are over the buff icon, then this is the document.body
  1023. // _removeBuffTooltip handler, so we don't want to add the buff tooltip
  1024. // TODO: Consider cleaning up this logic
  1025. if ($buff) _addBuffTooltip(mouseEvent, $buff);
  1026. } else {
  1027. _removeBuffTooltip();
  1028. }
  1029. }
  1030.  
  1031. function handleBuffArrayChange($buffArray) {
  1032. const $buffs = Array.from($buffArray.querySelectorAll('.slot'));
  1033. const visibleSkillIds = [];
  1034. $buffs.forEach($buff => {
  1035. visibleSkillIds.push(_getSkillIdFromBuff($buff));
  1036. if ($buff.classList.contains('js-buff-tooltip-initd')) return;
  1037. $buff.classList.add('js-buff-tooltip-initd'); // Handle deleting tooltip either on mouseleave or on mousemove outside of the .buffarray
  1038. // Being this comprehensive helps ensure the tooltip doesn't accidentally stay visible inappropriately
  1039.  
  1040. if ($buff.parentElement) {
  1041. $buff.parentElement.addEventListener('mousemove', event => _handleBuffTooltipDisplay(event, $buff));
  1042. $buff.addEventListener('mouseleave', _removeBuffTooltip);
  1043. }
  1044. }); // If tooltip is visible, check if the skill it was displaying
  1045. // a tooltip for still exists or not in the buff array
  1046. // If it doesn't exist, remove the tooltip
  1047.  
  1048. const currentDisplayedSkillId = document.querySelector('.js-skill-tooltip').getAttribute('data-skill-id');
  1049.  
  1050. if (currentDisplayedSkillId && !visibleSkillIds.includes(currentDisplayedSkillId)) {
  1051. _removeBuffTooltip();
  1052. }
  1053. }
  1054.  
  1055. },{"../../utils/misc":50,"./skills":11}],10:[function(require,module,exports){
  1056. "use strict";
  1057.  
  1058. Object.defineProperty(exports, "__esModule", {
  1059. value: true
  1060. });
  1061. exports.default = void 0;
  1062.  
  1063. var _helpers = require("./helpers");
  1064.  
  1065. var _misc = require("../../utils/misc");
  1066.  
  1067. function createBuffTooltip() {
  1068. if (document.querySelector('.js-skill-tooltip')) return;
  1069. const buffTooltipHTML = `
  1070. <div class="container js-tooltip-content">
  1071. <div class="slottitle textblue js-tooltip-name"></div>
  1072. <div class="description js-tooltip-desc"></div>
  1073. <div class="uimod-skill-tooltip-text js-buff-tooltip-effects">Effects:</div>
  1074. <div class="js-tooltip-stats"></div>
  1075. </div>
  1076. `;
  1077. const $buffTooltip = (0, _misc.makeElement)({
  1078. element: 'div',
  1079. class: 'border blue slotdescription uimod-skill-tooltip js-skill-tooltip',
  1080. content: buffTooltipHTML
  1081. });
  1082. document.querySelector('.layout').appendChild($buffTooltip);
  1083. } // Add observers to every buff array, so we can track skills and add buff tooltip handlers when they appear
  1084.  
  1085.  
  1086. function buffTooltips() {
  1087. const $buffArrays = Array.from(document.querySelectorAll('.buffarray:not(.js-buffarray-initd)'));
  1088. $buffArrays.forEach($buffArray => {
  1089. $buffArray.classList.add('js-buffarray-initd');
  1090. (0, _helpers.handleBuffArrayChange)($buffArray);
  1091. const buffArrayObserver = new MutationObserver(() => (0, _helpers.handleBuffArrayChange)($buffArray));
  1092. buffArrayObserver.observe($buffArray, {
  1093. childList: true
  1094. });
  1095. });
  1096. } // TODO BUGFIX: After buffing yourself, selecting yourself and hovering the buff tooltip sometimes doesnt show the tooltip
  1097.  
  1098.  
  1099. var _default = {
  1100. name: 'Buff Tooltips',
  1101. description: 'In a tooltip, shows a basic description of the buff that you are hovering over.',
  1102. run: ({
  1103. registerOnDomChange
  1104. }) => {
  1105. createBuffTooltip();
  1106. buffTooltips();
  1107. registerOnDomChange(buffTooltips);
  1108. }
  1109. };
  1110. exports.default = _default;
  1111.  
  1112. },{"../../utils/misc":50,"./helpers":9}],11:[function(require,module,exports){
  1113. "use strict";
  1114.  
  1115. Object.defineProperty(exports, "__esModule", {
  1116. value: true
  1117. });
  1118. exports.default = void 0;
  1119. // Source: https://hordes.io/info/skills
  1120. var _default = {
  1121. // Warrior
  1122. 21: {
  1123. name: 'Armor Reinforcement',
  1124. description: 'Passively increase your Defense.',
  1125. stats: ['+ Defense', '+ Increased Aggro Generation']
  1126. },
  1127. 2: {
  1128. name: 'Bulwark',
  1129. description: 'Increase your block chance, while raising your damage for each successful block.',
  1130. stats: ['+ Block'],
  1131. notes: ['Stackable buff on block']
  1132. },
  1133. 18: {
  1134. name: 'Centrifugal Laceration',
  1135. description: 'Your Crescent Swipe lacerates enemies, causing them to bleed for additional Damage.',
  1136. notes: ['x% as additional damage over 10 seconds']
  1137. },
  1138. 33: {
  1139. name: 'Charge',
  1140. description: 'Charge towards your target while also stunning it. Stun duration increases with charge distance.'
  1141. },
  1142. 20: {
  1143. name: "Crusader's Courage",
  1144. description: 'You and your party members gain additional Defense.',
  1145. stats: ['+ Defense']
  1146. },
  1147. 17: {
  1148. name: 'Colossal Reconstruction',
  1149. description: 'While active you are healed each time you block an attack.'
  1150. },
  1151. 19: {
  1152. name: 'Unholy Warcry',
  1153. description: 'You and your party members deal additional Damage.',
  1154. stats: ['+ Min Dmg', '+ Max Dmg']
  1155. },
  1156. 18: {
  1157. // This is the effect triggered by Centrifugal Laceration
  1158. name: 'Bleed',
  1159. description: 'Crescent Swipe lacerates enemies, causing them to bleed for additional Damage.',
  1160. stats: ['x% as additional damage over 10 seconds']
  1161. },
  1162. buffBlock: {
  1163. name: 'Block',
  1164. description: "Blocks the damage from an enemy's attack."
  1165. },
  1166. // Mage
  1167. 4: {
  1168. name: 'Frost Bolt',
  1169. description: 'Freezes targets for up to 4 stacks, at which they will be stunned and take 50% increased damage.'
  1170. },
  1171. 14: {
  1172. name: 'Chilling Radiance',
  1173. description: 'Emit a chilling shockwave of ice around you, damaging and freezing enemies. Increases the critical hit chance of some of your spells.',
  1174. stats: ['Empower Crit% of Ice bolt', 'Empower Crit% of Icicle Orb', '+100 % Movement Spd. Reduction']
  1175. },
  1176. 23: {
  1177. name: 'Ice Shield',
  1178. description: 'Protects you against the next incoming attacks.',
  1179. stats: ['# attacks blocked']
  1180. },
  1181. 16: {
  1182. name: 'Hypothermic Frenzy',
  1183. description: 'You gain Haste and all your damage output is increased.',
  1184. stats: ['+ Haste', '+ Increased Dmg']
  1185. },
  1186. 24: {
  1187. name: 'Enchantment',
  1188. description: 'Increase your targets Damage.',
  1189. stats: ['+ Min Dmg', '+ Max Dmg']
  1190. },
  1191. 22: {
  1192. name: 'Arctic Aura',
  1193. description: 'You and your party members gain additional Crit%.',
  1194. stats: ['+ Critical']
  1195. },
  1196. frozenBuff: {
  1197. name: 'Frozen',
  1198. description: 'Freezes targets for up to 4 stacks, at which they will be stunned and take 50% increased damage.'
  1199. },
  1200. // Archer
  1201. 10: {
  1202. name: 'Serpent Arrows',
  1203. description: 'Your Precise Shots will jump to additional targets while active.',
  1204. stats: ['# Jumps', '##% damage per Jump']
  1205. },
  1206. 11: {
  1207. name: 'Invigorate',
  1208. description: 'Instantly recovers MP and increases your damage temporarily.',
  1209. stats: ['+ Increased damage']
  1210. },
  1211. 29: {
  1212. name: 'Poison Arrows',
  1213. description: 'Your Precise Shot applies a poisonous Debuff on hit, damaging and slowing your enemies.',
  1214. stats: ['###% per stack as additional damage over 10 seconds']
  1215. },
  1216. 27: {
  1217. name: 'Pathfinding',
  1218. description: 'You and your party members gain additional Movement Speed.',
  1219. stats: ['+ Move Spd']
  1220. },
  1221. 26: {
  1222. name: 'Cranial Punctures',
  1223. description: 'Passively increase your Crit%.',
  1224. stats: ['+ Critical']
  1225. },
  1226. 25: {
  1227. name: 'Temporal Dilation',
  1228. description: 'You and your party members gain additional Haste.',
  1229. stats: ['+ Haste']
  1230. },
  1231. 31: {
  1232. // Technically this is an effect brought on by Precise Shot
  1233. name: 'Swift Shot',
  1234. description: 'Increases the damage of your next Swift Shots and allows them to be cast instantly.'
  1235. },
  1236. 38: {
  1237. name: 'Dash',
  1238. description: 'You dash into your current direction, instantly resetting the cooldown of Precise Shot. Your next Precise Shot is an instant cast.'
  1239. },
  1240. // Shaman
  1241. // TODO: Figure out what the post-summon speed buff icon URL
  1242. 12: {
  1243. name: 'Decay',
  1244. description: 'Curse your enemy with a spell of decay, dealing damage over time.',
  1245. stats: ['DMG', '+ Movement Spd. Reduction']
  1246. },
  1247. 7: {
  1248. name: 'Revitalize',
  1249. description: 'Heal a friendly target over a short duration, stacking up to 3 times while also increasing the power of your Mend.',
  1250. stats: ['Heal']
  1251. },
  1252. 13: {
  1253. name: "Mimir's Well",
  1254. description: 'You and your party members quickly regenerate mana over a short period of time.',
  1255. stats: ['MP recovered']
  1256. },
  1257. 36: {
  1258. name: 'Spirit Animal',
  1259. description: 'Turn into your spirit animal for additional movementspeed.',
  1260. stats: ['+ Move Spd']
  1261. },
  1262. 28: {
  1263. name: 'Canine Howl',
  1264. description: 'You and your entire party enrages with haste, causing you to attack faster.',
  1265. stats: ['+ Haste']
  1266. },
  1267. 37: {
  1268. name: 'Agonize',
  1269. description: 'Turns your target into a zombie, interrupting all actions, slowing it down, and reducing received healing for the duration.',
  1270. stats: ['Movement Spd. Reduction', 'Healing Reduction']
  1271. },
  1272. 30: {
  1273. name: 'Healing Totem',
  1274. description: 'Place a totem on the ground healing your entire party.',
  1275. stats: ['Heal']
  1276. },
  1277. // Other
  1278. 39: {
  1279. name: 'Mount Riding',
  1280. description: 'Allows you to ride ground mounts',
  1281. stats: ['+60 Move Spd']
  1282. },
  1283. potionMp: {
  1284. name: 'MP Potion',
  1285. stats: ['MP Recovered']
  1286. },
  1287. potionhp: {
  1288. name: 'HP Potion',
  1289. stats: ['HP Recovered']
  1290. },
  1291. dazedBuff: {
  1292. name: 'Dazed',
  1293. description: 'When you are hit from behind, you can be dazed. This slows your movement speed and dismounts you.',
  1294. stats: ['Movement Spd. Reduction']
  1295. }
  1296. };
  1297. exports.default = _default;
  1298.  
  1299. },{}],12:[function(require,module,exports){
  1300. "use strict";
  1301.  
  1302. Object.defineProperty(exports, "__esModule", {
  1303. value: true
  1304. });
  1305. exports.showChatContextMenu = showChatContextMenu;
  1306.  
  1307. // Makes chat context menu visible and appear under the mouse
  1308. function showChatContextMenu(name, mousePos, registeredMenuItems) {
  1309. // Right before we show the context menu, we want to check if we should hide/unhide any of the menu items
  1310. const $contextMenu = document.querySelector('.js-chat-context-menu');
  1311. const $menuItems = Array.from($contextMenu.querySelectorAll('[name]'));
  1312. $menuItems.forEach($menuItem => {
  1313. const id = $menuItem.getAttribute('name');
  1314. const handleVisibilityCheck = registeredMenuItems[id] && registeredMenuItems[id].handleVisibilityCheck;
  1315.  
  1316. if (handleVisibilityCheck) {
  1317. const isVisible = handleVisibilityCheck();
  1318. $menuItem.classList.toggle('js-hidden', !isVisible);
  1319. }
  1320. });
  1321. $contextMenu.querySelector('.js-name').textContent = name;
  1322. $contextMenu.setAttribute('style', `display: block; left: ${mousePos.x}px; top: ${mousePos.y}px;`);
  1323. }
  1324.  
  1325. },{}],13:[function(require,module,exports){
  1326. "use strict";
  1327.  
  1328. Object.defineProperty(exports, "__esModule", {
  1329. value: true
  1330. });
  1331. exports.registerChatMenuItem = registerChatMenuItem;
  1332. exports.default = void 0;
  1333.  
  1334. var _state = require("../../utils/state");
  1335.  
  1336. var _misc = require("../../utils/misc");
  1337.  
  1338. var helpers = _interopRequireWildcard(require("./helpers"));
  1339.  
  1340. var chat = _interopRequireWildcard(require("../../utils/chat"));
  1341.  
  1342. function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
  1343.  
  1344. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
  1345.  
  1346. const registeredMenuItems = {}; // This creates the initial chat context menu DOM (which starts as hidden)
  1347.  
  1348. function createChatContextMenu() {
  1349. const tempState = (0, _state.getTempState)();
  1350.  
  1351. if (document.querySelector('.js-chat-context-menu')) {
  1352. return;
  1353. }
  1354.  
  1355. let contextMenuHTML = `
  1356. <div class="js-name">...</div>
  1357. <div class="choice" name="party">Party invite</div>
  1358. <div class="choice" name="whisper">Whisper</div>
  1359. <div class="choice" name="copy">Copy name</div>
  1360. `;
  1361. Object.values(registeredMenuItems).forEach(({
  1362. id,
  1363. label
  1364. }) => {
  1365. contextMenuHTML += `<div class="choice" name="${id}">${label}</div>`;
  1366. });
  1367. document.body.appendChild((0, _misc.makeElement)({
  1368. element: 'div',
  1369. class: 'panel context border grey js-chat-context-menu',
  1370. content: contextMenuHTML
  1371. }));
  1372. const $chatContextMenu = document.querySelector('.js-chat-context-menu');
  1373. $chatContextMenu.querySelector('[name="party"]').addEventListener('click', () => {
  1374. chat.partyPlayer(tempState.chatName);
  1375. });
  1376. $chatContextMenu.querySelector('[name="whisper"]').addEventListener('click', () => {
  1377. chat.whisperPlayer(tempState.chatName);
  1378. });
  1379. $chatContextMenu.querySelector('[name="copy"]').addEventListener('click', () => {
  1380. navigator.clipboard.writeText(tempState.chatName);
  1381. });
  1382. Object.values(registeredMenuItems).forEach(({
  1383. id,
  1384. handleClick
  1385. }) => {
  1386. $chatContextMenu.querySelector(`[name="${id}"]`).addEventListener('click', handleClick);
  1387. });
  1388. } // This opens a context menu when you click a user's name in chat
  1389.  
  1390.  
  1391. function chatContextMenu() {
  1392. const tempState = (0, _state.getTempState)();
  1393.  
  1394. const addContextMenu = ($name, name) => {
  1395. $name.classList.add('js-is-context-menu-initd'); // Add name to element so we can target it in CSS, e.g. when filtering chat for block list
  1396.  
  1397. $name.setAttribute('data-chat-name', name);
  1398.  
  1399. const showContextMenu = clickEvent => {
  1400. // TODO: Is there a way to pass the name to showChatContextMenumethod, instead of storing in tempState?
  1401. tempState.chatName = name;
  1402. helpers.showChatContextMenu(name, {
  1403. x: clickEvent.pageX,
  1404. y: clickEvent.pageY
  1405. }, registeredMenuItems);
  1406. };
  1407.  
  1408. $name.addEventListener('click', showContextMenu); // Left click
  1409.  
  1410. $name.addEventListener('contextmenu', showContextMenu); // Right click works too
  1411. }; // Wire up most chat messages
  1412.  
  1413.  
  1414. Array.from(document.querySelectorAll('#chat .name:not(.js-is-context-menu-initd)')).forEach($name => {
  1415. addContextMenu($name, $name.textContent);
  1416. }); // Wire up messages coming from whispers
  1417. // `textf0` is the VG faction, `textf1` is the BL faction - we want to support both with our whisper context menu
  1418.  
  1419. Array.from(document.querySelectorAll('.textwhisper .textf1:not(.js-is-context-menu-initd), .textwhisper .textf0:not(.js-is-context-menu-initd)')).forEach($whisperName => {
  1420. // $whisperName's textContent is "to [name]" or "from [name]", so we cut off the first word
  1421. let name = $whisperName.textContent.split(' ');
  1422. name.shift(); // Remove the first word
  1423.  
  1424. name = name.join(' ');
  1425. addContextMenu($whisperName, name);
  1426. });
  1427. } // Close chat context menu if clicking outside of it
  1428.  
  1429.  
  1430. function closeChatContextMenu(clickEvent) {
  1431. const $target = clickEvent.target; // If clicking on name or directly on context menu, don't close it
  1432. // Still closes if clicking on context menu item
  1433.  
  1434. if ($target.classList.contains('js-is-context-menu-initd') || $target.classList.contains('js-chat-context-menu')) {
  1435. return;
  1436. }
  1437.  
  1438. const $contextMenu = document.querySelector('.js-chat-context-menu');
  1439. $contextMenu.style.display = 'none';
  1440. } // `id` is unique to this chat context item, e.g. "friend"
  1441. // `label` is the text in the visible context menu
  1442. // `handleClick` is a callback triggered when the user clicks on the menu item
  1443. // `handleVisiblityCheck` is an optional callback triggered when the menu is rendered.
  1444. // Return `true` and the menu item will be visible, return `false` and it will be hidden
  1445. // If this argument is not provided, the menu item will always be visible.
  1446.  
  1447.  
  1448. function registerChatMenuItem({
  1449. id,
  1450. label,
  1451. handleClick,
  1452. handleVisibilityCheck
  1453. }) {
  1454. registeredMenuItems[id] = {
  1455. id,
  1456. label,
  1457. handleClick,
  1458. handleVisibilityCheck
  1459. };
  1460. }
  1461.  
  1462. var _default = {
  1463. name: 'Chat Context Menu',
  1464. description: 'Displays a menu when you click on a player, allowing you to whisper/party them. Also allows chat menu to be used by other mods, e.g. friends list, block list.',
  1465. run: ({
  1466. registerOnLeftClick,
  1467. registerOnChatChange
  1468. }) => {
  1469. createChatContextMenu();
  1470. chatContextMenu(); // When we click anywhere on the page outside of our chat context menu, we want to close the menu
  1471.  
  1472. registerOnLeftClick(closeChatContextMenu); // Register event listeners for each name when a new chat message appears
  1473.  
  1474. registerOnChatChange(chatContextMenu);
  1475. }
  1476. };
  1477. exports.default = _default;
  1478.  
  1479. },{"../../utils/chat":48,"../../utils/misc":50,"../../utils/state":52,"./helpers":12}],14:[function(require,module,exports){
  1480. "use strict";
  1481.  
  1482. Object.defineProperty(exports, "__esModule", {
  1483. value: true
  1484. });
  1485. exports.default = void 0;
  1486.  
  1487. var chat = _interopRequireWildcard(require("../../utils/chat"));
  1488.  
  1489. var _state = require("../../utils/state");
  1490.  
  1491. function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
  1492.  
  1493. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
  1494.  
  1495. // Remove GM chat filter state for users of v1.2.5 and prior
  1496. function removeGmChatFilter() {
  1497. const state = (0, _state.getState)();
  1498. let stateUpdated = false;
  1499. state.chatTabs = state.chatTabs.map(chatTabState => {
  1500. if (!chatTabState) return chatTabState;
  1501.  
  1502. if (chatTabState.filters && chatTabState.filters.hasOwnProperty('GM')) {
  1503. delete chatTabState.filters.GM;
  1504. stateUpdated = true;
  1505. }
  1506.  
  1507. return chatTabState;
  1508. });
  1509.  
  1510. if (state.chat) {
  1511. delete state.chat;
  1512. stateUpdated = true;
  1513. }
  1514.  
  1515. if (stateUpdated) (0, _state.saveState)();
  1516. }
  1517.  
  1518. var _default = {
  1519. name: 'Chat filters',
  1520. description: "Filters all chat, e.g. ensuring blocked users' messages are not visible in chat.",
  1521. run: ({
  1522. registerOnChatChange
  1523. }) => {
  1524. removeGmChatFilter(); // Whenever chat changes, we want to filter it
  1525.  
  1526. registerOnChatChange(chat.filterAllChat);
  1527. }
  1528. };
  1529. exports.default = _default;
  1530.  
  1531. },{"../../utils/chat":48,"../../utils/state":52}],15:[function(require,module,exports){
  1532. "use strict";
  1533.  
  1534. Object.defineProperty(exports, "__esModule", {
  1535. value: true
  1536. });
  1537. exports.showChatTabConfigWindow = showChatTabConfigWindow;
  1538. exports.addChatTab = addChatTab;
  1539. exports.selectChatTab = selectChatTab;
  1540. exports.getCurrentChatFilters = getCurrentChatFilters;
  1541.  
  1542. var _state = require("../../utils/state");
  1543.  
  1544. var _misc = require("../../utils/misc");
  1545.  
  1546. const DEFAULT_CHAT_TAB_NAME = 'Untitled'; // Gets current chat filters as represented in the UI
  1547. // filter being true means it's invisible(filtered) in chat
  1548. // filter being false means it's visible(unfiltered) in chat
  1549.  
  1550. function getCurrentChatFilters() {
  1551. // Saved by the official game client
  1552. const gameFilters = JSON.parse(localStorage.getItem('filteredChannels'));
  1553. return {
  1554. global: gameFilters.includes('global'),
  1555. faction: gameFilters.includes('faction'),
  1556. party: gameFilters.includes('party'),
  1557. clan: gameFilters.includes('clan'),
  1558. pvp: gameFilters.includes('pvp'),
  1559. inv: gameFilters.includes('inv')
  1560. };
  1561. } // Shows the chat tab config window for a specific tab, displayed in a specific position
  1562.  
  1563.  
  1564. function showChatTabConfigWindow(tabId, pos) {
  1565. const state = (0, _state.getState)();
  1566. const tempState = (0, _state.getTempState)();
  1567. const $chatTabConfig = document.querySelector('.js-chat-tab-config');
  1568. const chatTab = state.chatTabs.find(tab => tab.id === tabId); // Update position and name in chat tab config
  1569.  
  1570. $chatTabConfig.style.left = `${pos.x}px`;
  1571. $chatTabConfig.style.top = `${pos.y}px`;
  1572. $chatTabConfig.querySelector('.js-chat-tab-name').value = chatTab.name; // Store tabId in state, to be used by the Remove/Add buttons in config window
  1573.  
  1574. tempState.editedChatTabId = tabId; // Hide remove button if only one chat tab left - can't remove last one
  1575. // Show it if more than one chat tab left
  1576.  
  1577. const chatTabCount = Object.keys(state.chatTabs).length;
  1578. const $removeChatTabBtn = $chatTabConfig.querySelector('.js-remove-chat-tab');
  1579. $removeChatTabBtn.style.display = chatTabCount < 2 ? 'none' : 'block'; // Show chat tab config
  1580.  
  1581. $chatTabConfig.style.display = 'block';
  1582. } // Adds chat tab to DOM, sets it as selected
  1583. // If argument chatTab is provided, will use that name+id
  1584. // If no argument is provided, will create new tab name/id and add it to state
  1585. // isInittingTab is optional boolean, if `true`, will _not_ set added tab as selected. Used when initializing all chat tabs on load
  1586. // Returns newly added tabId
  1587.  
  1588.  
  1589. function addChatTab(chatTab, isInittingTab) {
  1590. const state = (0, _state.getState)();
  1591. let tabName = DEFAULT_CHAT_TAB_NAME;
  1592. let tabId = (0, _misc.uuid)();
  1593.  
  1594. if (chatTab) {
  1595. tabName = chatTab.name;
  1596. tabId = chatTab.id;
  1597. } else {
  1598. // If no chat tab was provided, create it in state
  1599. state.chatTabs.push({
  1600. name: tabName,
  1601. id: tabId,
  1602. filters: getCurrentChatFilters()
  1603. });
  1604. (0, _state.saveState)();
  1605. }
  1606.  
  1607. const $tabs = document.querySelector('.js-chat-tabs');
  1608. const $tab = (0, _misc.makeElement)({
  1609. element: 'div',
  1610. content: tabName
  1611. });
  1612. $tab.setAttribute('data-tab-id', tabId); // Add chat tab to DOM
  1613.  
  1614. $tabs.appendChild($tab); // Wire chat tab up to open config on right click
  1615.  
  1616. $tab.addEventListener('contextmenu', clickEvent => {
  1617. const mousePos = {
  1618. x: clickEvent.pageX,
  1619. y: clickEvent.pageY
  1620. };
  1621. showChatTabConfigWindow(tabId, mousePos);
  1622. }); // And select chat tab on left click
  1623.  
  1624. $tab.addEventListener('click', () => {
  1625. selectChatTab(tabId);
  1626. });
  1627.  
  1628. if (!isInittingTab) {
  1629. // Select the newly added chat tab
  1630. selectChatTab(tabId);
  1631. } // Returning tabId to all adding new tab to pass tab ID to `showChatTabConfigWindow`
  1632.  
  1633.  
  1634. return tabId;
  1635. } // Selects chat tab [on click], updating client chat filters and custom chat filters
  1636.  
  1637.  
  1638. function selectChatTab(tabId) {
  1639. const state = (0, _state.getState)(); // Remove selected class from everything, then add selected class to clicked tab
  1640.  
  1641. Array.from(document.querySelectorAll('[data-tab-id]')).forEach($tab => {
  1642. $tab.classList.remove('js-selected-tab');
  1643. });
  1644. const $tab = document.querySelector(`[data-tab-id="${tabId}"]`);
  1645. $tab.classList.add('js-selected-tab');
  1646. const tabFilters = state.chatTabs.find(tab => tab.id === tabId).filters; // Simulating clicks on the filters to turn them on/off
  1647.  
  1648. const $filterButtons = Array.from(document.querySelectorAll('.channelselect small'));
  1649. Object.keys(tabFilters).forEach(filter => {
  1650. const $filterButton = $filterButtons.find($btn => $btn.textContent === filter);
  1651. if (!$filterButton) return;
  1652. const isCurrentlyFiltered = $filterButton.classList.contains('textgrey'); // If is currently filtered but filter for this tab is turned off, click it to turn filter off
  1653.  
  1654. if (isCurrentlyFiltered && !tabFilters[filter]) {
  1655. $filterButton.click();
  1656. } // If it is not currently filtered but filter for this tab is turned on, click it to turn filter on
  1657.  
  1658.  
  1659. if (!isCurrentlyFiltered && tabFilters[filter]) {
  1660. $filterButton.click();
  1661. }
  1662. }); // Update the selected tab in state
  1663.  
  1664. state.selectedChatTabId = tabId;
  1665. (0, _state.saveState)();
  1666. }
  1667.  
  1668. },{"../../utils/misc":50,"../../utils/state":52}],16:[function(require,module,exports){
  1669. "use strict";
  1670.  
  1671. Object.defineProperty(exports, "__esModule", {
  1672. value: true
  1673. });
  1674. exports.default = void 0;
  1675.  
  1676. var helpers = _interopRequireWildcard(require("./helpers"));
  1677.  
  1678. var _state = require("../../utils/state");
  1679.  
  1680. var _misc = require("../../utils/misc");
  1681.  
  1682. function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
  1683.  
  1684. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
  1685.  
  1686. // Creates DOM elements and wires them up for custom chat tabs and chat tab config
  1687. // Note: Should be done after creating new custom chat filters
  1688. function customChatTabs() {
  1689. const state = (0, _state.getState)();
  1690. const tempState = (0, _state.getTempState)(); // Create the chat tab configuration DOM
  1691.  
  1692. const $chatTabConfigurator = (0, _misc.makeElement)({
  1693. element: 'div',
  1694. class: 'uimod-chat-tab-config js-chat-tab-config',
  1695. content: `
  1696. <h1>Chat Tab Config</h1>
  1697. <div class="uimod-chat-tab-config-grid">
  1698. <div>Name</div><input type="text" class="js-chat-tab-name" value="untitled"></input>
  1699. <div class="btn orange js-remove-chat-tab">Remove</div><div class="btn blue js-save-chat-tab">Ok</div>
  1700. </div>
  1701. `
  1702. });
  1703. document.body.append($chatTabConfigurator); // Wire it up
  1704.  
  1705. document.querySelector('.js-remove-chat-tab').addEventListener('click', () => {
  1706. // Remove the chat tab from state
  1707. const editedChatTab = state.chatTabs.find(tab => tab.id === tempState.editedChatTabId);
  1708. const editedChatTabIndex = state.chatTabs.indexOf(editedChatTab);
  1709. state.chatTabs.splice(editedChatTabIndex, 1); // Remove the chat tab from DOM
  1710.  
  1711. const $chatTab = document.querySelector(`[data-tab-id="${tempState.editedChatTabId}"]`);
  1712. $chatTab.parentNode.removeChild($chatTab); // If we just removed the currently selected chat tab
  1713.  
  1714. if (tempState.editedChatTabId === state.selectedChatTabId) {
  1715. // Select the chat tab to the left of the removed one
  1716. const nextChatTabIndex = editedChatTabIndex === 0 ? 0 : editedChatTabIndex - 1;
  1717. helpers.selectChatTab(state.chatTabs[nextChatTabIndex].id);
  1718. } // Close chat tab config
  1719.  
  1720.  
  1721. document.querySelector('.js-chat-tab-config').style.display = 'none';
  1722. });
  1723. document.querySelector('.js-save-chat-tab').addEventListener('click', () => {
  1724. // Set new chat tab name in DOM
  1725. const $chatTab = document.querySelector(`[data-tab-id="${state.selectedChatTabId}"]`);
  1726. const newName = document.querySelector('.js-chat-tab-name').value;
  1727. $chatTab.textContent = newName; // Set new chat tab name in state
  1728. // `selectedChatTab` is a reference on `state.chatTabs`, so updating it above still updates it in the state - we want to save that
  1729.  
  1730. const selectedChatTab = state.chatTabs.find(tab => tab.id === state.selectedChatTabId);
  1731. selectedChatTab.name = newName;
  1732. (0, _state.saveState)(); // Close chat tab config
  1733.  
  1734. document.querySelector('.js-chat-tab-config').style.display = 'none';
  1735. }); // Create the initial chat tabs HTML
  1736.  
  1737. const $chat = document.querySelector('#chat');
  1738. const $chatTabs = (0, _misc.makeElement)({
  1739. element: 'div',
  1740. class: 'uimod-chat-tabs js-chat-tabs',
  1741. content: '<div class="js-chat-tab-add">+</div>'
  1742. }); // Add them to the DOM
  1743.  
  1744. $chat.parentNode.insertBefore($chatTabs, $chat); // Add all our chat tabs from state
  1745.  
  1746. state.chatTabs.forEach(chatTab => {
  1747. const isInittingTab = true;
  1748. helpers.addChatTab(chatTab, isInittingTab);
  1749. }); // Wire up the add chat tab button
  1750.  
  1751. document.querySelector('.js-chat-tab-add').addEventListener('click', clickEvent => {
  1752. const chatTabId = helpers.addChatTab();
  1753. const mousePos = {
  1754. x: clickEvent.pageX,
  1755. y: clickEvent.pageY
  1756. };
  1757. helpers.showChatTabConfigWindow(chatTabId, mousePos);
  1758. }); // If initial chat tab doesn't exist, create it based off current filter settings
  1759.  
  1760. if (!Object.keys(state.chatTabs).length) {
  1761. const tabId = (0, _misc.uuid)();
  1762. const chatTab = {
  1763. name: 'Main',
  1764. id: tabId,
  1765. filters: helpers.getCurrentChatFilters()
  1766. };
  1767. state.chatTabs.push(chatTab);
  1768. (0, _state.saveState)();
  1769. helpers.addChatTab(chatTab);
  1770. } // Wire up click event handlers onto the filters to update the selected chat tab's filters in state
  1771.  
  1772.  
  1773. document.querySelector('.channelselect').addEventListener('click', clickEvent => {
  1774. const $elementMouseIsOver = document.elementFromPoint(clickEvent.clientX, clickEvent.clientY); // We only want to change the filters if the user manually clicks the filter button
  1775. // If they clicked a chat tab and we programatically set filters, we don't want to update
  1776. // the current tab's filter state
  1777.  
  1778. if (!$elementMouseIsOver.classList.contains('btn')) {
  1779. return;
  1780. }
  1781.  
  1782. const selectedChatTab = state.chatTabs.find(tab => tab.id === state.selectedChatTabId);
  1783. selectedChatTab.filters = helpers.getCurrentChatFilters();
  1784. (0, _state.saveState)();
  1785. }); // Select the currently selected tab in state on mod initialization
  1786.  
  1787. if (state.selectedChatTabId) {
  1788. helpers.selectChatTab(state.selectedChatTabId);
  1789. }
  1790. }
  1791.  
  1792. function cleanCustomChatTabState() {
  1793. const state = (0, _state.getState)();
  1794. let stateUpdated = true;
  1795. state.chatTabs = state.chatTabs.filter(chatTab => {
  1796. if (!chatTab) {
  1797. stateUpdated = true;
  1798. return false;
  1799. }
  1800.  
  1801. return true;
  1802. });
  1803. if (stateUpdated) (0, _state.saveState)();
  1804. }
  1805.  
  1806. var _default = {
  1807. name: 'Chat tabs',
  1808. description: 'Enables support for multiple chat tabs',
  1809. run: () => {
  1810. cleanCustomChatTabState();
  1811. customChatTabs();
  1812. }
  1813. };
  1814. exports.default = _default;
  1815.  
  1816. },{"../../utils/misc":50,"../../utils/state":52,"./helpers":15}],17:[function(require,module,exports){
  1817. "use strict";
  1818.  
  1819. Object.defineProperty(exports, "__esModule", {
  1820. value: true
  1821. });
  1822. exports.handleClanWindowChange = handleClanWindowChange;
  1823.  
  1824. var _misc = require("../../utils/misc");
  1825.  
  1826. var _state = require("../../utils/state");
  1827.  
  1828. function _lastSeenFromTimestamp(ts) {
  1829. if (!ts) return 'Never';
  1830. const nowTs = Date.now();
  1831. const seconds = (nowTs - ts) / 1000; // Divide by 1000 because Date.now returns milliseconds
  1832.  
  1833. const minutes = seconds / 60;
  1834. const hours = minutes / 60;
  1835. const days = hours / 24;
  1836. const weeks = days / 7;
  1837. const months = weeks / 30;
  1838. const years = months / 12;
  1839.  
  1840. const getPluralizedText = (num, word) => {
  1841. num = Math.round(num);
  1842. return num === 1 ? `${num} ${word}` : `${num} ${word}s`;
  1843. };
  1844.  
  1845. if (seconds < 60) return `${getPluralizedText(seconds, 'second')} ago`;
  1846. if (minutes < 60) return `${getPluralizedText(minutes, 'minute')} ago`;
  1847. if (hours < 24) return `${getPluralizedText(hours, 'hour')} ago`;
  1848. if (days < 7) return `${getPluralizedText(days, 'day')} ago`;
  1849. if (days < 30) return `${getPluralizedText(weeks, 'week')} ago`;
  1850. if (months < 12) return `${getPluralizedText(months, 'month')} ago`;
  1851. return `${getPluralizedText(years, 'year')} ago`;
  1852. }
  1853.  
  1854. function _handleClanMemberTableChange() {
  1855. const state = (0, _state.getState)();
  1856. const $clanLastSeenTable = document.querySelector('.js-clan-lastseen-table');
  1857. const $clanMemberTable = document.querySelector('.js-clan-members-table-initd'); // Update+Save current online users last seen time
  1858.  
  1859. const currentTimestamp = Date.now();
  1860. const $memberNames = Array.from($clanMemberTable.querySelectorAll('tr .name'));
  1861. const latestMemberNames = [];
  1862. $memberNames.map($name => {
  1863. const isOnline = !$name.parentNode.parentNode.classList.contains('offline');
  1864. const name = $name.textContent.trim();
  1865.  
  1866. if (isOnline) {
  1867. // Update current timestamp of online members
  1868. state.clanLastActiveMembers[name] = currentTimestamp;
  1869. } else if (!state.clanLastActiveMembers.hasOwnProperty(name)) {
  1870. // If not existing in state, add them so that we can check update their last seen time when they type in chat (See `refreshLastSeenClanMember`)
  1871. state.clanLastActiveMembers[name] = null;
  1872. }
  1873.  
  1874. latestMemberNames.push(name);
  1875. }); // Remove clan members that've left the clan from state, so their last seen time is no longer tracked when they type in chat
  1876.  
  1877. const removedMembers = Object.keys(state.clanLastActiveMembers).filter(nameInState => !latestMemberNames.includes(nameInState));
  1878. removedMembers.forEach(removedName => delete state.clanLastActiveMembers[removedName]);
  1879. (0, _state.saveState)(); // Update changed last seen times in DOM
  1880.  
  1881. const $names = Array.from($clanMemberTable.querySelectorAll('tr .name'));
  1882. const $lastSeenRows = Array.from($clanLastSeenTable.querySelectorAll('.js-clan-lastseen-row')); // If necessary, update the quantity of rows in our custom table
  1883.  
  1884. const $tableBody = $clanLastSeenTable.querySelector('tbody');
  1885.  
  1886. if ($names.length !== $lastSeenRows.length) {
  1887. const $newRow = (0, _misc.makeElement)({
  1888. element: 'tr',
  1889. class: 'striped js-clan-lastseen-row',
  1890. content: '<td></td>'
  1891. });
  1892.  
  1893. if ($names.length > $lastSeenRows.length) {
  1894. // Add last seen rows to match names length
  1895. const rowsToAddCount = $names.length - $lastSeenRows.length;
  1896.  
  1897. for (var i = 0; i < rowsToAddCount; i++) {
  1898. $tableBody.appendChild($newRow.cloneNode(true));
  1899. }
  1900. } else {
  1901. // Remove last seen rows to match names length
  1902. const rowsToRemoveCount = $lastSeenRows.length - $names.length;
  1903.  
  1904. for (var i = 0; i < rowsToRemoveCount; i++) {
  1905. $tableBody.querySelector('tr').remove();
  1906. }
  1907. }
  1908. } // Update last seen rows with appropriate last seen time
  1909.  
  1910.  
  1911. const $tableRows = Array.from($tableBody.querySelectorAll('td'));
  1912. $names.forEach(($name, index) => {
  1913. const name = $name.textContent.trim();
  1914. const isOnline = state.clanLastActiveMembers[name] === currentTimestamp;
  1915. const lastSeenStr = isOnline ? 'Now' : _lastSeenFromTimestamp(state.clanLastActiveMembers[name]);
  1916. const $tableRow = $tableRows[index];
  1917. const rowLastSeenStr = $tableRow.textContent;
  1918. const isLastSeenChanged = rowLastSeenStr !== lastSeenStr;
  1919. if (isLastSeenChanged) $tableRow.textContent = lastSeenStr; // Mirroring the 50% opacity that the normal clan member table has on offline members
  1920.  
  1921. const lineClassList = $tableRow.parentNode.classList;
  1922. const displayingRowAsOffline = lineClassList.contains('js-offline-member');
  1923.  
  1924. if (!isOnline && !displayingRowAsOffline) {
  1925. lineClassList.add('js-offline-member');
  1926. } else if (isOnline && displayingRowAsOffline) {
  1927. lineClassList.remove('js-offline-member');
  1928. }
  1929. });
  1930. }
  1931.  
  1932. function handleClanWindowChange() {
  1933. const state = (0, _state.getState)();
  1934. const tempState = (0, _state.getTempState)();
  1935. const $clanWindow = document.querySelector('.window .clanView'); // Table takes a moment to be created after clanView window is opened
  1936.  
  1937. const $clanMemberTable = $clanWindow.querySelector('table:not(.js-clan-lastseen-initd)');
  1938. if (!$clanMemberTable) return; // If not in Members tab (e.g. Applications tab), don't initialize Last seen
  1939. // Check if we're in Members tab by seeing if there are 2 columns or not
  1940. // (This allows us to support multiple languages, as opposed to checking for "Applications")
  1941.  
  1942. const isMembersTab = Array.from($clanMemberTable.querySelectorAll('thead th')).length === 2;
  1943. const $lastSeenTable = $clanWindow.querySelector('.js-clan-lastseen-table');
  1944.  
  1945. if (!isMembersTab) {
  1946. // Hide last seen table if it's visible
  1947. if ($lastSeenTable) $lastSeenTable.style.display = 'none';
  1948. return;
  1949. } else if ($lastSeenTable) {
  1950. // Unhide it when we are on Members table
  1951. $lastSeenTable.setAttribute('style', '');
  1952. } // Initialize the table column if we haven't already
  1953. // The clan member table loses its class when the tab is changed, so we check
  1954.  
  1955.  
  1956. if (!$clanMemberTable.classList.contains('js-clan-members-table-initd')) {
  1957. $clanMemberTable.classList.add('js-clan-members-table-initd', 'uimod-clan-members-table'); // Last seen table may already exist if we're switching from Applications tab back to Members tab
  1958.  
  1959. if ($lastSeenTable) return; // If last seen table hasn't been created, create it.
  1960. // We add a new table next to the preexisting table.
  1961. // We don't just add a new column because Svelte changes the columns and rows around
  1962. // a lot, pretty randomly. This leads to our right-most column occasionally bugging out
  1963. // and ending up as the left-most column.
  1964. // Using our own table lets us control everything about it without Svelte interfering.
  1965.  
  1966. $clanMemberTable.parentNode.appendChild((0, _misc.makeElement)({
  1967. element: 'table',
  1968. class: 'marg-top panel-black js-clan-lastseen-table uimod-clan-lastseen-table',
  1969. content: `
  1970. <thead>
  1971. <tr class="textprimary">
  1972. <th>Last seen</th>
  1973. </tr>
  1974. </thead>
  1975. <tbody>
  1976. <tr class="striped js-clan-lastseen-row">
  1977. <td></td>
  1978. </tr>
  1979. </tbody>
  1980. `
  1981. })); // Reset last active members state if clan has changed
  1982.  
  1983. const clanName = $clanWindow.querySelector('.textcenter h1').textContent;
  1984.  
  1985. if (clanName !== state.currentClanName) {
  1986. state.currentClanName = clanName.trim();
  1987. state.clanLastActiveMembers = {};
  1988. (0, _state.saveState)();
  1989. }
  1990. }
  1991.  
  1992. if (!tempState.clanTableObserver) {
  1993. _handleClanMemberTableChange();
  1994.  
  1995. tempState.clanTableObserver = new MutationObserver(_handleClanMemberTableChange);
  1996. tempState.clanTableObserver.observe($clanMemberTable, {
  1997. attributes: true,
  1998. childList: true,
  1999. subtree: true
  2000. });
  2001. }
  2002. }
  2003.  
  2004. },{"../../utils/misc":50,"../../utils/state":52}],18:[function(require,module,exports){
  2005. "use strict";
  2006.  
  2007. Object.defineProperty(exports, "__esModule", {
  2008. value: true
  2009. });
  2010. exports.default = void 0;
  2011.  
  2012. var _ui = require("../../utils/ui");
  2013.  
  2014. var _state = require("../../utils/state");
  2015.  
  2016. var _helpers = require("./helpers");
  2017.  
  2018. // When clan window is open, initialize the mutation observer to add Last seen and track last seen in state
  2019. function clanActivityTracker() {
  2020. const tempState = (0, _state.getTempState)();
  2021. const $clanWindow = document.querySelector('.window .clanView'); // If the window is no longer visible, update the state to denote the window has closed and kill the observer
  2022.  
  2023. if (!$clanWindow) {
  2024. if ((0, _ui.isWindowOpen)(_ui.WindowNames.clan)) {
  2025. if (tempState.clanWindowObserver) {
  2026. tempState.clanWindowObserver.disconnect();
  2027. delete tempState.clanWindowObserver;
  2028. }
  2029.  
  2030. if (tempState.clanTableObserver) {
  2031. tempState.clanTableObserver.disconnect();
  2032. delete tempState.clanTableObserver;
  2033. }
  2034.  
  2035. (0, _ui.setWindowClosed)(_ui.WindowNames.clan);
  2036. }
  2037. } else if (!tempState.clanWindowObserver) {
  2038. (0, _ui.setWindowOpen)(_ui.WindowNames.clan);
  2039. (0, _helpers.handleClanWindowChange)();
  2040. tempState.clanWindowObserver = new MutationObserver(_helpers.handleClanWindowChange);
  2041. tempState.clanWindowObserver.observe($clanWindow, {
  2042. attributes: true,
  2043. childList: true
  2044. });
  2045. }
  2046. } // Update last seen for clan members when they type in chat
  2047.  
  2048.  
  2049. function refreshLastSeenClanMember(mutations) {
  2050. const state = (0, _state.getState)();
  2051. let updatedState = false;
  2052. const $newChatLines = mutations.map(mutation => Array.from(mutation.addedNodes)).flat();
  2053. $newChatLines.forEach($chatLine => {
  2054. const $name = $chatLine.querySelector('.name');
  2055. if (!$name) return;
  2056. const name = $name.textContent.trim(); // If not clan member, don't update state
  2057.  
  2058. if (!state.clanLastActiveMembers.hasOwnProperty(name)) return;
  2059. updatedState = true;
  2060. state.clanLastActiveMembers[name] = Date.now();
  2061. });
  2062. if (updatedState) (0, _state.saveState)();
  2063. }
  2064.  
  2065. var _default = {
  2066. name: 'Clan activity tracker',
  2067. description: 'Updates clan member table with a Last seen column',
  2068. run: ({
  2069. registerOnDomChange,
  2070. registerOnChatChange
  2071. }) => {
  2072. clanActivityTracker(); // Run it initially once in case clan is already open on mod load
  2073.  
  2074. registerOnDomChange(clanActivityTracker); // Run it on dom change for whenever the clan window is opened/closed
  2075.  
  2076. registerOnChatChange(refreshLastSeenClanMember); // Run it on chat change so whenever a clan member chats, their last seen is updated
  2077. }
  2078. };
  2079. exports.default = _default;
  2080.  
  2081. },{"../../utils/state":52,"../../utils/ui":53,"./helpers":17}],19:[function(require,module,exports){
  2082. "use strict";
  2083.  
  2084. Object.defineProperty(exports, "__esModule", {
  2085. value: true
  2086. });
  2087. exports.deposit = deposit;
  2088. exports.withdraw = withdraw;
  2089.  
  2090. var _game = require("../../utils/game");
  2091.  
  2092. var _ui = require("../../utils/ui");
  2093.  
  2094. function _executeStashAction($stash) {
  2095. const $currencyInput = $stash.querySelector('input.formatted'); // Input some huge value they'll have less than
  2096.  
  2097. $currencyInput.value = 999999999999999;
  2098. $currencyInput.dispatchEvent(new Event('input'));
  2099. setTimeout(function () {
  2100. const $actionButton = $stash.querySelector('.marg-top .btn');
  2101.  
  2102. if (!$actionButton.classList.contains('disabled')) {
  2103. $actionButton.dispatchEvent(new Event('click'));
  2104. } // Clear input
  2105.  
  2106.  
  2107. $currencyInput.value = '';
  2108. $currencyInput.dispatchEvent(new Event('input'));
  2109. }, 0);
  2110. }
  2111.  
  2112. function deposit() {
  2113. const $stash = (0, _game.getWindow)(_ui.WindowNames.stash); // Select normal deposit button
  2114.  
  2115. $stash.querySelector('.slot .grey.gold:not(.js-deposit-all)').dispatchEvent(new Event('click'));
  2116.  
  2117. _executeStashAction($stash);
  2118. }
  2119.  
  2120. function withdraw() {
  2121. const $stash = (0, _game.getWindow)(_ui.WindowNames.stash); // Select normal deposit button
  2122.  
  2123. const $stashBtns = $stash.querySelectorAll('.slot .grey.gold:not(.js-withdraw-all');
  2124. const $withdrawBtn = $stashBtns[$stashBtns.length - 1]; // Right most button
  2125.  
  2126. $withdrawBtn.dispatchEvent(new Event('click'));
  2127.  
  2128. _executeStashAction($stash);
  2129. }
  2130.  
  2131. },{"../../utils/game":49,"../../utils/ui":53}],20:[function(require,module,exports){
  2132. "use strict";
  2133.  
  2134. Object.defineProperty(exports, "__esModule", {
  2135. value: true
  2136. });
  2137. exports.default = void 0;
  2138.  
  2139. var _misc = require("../../utils/misc");
  2140.  
  2141. var _ui = require("../../utils/ui");
  2142.  
  2143. var _game = require("../../utils/game");
  2144.  
  2145. var _helper = require("./helper");
  2146.  
  2147. function addDepositAllButton() {
  2148. const $stash = (0, _game.getWindow)(_ui.WindowNames.stash); // If stash is closed or deposit all button is already added, we dont need to do anything
  2149.  
  2150. if (!$stash || $stash.querySelector('.js-deposit-all')) {
  2151. return;
  2152. } // Create deposit all button and add it to stash
  2153.  
  2154.  
  2155. const $depositTargetBtn = $stash.querySelector('.slot .grey.gold');
  2156. const $depositAllBtn = $depositTargetBtn.cloneNode(true);
  2157. const $depositAllText = (0, _misc.makeElement)({
  2158. element: 'span',
  2159. content: ' ALL'
  2160. });
  2161. $depositAllBtn.append($depositAllText);
  2162. $depositAllBtn.classList.add('js-deposit-all');
  2163. $depositAllBtn.classList.remove('active');
  2164. $depositTargetBtn.parentElement.insertBefore($depositAllBtn, $depositTargetBtn);
  2165. $stash.querySelector('.js-deposit-all').addEventListener('click', _helper.deposit);
  2166. }
  2167.  
  2168. function addWithdrawAllButton() {
  2169. const $stash = (0, _game.getWindow)(_ui.WindowNames.stash); // If stash is closed or withdraw all button is already added, we dont need to do anything
  2170.  
  2171. if (!$stash || $stash.querySelector('.js-withdraw-all')) {
  2172. return;
  2173. } // Create withdraw all button and add it to stash
  2174.  
  2175.  
  2176. const $stashBtns = $stash.querySelectorAll('.slot .grey.gold');
  2177. const $withdrawTargetBtn = $stashBtns[$stashBtns.length - 1]; // Right most button
  2178.  
  2179. const $withdrawAllBtn = $withdrawTargetBtn.cloneNode(true);
  2180. const $withdrawAllText = (0, _misc.makeElement)({
  2181. element: 'span',
  2182. content: ' ALL'
  2183. });
  2184. $withdrawAllBtn.append($withdrawAllText);
  2185. $withdrawAllBtn.classList.add('js-withdraw-all');
  2186. $withdrawAllBtn.classList.remove('active');
  2187. $withdrawTargetBtn.parentElement.insertBefore($withdrawAllBtn, $withdrawTargetBtn);
  2188. $stash.querySelector('.js-withdraw-all').addEventListener('click', _helper.withdraw);
  2189. }
  2190.  
  2191. var _default = {
  2192. name: 'Desposit/Withdraw All Button',
  2193. description: 'Adds two buttons to your stash to quickly deposit/withdraw all of your money',
  2194. run: ({
  2195. registerOnDomChange
  2196. }) => {
  2197. addDepositAllButton();
  2198. registerOnDomChange(addDepositAllButton);
  2199. addWithdrawAllButton();
  2200. registerOnDomChange(addWithdrawAllButton);
  2201. }
  2202. };
  2203. exports.default = _default;
  2204.  
  2205. },{"../../utils/game":49,"../../utils/misc":50,"../../utils/ui":53,"./helper":19}],21:[function(require,module,exports){
  2206. "use strict";
  2207.  
  2208. Object.defineProperty(exports, "__esModule", {
  2209. value: true
  2210. });
  2211. exports.dragElement = dragElement;
  2212.  
  2213. // Influenced by: https://gist.github.com/remarkablemark/5002d27442600510d454a5aeba370579 & https://stackoverflow.com/a/45831670
  2214. // $draggedElement is the item that will be dragged.
  2215. // $dragTrigger is optional, if passed, this element that must be held down to drag $draggedElement
  2216. // If $dragTrigger is not passed, clicking anywhere on $draggedElement will drag it
  2217. // dragAfterTimeMs is an optional argument. If passed, user has to hold mouse down for that long before being able to drag
  2218. function dragElement($draggedElement, $dragTrigger, dragAfterTimeMs) {
  2219. let offset = [0, 0];
  2220. let mouseDownPos = [0, 0];
  2221. let elementPos = [0, 0];
  2222. let isDown = false;
  2223. let downTimeMs = 0; // Time when user last started holding mouse left click
  2224.  
  2225. const $trigger = $dragTrigger || $draggedElement;
  2226. $trigger.addEventListener('mousedown', e => {
  2227. isDown = true;
  2228. downTimeMs = Date.now(); // Offset is used when there is a separate $dragTrigger
  2229.  
  2230. offset = [$draggedElement.offsetLeft - e.clientX, $draggedElement.offsetTop - e.clientY]; // mouseDownPos and elementPos are used when $draggedElement is also the trigger
  2231.  
  2232. mouseDownPos = [e.clientX, e.clientY];
  2233. elementPos = [parseInt($draggedElement.style.left) || 0, parseInt($draggedElement.style.top) || 0];
  2234. }, true);
  2235. document.addEventListener('mouseup', () => {
  2236. downTimeMs = 0;
  2237. isDown = false;
  2238. }, true);
  2239. document.addEventListener('mousemove', e => {
  2240. e.preventDefault();
  2241.  
  2242. if (isDown) {
  2243. // If dragAfterTimeMs is set, then user must hold down mouse for specified time before being able to drag
  2244. if (dragAfterTimeMs && Date.now() - downTimeMs < dragAfterTimeMs) return;
  2245. const deltaX = $dragTrigger ? e.clientX + offset[0] : elementPos[0] + e.clientX - mouseDownPos[0];
  2246. const deltaY = $dragTrigger ? e.clientY + offset[1] : elementPos[1] + e.clientY - mouseDownPos[1];
  2247. $draggedElement.style.left = `${deltaX}px`;
  2248. $draggedElement.style.top = `${deltaY}px`;
  2249. }
  2250. }, true);
  2251. }
  2252.  
  2253. },{}],22:[function(require,module,exports){
  2254. "use strict";
  2255.  
  2256. Object.defineProperty(exports, "__esModule", {
  2257. value: true
  2258. });
  2259. exports.default = void 0;
  2260.  
  2261. var helpers = _interopRequireWildcard(require("./helpers"));
  2262.  
  2263. var _state = require("../../utils/state");
  2264.  
  2265. function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
  2266.  
  2267. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
  2268.  
  2269. function draggableUIWindows() {
  2270. const state = (0, _state.getState)(); // Drag all windows by their header
  2271.  
  2272. if (state.enableWindowDragging) {
  2273. Array.from(document.querySelectorAll('.window:not(.js-can-move)')).forEach($window => {
  2274. $window.classList.add('js-can-move');
  2275. helpers.dragElement($window, $window.querySelector('.titleframe'));
  2276. });
  2277. }
  2278.  
  2279. if (state.enableFrameDragging) {
  2280. // Drag all UI by clicking and holding
  2281. Array.from(document.querySelectorAll(`
  2282. .partyframes:not(.js-can-move),
  2283. #ufplayer:not(.js-can-move),
  2284. #uftarget:not(.js-can-move),
  2285. #skillbar:not(.js-can-move)
  2286. `)).forEach($frame => {
  2287. $frame.classList.add('js-can-move');
  2288. helpers.dragElement($frame, null, 1000);
  2289. });
  2290. }
  2291. }
  2292.  
  2293. function saveDraggedUIWindows() {
  2294. const state = (0, _state.getState)();
  2295.  
  2296. if (state.enableWindowDragging) {
  2297. // Save dragged UI windows position to state
  2298. Array.from(document.querySelectorAll('.window:not(.js-ui-is-saving)')).forEach($window => {
  2299. $window.classList.add('js-ui-is-saving');
  2300. const $draggableTarget = $window.querySelector('.titleframe');
  2301. const windowName = $draggableTarget.querySelector('[name="title"]').textContent;
  2302. $draggableTarget.addEventListener('mouseup', () => {
  2303. state.windowsPos[windowName] = $window.getAttribute('style');
  2304. (0, _state.saveState)();
  2305. });
  2306. });
  2307. }
  2308.  
  2309. if (state.enableFrameDragging) {
  2310. // Save dragged UI frame position to state
  2311. const saveFramePos = ($element, name) => {
  2312. if (!$element) return;
  2313. $element.classList.add('js-ui-is-saving');
  2314. $element.addEventListener('mouseup', () => {
  2315. state.windowsPos[name] = $element.getAttribute('style');
  2316. });
  2317. };
  2318.  
  2319. saveFramePos(document.querySelector('.partyframes:not(.js-ui-is-saving)'), 'partyFrame');
  2320. saveFramePos(document.querySelector('#ufplayer:not(.js-ui-is-saving)'), 'playerFrame');
  2321. saveFramePos(document.querySelector('#uftarget:not(.js-ui-is-saving)'), 'targetFrame');
  2322. saveFramePos(document.querySelector('#skillbar:not(.js-ui-is-saving)'), 'skillBar');
  2323. }
  2324. } // Loads draggable UI windows position from state
  2325.  
  2326.  
  2327. function loadDraggedUIWindowsPositions() {
  2328. const state = (0, _state.getState)();
  2329. Array.from(document.querySelectorAll('.window:not(.js-has-loaded-pos)')).forEach($window => {
  2330. $window.classList.add('js-has-loaded-pos');
  2331. const windowName = $window.querySelector('[name="title"]').textContent;
  2332. const pos = state.windowsPos[windowName];
  2333.  
  2334. if (pos) {
  2335. $window.setAttribute('style', pos);
  2336. }
  2337. });
  2338.  
  2339. const loadFramePos = ($element, name) => {
  2340. if (!$element) return;
  2341. $element.classList.add('js-has-loaded-pos');
  2342. const pos = state.windowsPos[name];
  2343.  
  2344. if (pos) {
  2345. $element.setAttribute('style', pos);
  2346. }
  2347. };
  2348.  
  2349. loadFramePos(document.querySelector('.partyframes:not(.js-has-loaded-pos)'), 'partyFrame');
  2350. loadFramePos(document.querySelector('#ufplayer:not(.js-has-loaded-pos)'), 'playerFrame');
  2351. loadFramePos(document.querySelector('#uftarget:not(.js-has-loaded-pos)'), 'targetFrame');
  2352. loadFramePos(document.querySelector('#skillbar:not(.js-has-loaded-pos)'), 'skillBar');
  2353. }
  2354.  
  2355. var _default = {
  2356. name: 'Draggable Windows',
  2357. description: 'Allows you to drag windows in the UI',
  2358. run: ({
  2359. registerOnDomChange
  2360. }) => {
  2361. draggableUIWindows();
  2362. saveDraggedUIWindows();
  2363. loadDraggedUIWindowsPositions(); // As windows open, we want to make them draggable
  2364.  
  2365. registerOnDomChange(saveDraggedUIWindows);
  2366. registerOnDomChange(draggableUIWindows);
  2367. registerOnDomChange(loadDraggedUIWindowsPositions);
  2368. }
  2369. };
  2370. exports.default = _default;
  2371.  
  2372. },{"../../utils/state":52,"./helpers":21}],23:[function(require,module,exports){
  2373. "use strict";
  2374.  
  2375. Object.defineProperty(exports, "__esModule", {
  2376. value: true
  2377. });
  2378. exports.createFriendsList = createFriendsList;
  2379. exports.removeFriendsList = removeFriendsList;
  2380. exports.toggleFriendsList = toggleFriendsList;
  2381.  
  2382. var _state = require("../../utils/state");
  2383.  
  2384. var _player = require("../../utils/player");
  2385.  
  2386. var _chat = require("../../utils/chat");
  2387.  
  2388. var _misc = require("../../utils/misc");
  2389.  
  2390. var _ui = require("../../utils/ui");
  2391.  
  2392. function createFriendsList() {
  2393. const state = (0, _state.getState)();
  2394.  
  2395. if (document.querySelector('.js-friends-list')) {
  2396. // Don't open the friends list twice.
  2397. return;
  2398. }
  2399.  
  2400. let friendsListHTML = '';
  2401. Object.keys(state.friendsList).sort().forEach(friendName => {
  2402. friendsListHTML += `
  2403. <div data-player-name="${friendName}">${friendName}</div>
  2404. <div class="btn blue js-whisper-player" data-player-name="${friendName}">Whisper</div>
  2405. <div class="btn blue js-party-player" data-player-name="${friendName}">Party invite</div>
  2406. <div class="btn orange js-unfriend-player" data-player-name="${friendName}">X</div>
  2407. <input type="text" class="js-friend-note" placeholder="You can add a note here" data-player-name="${friendName}" value="${state.friendNotes[friendName] || ''}"></input>
  2408. `;
  2409. });
  2410. const customFriendsWindowHTML = `
  2411. <div class="titleframe uimod-friends-list-helper">
  2412. <div class="textprimary title uimod-friends-list-helper">
  2413. <div name="title">Friends list</div>
  2414. </div>
  2415. <img src="/assets/ui/icons/cross.svg?v=3282286" class="js-close-custom-friends-list btn black svgicon">
  2416. </div>
  2417. <div class="uimod-friends-intro">To add someone as a friend, click their name in chat and then click Friend :)</div>
  2418. <div class="uimod-friends">${friendsListHTML}</div>
  2419. `;
  2420. const $customFriendsList = (0, _misc.makeElement)({
  2421. element: 'div',
  2422. class: 'menu window panel-black js-friends-list uimod-custom-window',
  2423. content: customFriendsWindowHTML
  2424. });
  2425. document.body.appendChild($customFriendsList);
  2426. (0, _ui.setWindowOpen)(_ui.WindowNames.friendsList); // Wire up the buttons
  2427.  
  2428. Array.from(document.querySelectorAll('.js-whisper-player')).forEach($button => {
  2429. $button.addEventListener('click', clickEvent => {
  2430. const name = clickEvent.target.getAttribute('data-player-name');
  2431. (0, _chat.whisperPlayer)(name);
  2432. });
  2433. });
  2434. Array.from(document.querySelectorAll('.js-party-player')).forEach($button => {
  2435. $button.addEventListener('click', clickEvent => {
  2436. const name = clickEvent.target.getAttribute('data-player-name');
  2437. (0, _chat.partyPlayer)(name);
  2438. });
  2439. });
  2440. Array.from(document.querySelectorAll('.js-unfriend-player')).forEach($button => {
  2441. $button.addEventListener('click', clickEvent => {
  2442. const name = clickEvent.target.getAttribute('data-player-name');
  2443. (0, _player.unfriendPlayer)(name); // Remove the blocked player from the list
  2444.  
  2445. Array.from(document.querySelectorAll(`.js-friends-list [data-player-name="${name}"]`)).forEach($element => {
  2446. $element.parentNode.removeChild($element);
  2447. });
  2448. });
  2449. });
  2450. Array.from(document.querySelectorAll('.js-friend-note')).forEach($element => {
  2451. $element.addEventListener('change', clickEvent => {
  2452. const name = clickEvent.target.getAttribute('data-player-name');
  2453. state.friendNotes[name] = clickEvent.target.value;
  2454. });
  2455. }); // The close button for our custom UI
  2456.  
  2457. document.querySelector('.js-close-custom-friends-list').addEventListener('click', removeFriendsList);
  2458. }
  2459.  
  2460. function removeFriendsList() {
  2461. const $friendsListWindow = document.querySelector('.js-friends-list');
  2462. $friendsListWindow.parentNode.removeChild($friendsListWindow);
  2463. (0, _ui.setWindowClosed)(_ui.WindowNames.friendsList);
  2464. }
  2465.  
  2466. function toggleFriendsList() {
  2467. if ((0, _ui.isWindowOpen)(_ui.WindowNames.friendsList)) {
  2468. removeFriendsList();
  2469. } else {
  2470. createFriendsList();
  2471. }
  2472. }
  2473.  
  2474. },{"../../utils/chat":48,"../../utils/misc":50,"../../utils/player":51,"../../utils/state":52,"../../utils/ui":53}],24:[function(require,module,exports){
  2475. "use strict";
  2476.  
  2477. Object.defineProperty(exports, "__esModule", {
  2478. value: true
  2479. });
  2480. Object.defineProperty(exports, "createFriendsList", {
  2481. enumerable: true,
  2482. get: function () {
  2483. return _friendsListUi.createFriendsList;
  2484. }
  2485. });
  2486. Object.defineProperty(exports, "removeFriendsList", {
  2487. enumerable: true,
  2488. get: function () {
  2489. return _friendsListUi.removeFriendsList;
  2490. }
  2491. });
  2492. exports.default = void 0;
  2493.  
  2494. var _ui = require("../../utils/ui");
  2495.  
  2496. var _friendsListUi = require("./friendsListUi");
  2497.  
  2498. var _chatContextMenu = require("../chatContextMenu");
  2499.  
  2500. var _player = require("../../utils/player");
  2501.  
  2502. var _state = require("../../utils/state");
  2503.  
  2504. function customFriendsList() {
  2505. const state = (0, _state.getState)();
  2506. const tempState = (0, _state.getTempState)();
  2507. _ui.WindowNames.friendsList = 'friends-list';
  2508. (0, _chatContextMenu.registerChatMenuItem)({
  2509. id: 'friend',
  2510. label: 'Friend',
  2511. handleClick: () => {
  2512. (0, _player.friendPlayer)(tempState.chatName);
  2513. },
  2514. handleVisibilityCheck: () => {
  2515. return !state.friendsList[tempState.chatName];
  2516. }
  2517. });
  2518. (0, _chatContextMenu.registerChatMenuItem)({
  2519. id: 'unfriend',
  2520. label: 'Unfriend',
  2521. handleClick: () => {
  2522. (0, _player.unfriendPlayer)(tempState.chatName);
  2523. },
  2524. handleVisibilityCheck: () => {
  2525. return !!state.friendsList[tempState.chatName];
  2526. }
  2527. });
  2528. (0, _ui.createNavButton)('friendslist', 'F', 'Friends List', _friendsListUi.toggleFriendsList); // If it was open when the game last closed keep it open
  2529.  
  2530. if ((0, _ui.isWindowOpen)(_ui.WindowNames.friendsList)) {
  2531. (0, _friendsListUi.createFriendsList)();
  2532. }
  2533. }
  2534.  
  2535. var _default = {
  2536. name: 'Friends list',
  2537. description: 'Allows access to your friends list from the top right F icon',
  2538. run: customFriendsList
  2539. };
  2540. exports.default = _default;
  2541.  
  2542. },{"../../utils/player":51,"../../utils/state":52,"../../utils/ui":53,"../chatContextMenu":13,"./friendsListUi":23}],25:[function(require,module,exports){
  2543. "use strict";
  2544.  
  2545. Object.defineProperty(exports, "__esModule", {
  2546. value: true
  2547. });
  2548. exports.handleHealthChange = handleHealthChange;
  2549.  
  2550. var _state = require("../../utils/state");
  2551.  
  2552. const HEALTH_PERCENTAGE_COLORS_ORANGE = {
  2553. 100: 'linear-gradient(0deg, #34CB49 0%, #2da640 49%, #34CB49 50%)',
  2554. 90: 'linear-gradient(0deg, #4AB844 0%, #3D963B 49%, #4AB844 50%)',
  2555. 80: 'linear-gradient(0deg, #61A540 0%, #4D8637 49%, #61A540 50%)',
  2556. 70: 'linear-gradient(0deg, #77923C 0%, #5E7733 49%, #77923C 50%)',
  2557. 60: 'linear-gradient(0deg, #8E7F37 0%, #6E672F 49%, #8E7F37 50%)',
  2558. 50: 'linear-gradient(0deg, #A46D33 0%, #7E582A 49%, #A46D33 50%)',
  2559. 40: 'linear-gradient(0deg, #BB8A2F 0%, #8F4826 49%, #BB8A2F 50%)',
  2560. 30: 'linear-gradient(0deg, #D1772A 0%, #9F3922 49%, #D1772A 50%)',
  2561. 20: 'linear-gradient(0deg, #E86426 0%, #AF291E 49%, #E86426 50%)',
  2562. 10: 'linear-gradient(0deg, #E04222 0%, #C01A1A 49%, #E04222 50%)'
  2563. };
  2564. const HEALTH_PERCENTAGE_COLORS_RED = {
  2565. 100: 'linear-gradient(0deg, #34CB49 0%, #2da640 49%, #34CB49 50%)',
  2566. 90: 'linear-gradient(0deg, #4AB844 0%, #3D963B 49%, #4AB844 50%)',
  2567. 80: 'linear-gradient(0deg, #61A540 0%, #4D8637 49%, #61A540 50%)',
  2568. 70: 'linear-gradient(0deg, #77923C 0%, #5E7733 49%, #77923C 50%)',
  2569. 60: 'linear-gradient(0deg, #8E7F37 0%, #6E672F 49%, #8E7F37 50%)',
  2570. 50: 'linear-gradient(0deg, #A46D33 0%, #7E582A 49%, #A46D33 50%)',
  2571. 40: 'linear-gradient(0deg, #BB5A2F 0%, #8F4826 49%, #BB5A2F 50%)',
  2572. 30: 'linear-gradient(0deg, #D1472A 0%, #9F3922 49%, #D1472A 50%)',
  2573. 20: 'linear-gradient(0deg, #E83426 0%, #AF291E 49%, #E83426 50%)',
  2574. 10: 'linear-gradient(0deg, #E02222 0%, #C01A1A 49%, #E02222 50%)'
  2575. }; // TODO: Consider separate colors for fading that starts when they're below 50%
  2576. // Abruptly fading to a dark green/orange color when they hit 50% may not look great
  2577.  
  2578. function handleHealthChange($healthBar) {
  2579. const state = (0, _state.getState)(); // Clear the custom background for enemies
  2580. // This is necessary because when switching from an allied target to an enenmy target,
  2581. // the DOM element remains the same, but the class changes, hence this observer
  2582. // is still active.
  2583.  
  2584. if ($healthBar.classList.contains('bgenemy')) {
  2585. if ($healthBar.style.background) {
  2586. $healthBar.style.background = '';
  2587. }
  2588.  
  2589. return;
  2590. }
  2591.  
  2592. let colors = {};
  2593.  
  2594. if (state.healthBarFadeColor === 'red') {
  2595. colors = HEALTH_PERCENTAGE_COLORS_RED;
  2596. } else if (state.healthBarFadeColor === 'orange') {
  2597. colors = HEALTH_PERCENTAGE_COLORS_ORANGE;
  2598. }
  2599.  
  2600. const healthPercentage = parseFloat($healthBar.style.width);
  2601. let color = ''; // If health bar is set not to fade until X%, then use the default 100% color
  2602. // if we're not supposed to fade yet
  2603.  
  2604. if (state.healthBarFadePercentage > healthPercentage) {
  2605. color = colors[100];
  2606. } else if (healthPercentage < 10) {
  2607. color = colors[10];
  2608. } else if (healthPercentage < 20) {
  2609. color = colors[20];
  2610. } else if (healthPercentage < 30) {
  2611. color = colors[30];
  2612. } else if (healthPercentage < 40) {
  2613. color = colors[40];
  2614. } else if (healthPercentage < 50) {
  2615. color = colors[50];
  2616. } else if (healthPercentage < 60) {
  2617. color = colors[60];
  2618. } else if (healthPercentage < 70) {
  2619. color = colors[70];
  2620. } else if (healthPercentage < 80) {
  2621. color = colors[80];
  2622. } else if (healthPercentage < 90) {
  2623. color = colors[90];
  2624. } else {
  2625. color = colors[100];
  2626. }
  2627.  
  2628. if ($healthBar.style.background !== color) {
  2629. $healthBar.style.background = color;
  2630. }
  2631. }
  2632.  
  2633. },{"../../utils/state":52}],26:[function(require,module,exports){
  2634. "use strict";
  2635.  
  2636. Object.defineProperty(exports, "__esModule", {
  2637. value: true
  2638. });
  2639. exports.default = void 0;
  2640.  
  2641. var _helpers = require("./helpers");
  2642.  
  2643. function healthColorChanger() {
  2644. const $healthBars = Array.from(document.querySelectorAll('.progressBar.bghealth:not(.js-healthchanger-initd)'));
  2645. $healthBars.forEach($healthBar => {
  2646. $healthBar.classList.add('js-healthchanger-initd');
  2647. (0, _helpers.handleHealthChange)($healthBar);
  2648. const observer = new MutationObserver(mutations => (0, _helpers.handleHealthChange)(mutations[0].target));
  2649. observer.observe($healthBar, {
  2650. attributes: true // When style changes, width has changed, i.e. health percentage has changed
  2651.  
  2652. });
  2653. });
  2654. }
  2655.  
  2656. var _default = {
  2657. name: 'Health color changer',
  2658. description: 'Changes the green color of allied player health bars to become darker and redder as your health gets lower',
  2659. run: ({
  2660. registerOnDomChange
  2661. }) => {
  2662. registerOnDomChange(healthColorChanger);
  2663. healthColorChanger();
  2664. }
  2665. };
  2666. exports.default = _default;
  2667.  
  2668. },{"./helpers":25}],27:[function(require,module,exports){
  2669. "use strict";
  2670.  
  2671. Object.defineProperty(exports, "__esModule", {
  2672. value: true
  2673. });
  2674. exports.default = void 0;
  2675.  
  2676. var _modStart = _interopRequireDefault(require("./_modStart"));
  2677.  
  2678. var _customSettings = _interopRequireDefault(require("./_customSettings"));
  2679.  
  2680. var _chatContextMenu = _interopRequireDefault(require("./chatContextMenu"));
  2681.  
  2682. var _chatFilters = _interopRequireDefault(require("./chatFilters"));
  2683.  
  2684. var _chatTabs = _interopRequireDefault(require("./chatTabs"));
  2685.  
  2686. var _draggableUI = _interopRequireDefault(require("./draggableUI"));
  2687.  
  2688. var _friendsList = _interopRequireDefault(require("./friendsList"));
  2689.  
  2690. var _mapControls = _interopRequireDefault(require("./mapControls"));
  2691.  
  2692. var _resizableChat = _interopRequireDefault(require("./resizableChat"));
  2693.  
  2694. var _resizableMap = _interopRequireDefault(require("./resizableMap"));
  2695.  
  2696. var _selectedWindowIsTop = _interopRequireDefault(require("./selectedWindowIsTop"));
  2697.  
  2698. var _xpMeter = _interopRequireDefault(require("./xpMeter"));
  2699.  
  2700. var _merchantFilter = _interopRequireDefault(require("./merchantFilter"));
  2701.  
  2702. var _itemStatsCopy = _interopRequireDefault(require("./itemStatsCopy"));
  2703.  
  2704. var _keyPressTracker = _interopRequireDefault(require("./_keyPressTracker"));
  2705.  
  2706. var _clanActivityTracker = _interopRequireDefault(require("./clanActivityTracker"));
  2707.  
  2708. var _skillCooldownNumbers = _interopRequireDefault(require("./skillCooldownNumbers"));
  2709.  
  2710. var _depositAll = _interopRequireDefault(require("./depositAll"));
  2711.  
  2712. var _lockedItemSlots = _interopRequireDefault(require("./lockedItemSlots"));
  2713.  
  2714. var _screenshotMode = _interopRequireDefault(require("./screenshotMode"));
  2715.  
  2716. var _buffTooltips = _interopRequireDefault(require("./buffTooltips"));
  2717.  
  2718. var _healthColorChanger = _interopRequireDefault(require("./healthColorChanger"));
  2719.  
  2720. var _blockList = _interopRequireDefault(require("./blockList"));
  2721.  
  2722. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  2723.  
  2724. // The array here dictates the order of which mods are executed, from top to bottom
  2725. var _default = [// MUST BE AT THE TOP:
  2726. _modStart.default, _keyPressTracker.default, // Order for these items only matter in regards to registering items in settings/chat menu:
  2727. _friendsList.default, _blockList.default, // Order for these items shouldn't matter:
  2728. _resizableMap.default, _mapControls.default, _resizableChat.default, _chatFilters.default, _chatTabs.default, _draggableUI.default, _selectedWindowIsTop.default, _xpMeter.default, _merchantFilter.default, _itemStatsCopy.default, _clanActivityTracker.default, _skillCooldownNumbers.default, _depositAll.default, _lockedItemSlots.default, _screenshotMode.default, _buffTooltips.default, _healthColorChanger.default, // MUST BE AT THE BOTTOM:
  2729. _customSettings.default, _chatContextMenu.default];
  2730. exports.default = _default;
  2731.  
  2732. },{"./_customSettings":2,"./_keyPressTracker":5,"./_modStart":6,"./blockList":8,"./buffTooltips":10,"./chatContextMenu":13,"./chatFilters":14,"./chatTabs":16,"./clanActivityTracker":18,"./depositAll":20,"./draggableUI":22,"./friendsList":24,"./healthColorChanger":26,"./itemStatsCopy":28,"./lockedItemSlots":30,"./mapControls":32,"./merchantFilter":34,"./resizableChat":36,"./resizableMap":38,"./screenshotMode":40,"./selectedWindowIsTop":42,"./skillCooldownNumbers":44,"./xpMeter":46}],28:[function(require,module,exports){
  2733. "use strict";
  2734.  
  2735. Object.defineProperty(exports, "__esModule", {
  2736. value: true
  2737. });
  2738. exports.default = void 0;
  2739.  
  2740. var chat = _interopRequireWildcard(require("../../utils/chat"));
  2741.  
  2742. var _game = require("../../utils/game");
  2743.  
  2744. var _state = require("../../utils/state");
  2745.  
  2746. function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
  2747.  
  2748. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
  2749.  
  2750. async function itemStatsCopy(clickEvent) {
  2751. const tempState = (0, _state.getTempState)(); // This mod only triggers if you alt+right click
  2752.  
  2753. if (!tempState.keyModifiers.alt) {
  2754. return;
  2755. }
  2756.  
  2757. const $bagSlot = document.elementFromPoint(clickEvent.clientX, clickEvent.clientY); // No item in slot
  2758.  
  2759. if (!$bagSlot.querySelector('img')) {
  2760. return;
  2761. } // Once we confirm we want to copy to clipboard, hide context menu
  2762.  
  2763.  
  2764. const $itemContextMenuChoice = document.body.querySelector('.container > .panel > .choice');
  2765.  
  2766. if (!$itemContextMenuChoice) {
  2767. // If context menu isn't open, something is not right - stop what we're doing and exit
  2768. // Seen this happen very rarely when testing
  2769. return;
  2770. }
  2771.  
  2772. const $itemContextMenu = $itemContextMenuChoice.parentNode;
  2773.  
  2774. if ($itemContextMenu) {
  2775. $itemContextMenu.style.display = 'none';
  2776. } // Get the texts we want from the tooltip
  2777.  
  2778.  
  2779. const getDetailedTooltips = true;
  2780. const $tooltip = await (0, _game.getTooltipContent)($bagSlot, getDetailedTooltips);
  2781.  
  2782. if (!$tooltip) {
  2783. // This _shouldn't_ happen, but very occasionally there is a (likely timing-related) problem getting the tooltip
  2784. return;
  2785. } // We get the detailed tooltip, which may have a second comparison tooltip. Remove the comparison tooltip if we have it.
  2786.  
  2787.  
  2788. const $comparisonTooltip = $tooltip.querySelector('.slotdescription');
  2789. if ($comparisonTooltip) $comparisonTooltip.parentNode.removeChild($comparisonTooltip); // Collect item name/stats into strings
  2790.  
  2791. const itemName = $tooltip.querySelector('.slottitle').textContent;
  2792. const $itemQuality = $tooltip.querySelector('.type span');
  2793. const itemQuality = $itemQuality.textContent; // It's not a piece of equipment, just copy item name and exit
  2794.  
  2795. if (!itemQuality.includes('%')) {
  2796. let trimmedItemName = itemName; // If item name starts with T#, e.g. T1, T5, etc, then this was added onto the detailed tooltip
  2797. // It's usually unnecessary information, so we remove it
  2798. // (e.g. shows as "T94 Centrifugal Laceration Lv. 4" instead of "Centrifugal Laceration Lv. 4")
  2799.  
  2800. if (itemName.substr(0, 2).match(/T[0-9]/)) {
  2801. trimmedItemName = itemName.substr(itemName.indexOf(' ') + 1);
  2802. }
  2803.  
  2804. navigator.clipboard.writeText(trimmedItemName);
  2805. chat.addChatMessage(`Copied ${trimmedItemName} to clipboard.`);
  2806. return;
  2807. } // We only want the lvl number, so pop off the level number from the "Requires Lv. 17" line
  2808. // To find this line, we search through all the tooltip lines for the line containing "Requires"
  2809.  
  2810.  
  2811. const $lines = Array.from($tooltip.querySelectorAll('.container .pack'));
  2812. const $itemRequirement = $lines.filter($line => $line.textContent.includes('Requires '))[0];
  2813. const itemLvl = $itemRequirement.textContent.split(' ').pop(); // Grab the stats we care about, i.e. not part of the requirements or item type
  2814.  
  2815. const $stats = Array.from($tooltip.querySelectorAll(`
  2816. .pack > .textpurp,
  2817. .pack > .textblue,
  2818. .pack > .textgreen:not(.slottitle),
  2819. .pack > .textwhite:not(.type)
  2820. `));
  2821. const statsText = $stats.map($stat => {
  2822. // We only care about lines starting with a "+ ", showcasing that a piece of gear adds a certain stat
  2823. // The comparison line near the bottom of the tooltip also has a "+", but no space after it. This shows stat differentials vs current gear - we don't want that.
  2824. if ($stat.textContent.substr(0, 2) !== '+ ') return; // Return quality percentage only if it exists, otherwise return normal stat
  2825.  
  2826. const $quality = $stat.querySelector('span');
  2827.  
  2828. if ($quality) {
  2829. const quality = $quality.textContent;
  2830. const statLineChunks = $stat.textContent.replace(/\+\s/g, '+').split(' ');
  2831. statLineChunks.pop(); // Remove quality at end
  2832.  
  2833. statLineChunks.shift(); // Remove specific +# at the beginning
  2834.  
  2835. const statName = statLineChunks.join(' ');
  2836. return `${statName} ${quality}`;
  2837. } else {
  2838. return $stat.textContent.trim();
  2839. }
  2840. }).filter(statText => !!statText) // Filter out empty stat texts, i.e. if they didn't begin with a "+"
  2841. .join(', ');
  2842. navigator.clipboard.writeText(`${itemName} ${itemQuality} Lv.${itemLvl}: ${statsText}`);
  2843. chat.addChatMessage(`Copied ${itemName}'s stats to clipboard.`);
  2844. }
  2845.  
  2846. var _default = {
  2847. name: 'Items stats copy',
  2848. description: 'When alt+left clicking a piece of equipment in your inventory, its stats will be copied to your clipboard',
  2849. run: ({
  2850. registerOnRightClick
  2851. }) => {
  2852. registerOnRightClick(itemStatsCopy);
  2853. }
  2854. };
  2855. exports.default = _default;
  2856.  
  2857. },{"../../utils/chat":48,"../../utils/game":49,"../../utils/state":52}],29:[function(require,module,exports){
  2858. "use strict";
  2859.  
  2860. Object.defineProperty(exports, "__esModule", {
  2861. value: true
  2862. });
  2863. exports.lockSlot = lockSlot;
  2864. exports.initLockedSlots = initLockedSlots;
  2865.  
  2866. var _state = require("../../utils/state");
  2867.  
  2868. var _misc = require("../../utils/misc");
  2869.  
  2870. var _ui = require("../../utils/ui");
  2871.  
  2872. var _game = require("../../utils/game");
  2873.  
  2874. function _wireLockSlot($lockedSlot) {
  2875. const state = (0, _state.getState)();
  2876. const tempState = (0, _state.getTempState)();
  2877. const slotNumber = $lockedSlot.getAttribute('data-locked-slot-num');
  2878. const $bagSlot = document.querySelector(`#bag${slotNumber}`); // Left clicking works normally, proxy it through
  2879.  
  2880. $lockedSlot.addEventListener('click', () => {
  2881. $bagSlot.dispatchEvent(new Event('pointerup'));
  2882. }); // Hovering to see the tooltip works normally, proxy it through
  2883.  
  2884. $lockedSlot.addEventListener('pointerenter', () => {
  2885. $bagSlot.dispatchEvent(new Event('pointerenter'));
  2886. });
  2887. $lockedSlot.addEventListener('pointerleave', () => {
  2888. $bagSlot.dispatchEvent(new Event('pointerleave'));
  2889. }); // Right clicking removes Drop item from menu, otherwise works normally, proxy it through
  2890.  
  2891. $lockedSlot.addEventListener('contextmenu', event => {
  2892. // Block shift+right click
  2893. if (tempState.keyModifiers.shift) return; // Don't do anything if no item in this slot
  2894.  
  2895. if (!$bagSlot.querySelector('img')) return; // Emulate right click on the item to display its context menu
  2896.  
  2897. $bagSlot.dispatchEvent(new PointerEvent('pointerup', event));
  2898. setTimeout(() => {
  2899. const $contextMenuChoices = Array.from(document.querySelectorAll('.container > .panel.context .choice')); // Remove "Drop item" from context menu
  2900.  
  2901. $contextMenuChoices.forEach($choice => {
  2902. if ($choice.textContent.toLowerCase() === 'drop item') {
  2903. $choice.style.display = 'none';
  2904. }
  2905. }); // Add "Unlock slot" menu item
  2906.  
  2907. $contextMenuChoices[0].parentNode.appendChild((0, _misc.makeElement)({
  2908. element: 'div',
  2909. class: 'choice js-unlock-item',
  2910. content: 'Unlock slot'
  2911. })); // Wire up "Unlock slot" menu item
  2912.  
  2913. const $unlockItemChoice = document.querySelector('.js-unlock-item');
  2914. $unlockItemChoice.addEventListener('click', () => {
  2915. state.lockedItemSlots.splice(state.lockedItemSlots.indexOf(parseInt(slotNumber)), 1); // console.info('unlocked locked item', slotNumber, state.lockedItemSlots);
  2916.  
  2917. (0, _state.saveState)();
  2918. $lockedSlot.parentNode.removeChild($lockedSlot); // Hide context menu after clicking unlock (removing it breaks client that tries to remove it later)
  2919.  
  2920. const $contextMenu = $unlockItemChoice.parentNode;
  2921. $contextMenu.style.display = 'none';
  2922. });
  2923. }, 0);
  2924. });
  2925. }
  2926.  
  2927. function lockSlot(slotNumber) {
  2928. const $slot = document.querySelector(`#bag${slotNumber}`);
  2929. if (!$slot) return; // If slot has already been locked, don't lock it again
  2930.  
  2931. if (document.querySelector(`.js-locked-slot[data-locked-slot-num="${slotNumber}"]`)) return;
  2932. const $lockedSlot = (0, _misc.makeElement)({
  2933. element: 'div',
  2934. class: 'js-locked-slot uimod-locked-slot'
  2935. });
  2936. $lockedSlot.setAttribute('data-locked-slot-num', slotNumber);
  2937. $lockedSlot.setAttribute('style', `left: ${$slot.offsetLeft}px; top: ${$slot.offsetTop}px;`);
  2938. $slot.parentNode.insertBefore($lockedSlot, $slot);
  2939.  
  2940. _wireLockSlot($lockedSlot);
  2941. }
  2942.  
  2943. function initLockedSlots() {
  2944. const state = (0, _state.getState)();
  2945. const $inventory = (0, _game.getWindow)(_ui.WindowNames.inventory);
  2946. if (!$inventory || $inventory.classList.contains('js-locked-slots-initd')) return;
  2947. $inventory.classList.add('js-locked-slots-initd'); // Initialize locked slots UI
  2948. // console.info('initting locked slots', state.lockedItemSlots);
  2949.  
  2950. state.lockedItemSlots.forEach(lockSlot);
  2951. }
  2952.  
  2953. },{"../../utils/game":49,"../../utils/misc":50,"../../utils/state":52,"../../utils/ui":53}],30:[function(require,module,exports){
  2954. "use strict";
  2955.  
  2956. Object.defineProperty(exports, "__esModule", {
  2957. value: true
  2958. });
  2959. exports.default = void 0;
  2960.  
  2961. var _ui = require("../../utils/ui");
  2962.  
  2963. var _game = require("../../utils/game");
  2964.  
  2965. var _state = require("../../utils/state");
  2966.  
  2967. var _misc = require("../../utils/misc");
  2968.  
  2969. var _helpers = require("./helpers");
  2970.  
  2971. function addLockItemContextMenu() {
  2972. const state = (0, _state.getState)();
  2973. const $inventory = (0, _game.getWindow)(_ui.WindowNames.inventory);
  2974. const $contextMenu = document.querySelector('.container > .panel.context:not(.js-lock-menu-initd)');
  2975. if (!$inventory || !$contextMenu) return;
  2976. const $elementUnderContextMenu = document.elementFromPoint($contextMenu.offsetLeft, $contextMenu.offsetTop - 10 // Subtract 10px to get element right above context menu, rather than context menu itself
  2977. ); // If context menu top left is not inside inventory, then this is not the inventory context menu
  2978. // For example, Queue or Party was clicked while inventory was opened
  2979.  
  2980. if (!$inventory.contains($elementUnderContextMenu)) return; // Add Lock slot, only if unlock slot doesn't exist
  2981. // Use `setTimeout` to wait for `unlock slot` to be added
  2982.  
  2983. setTimeout(() => {
  2984. // If Lock slot already added, dont add it
  2985. if (document.querySelector('.js-lock-item')) return; // If Unlock slot exists, don't add Lock slot
  2986.  
  2987. const isLocked = Array.from($contextMenu.querySelectorAll('.choice')).some($choice => $choice.textContent.toLowerCase() === 'unlock slot');
  2988. if (isLocked) return;
  2989. $contextMenu.appendChild((0, _misc.makeElement)({
  2990. element: 'div',
  2991. class: 'choice js-lock-item',
  2992. content: 'Lock slot'
  2993. }));
  2994. document.querySelector('.js-lock-item').addEventListener('click', () => {
  2995. // Get bag slot element displayed above right click menu
  2996. // Overlay of the bag slot is selected by `elementFromPoint
  2997. const $bagSlotOverlay = document.elementFromPoint($contextMenu.offsetLeft, $contextMenu.offsetTop - 10); // Parent of overlay is the bag slot. Get its id (e.g. "bag4"), then get the slot number from the id
  2998. // Occasionally $bagSlotOverlay is actually the bag slot itself, not the overlay - if the user has clicked near the edge of the bag
  2999. // In this case, don't use the parentElement
  3000.  
  3001. const bagSlotNum = parseInt($bagSlotOverlay.id ? $bagSlotOverlay.id.substr(3) : $bagSlotOverlay.parentElement.id.substr(3)); // console.info('bagslotnum lock item', bagSlotNum, $bagSlotOverlay);
  3002.  
  3003. state.lockedItemSlots.push(bagSlotNum);
  3004. (0, _state.saveState)(); // Hide context menu
  3005.  
  3006. $contextMenu.style.display = 'none'; // Add lock slot in UI
  3007.  
  3008. (0, _helpers.lockSlot)(bagSlotNum);
  3009. });
  3010. }, 0);
  3011. } // Pass `true` as argument to reinitialize even if initd
  3012.  
  3013.  
  3014. function renderLockedItemSlots() {
  3015. const $inventory = (0, _game.getWindow)(_ui.WindowNames.inventory, true);
  3016. const $inventoryContainer = $inventory.parentNode; // We listen specifically on the inventory's container to check for `style` changes
  3017. // so we know if the inventory has had its visibility toggled
  3018.  
  3019. const inventoryObserver = new MutationObserver(_helpers.initLockedSlots);
  3020. inventoryObserver.observe($inventoryContainer, {
  3021. attributes: true,
  3022. childList: false
  3023. });
  3024. (0, _helpers.initLockedSlots)();
  3025. } // Removes non-numbers and duplicates from state.lockedItemSlots, and ensures it is an array
  3026. // This is primarily necessary because the original release had a few bugs that allowed a slot
  3027. // to be in the state array multiple times, or allowed `null` to be in the array. This isn't expected and caused bugs.
  3028.  
  3029.  
  3030. function cleanLockedItemState() {
  3031. const state = (0, _state.getState)(); // If something really went wrong and lockedItemSlots isn't an array, set it to an empty array
  3032.  
  3033. if (!Array.isArray(state.lockedItemSlots)) {
  3034. state.lockedItemSlots = []; // console.info('cleared lockedItemSlots');
  3035.  
  3036. (0, _state.saveState)();
  3037. return;
  3038. } // Remove duplicates and non-numbers
  3039.  
  3040.  
  3041. const cleanedLockItems = Array.from(new Set(state.lockedItemSlots)).filter(item => typeof item === 'number');
  3042. const itemsAreSame = cleanedLockItems.sort().join() === state.lockedItemSlots.sort().join();
  3043.  
  3044. if (!itemsAreSame) {
  3045. state.lockedItemSlots = cleanedLockItems;
  3046. (0, _state.saveState)();
  3047. }
  3048. }
  3049.  
  3050. var _default = {
  3051. name: 'Locked item slots',
  3052. description: 'Allows you to lock inventory slots so you can not drop those items or shift+right click them',
  3053. run: ({
  3054. registerOnDomChange
  3055. }) => {
  3056. cleanLockedItemState(); // Initialize locked item overlays
  3057.  
  3058. renderLockedItemSlots(); // Add Lock item choice to inventory context menu
  3059.  
  3060. addLockItemContextMenu();
  3061. registerOnDomChange(addLockItemContextMenu);
  3062. }
  3063. };
  3064. exports.default = _default;
  3065.  
  3066. },{"../../utils/game":49,"../../utils/misc":50,"../../utils/state":52,"../../utils/ui":53,"./helpers":29}],31:[function(require,module,exports){
  3067. "use strict";
  3068.  
  3069. Object.defineProperty(exports, "__esModule", {
  3070. value: true
  3071. });
  3072. exports.updateMapOpacity = updateMapOpacity;
  3073. exports.resetMapZoomScale = resetMapZoomScale;
  3074.  
  3075. var _state = require("../../utils/state");
  3076.  
  3077. // On load, update map opacity to match state
  3078. // We modify the opacity of the canvas and the background color alpha of the parent container
  3079. // We do this to allow our opacity buttons to be visible on hover with 100% opacity
  3080. // (A surprisingly difficult enough task to require this implementation)
  3081. function updateMapOpacity() {
  3082. const state = (0, _state.getState)();
  3083. const $map = document.querySelector('.container canvas');
  3084. const $mapContainer = document.querySelector('.js-map');
  3085. $map.style.opacity = String(state.mapOpacity / 100);
  3086. const mapContainerBgColor = window.getComputedStyle($mapContainer, null).getPropertyValue('background-color'); // Credit for this regexp + This opacity+rgba dual implementation: https://stackoverflow.com/questions/16065998/replacing-changing-alpha-in-rgba-javascript
  3087.  
  3088. let opacity = state.mapOpacity / 100; // This is a slightly lazy browser workaround to fix a bug.
  3089. // If the opacity is `1`, and it sets `rgba` to `1`, then the browser changes the
  3090. // rgba to rgb, dropping the alpha. We could account for that and add the `alpha` back in
  3091. // later, but setting the max opacity to very close to 1 makes sure the issue never crops up.
  3092. // Fun fact: 0.99 retains the alpha, but setting this to 0.999 still causes the browser to drop the alpha. Rude.
  3093.  
  3094. if (opacity === 1) {
  3095. opacity = 0.99;
  3096. }
  3097.  
  3098. const newBgColor = mapContainerBgColor.replace(/[\d\.]+\)$/g, `${opacity})`);
  3099. $mapContainer.style['background-color'] = newBgColor; // Update the button opacity
  3100.  
  3101. const $addBtn = document.querySelector('.js-map-opacity-add');
  3102. const $minusBtn = document.querySelector('.js-map-opacity-minus'); // Hide plus button if the opacity is max
  3103.  
  3104. if (state.mapOpacity === 100) {
  3105. $addBtn.style.visibility = 'hidden';
  3106. } else {
  3107. $addBtn.style.visibility = 'visible';
  3108. } // Hide minus button if the opacity is lowest
  3109.  
  3110.  
  3111. if (state.mapOpacity === 0) {
  3112. $minusBtn.style.visibility = 'hidden';
  3113. } else {
  3114. $minusBtn.style.visibility = 'visible';
  3115. }
  3116. }
  3117.  
  3118. function resetMapZoomScale() {
  3119. const state = (0, _state.getState)();
  3120. const $map = document.querySelector('.js-map-zoom');
  3121. if (!$map) return; // If this class doesn't exist, then the map zoom mod isn't enabled
  3122.  
  3123. if (state.mapZoom === 1) return;
  3124. $map.getContext('2d').resetTransform();
  3125. }
  3126.  
  3127. },{"../../utils/state":52}],32:[function(require,module,exports){
  3128. "use strict";
  3129.  
  3130. Object.defineProperty(exports, "__esModule", {
  3131. value: true
  3132. });
  3133. exports.default = void 0;
  3134.  
  3135. var _state = require("../../utils/state");
  3136.  
  3137. var helpers = _interopRequireWildcard(require("./helpers"));
  3138.  
  3139. var _misc = require("../../utils/misc");
  3140.  
  3141. function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
  3142.  
  3143. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
  3144.  
  3145. function mapControls() {
  3146. const state = (0, _state.getState)();
  3147. const $map = document.querySelector('.container canvas');
  3148.  
  3149. if (!$map.parentNode.classList.contains('js-map')) {
  3150. $map.parentNode.classList.add('js-map');
  3151. }
  3152.  
  3153. const $mapContainer = document.querySelector('.js-map'); // We only use the `js-map-move` button in the `draggableUI` mod
  3154.  
  3155. const $mapButtons = (0, _misc.makeElement)({
  3156. element: 'div',
  3157. class: 'js-map-btns',
  3158. content: `
  3159. <button class="js-map-opacity-add">+</button>
  3160. <button class="js-map-opacity-minus">-</button>
  3161. <button class="js-map-reset">r</button>
  3162. `
  3163. }); // Add it right before the map container div
  3164.  
  3165. $map.parentNode.insertBefore($mapButtons, $map);
  3166. helpers.updateMapOpacity();
  3167. const $addBtn = document.querySelector('.js-map-opacity-add');
  3168. const $minusBtn = document.querySelector('.js-map-opacity-minus');
  3169. const $resetBtn = document.querySelector('.js-map-reset'); // Hide the buttons if map opacity is maxed/minimum
  3170.  
  3171. if (state.mapOpacity === 100) {
  3172. $addBtn.style.visibility = 'hidden';
  3173. }
  3174.  
  3175. if (state.mapOpacity === 0) {
  3176. $minusBtn.style.visibility = 'hidden';
  3177. } // Wire it up
  3178.  
  3179.  
  3180. $addBtn.addEventListener('click', () => {
  3181. // Update opacity
  3182. state.mapOpacity += 10;
  3183. (0, _state.saveState)();
  3184. helpers.updateMapOpacity();
  3185. });
  3186. $minusBtn.addEventListener('click', () => {
  3187. // Update opacity
  3188. state.mapOpacity -= 10;
  3189. (0, _state.saveState)();
  3190. helpers.updateMapOpacity();
  3191. });
  3192. $resetBtn.addEventListener('click', () => {
  3193. state.mapOpacity = 70;
  3194. state.mapWidth = '194px';
  3195. state.mapHeight = '194px';
  3196. helpers.resetMapZoomScale();
  3197. state.mapZoomScaleFactor = 1;
  3198. (0, _state.saveState)();
  3199. helpers.updateMapOpacity();
  3200. $mapContainer.style.width = state.mapWidth;
  3201. $mapContainer.style.height = state.mapHeight;
  3202. });
  3203. helpers.updateMapOpacity();
  3204. }
  3205.  
  3206. var _default = {
  3207. name: 'Map controls',
  3208. description: 'Enables hovering over the minimap to show buttons that let you increase or decrease the opacity of the map, or reset the size+transparency of it',
  3209. run: mapControls
  3210. };
  3211. exports.default = _default;
  3212.  
  3213. },{"../../utils/misc":50,"../../utils/state":52,"./helpers":31}],33:[function(require,module,exports){
  3214. "use strict";
  3215.  
  3216. Object.defineProperty(exports, "__esModule", {
  3217. value: true
  3218. });
  3219. exports.handleMerchantFilterInputChange = handleMerchantFilterInputChange;
  3220. exports.deleteMerchantObserver = deleteMerchantObserver;
  3221.  
  3222. var _game = require("../../utils/game");
  3223.  
  3224. var _state = require("../../utils/state");
  3225.  
  3226. function handleMerchantFilterInputChange() {
  3227. const $filterInput = document.querySelector('.js-merchant-filter-input');
  3228.  
  3229. if (!$filterInput) {
  3230. return;
  3231. }
  3232.  
  3233. var value = $filterInput.value;
  3234.  
  3235. if (value) {
  3236. _refreshMerchantFilter(); // When we're filtering, start refreshing merchant filter if we haven't already
  3237.  
  3238. } // If no filters, include single empty string, to make every item visible
  3239.  
  3240.  
  3241. // NOTE
  3242. var filters = value.split(',').map(v => v.trim()) || [''];
  3243. if (filters[0] === "default") {
  3244. filters = ["3stat", "nowrongbloodline", "nocrap", "properif"].concat(filters.slice(1))
  3245. }
  3246.  
  3247. const $items = Array.from(document.querySelectorAll('.js-merchant-initd .items .slot'));
  3248. $items.forEach($item => {
  3249. const tooltipContentPromise = (0, _game.getTooltipContent)($item);
  3250. tooltipContentPromise.then(tooltipContent => {
  3251. if (!tooltipContent) {
  3252. // Something weird happened, probably related to lag from looking at tooltips in bulk
  3253. // In this case where we unexpectedly don't have the tooltip, just show the item rather than error out
  3254. $item.parentNode.style.display = 'grid';
  3255. return;
  3256. }
  3257.  
  3258. var tooltipTextContent = tooltipContent.innerHTML.replace(/<[^>]*>/g, '\n').replace(/\n\s*\n/g, '\n').substring(1).toLowerCase();
  3259. var type_regex = /(?:common|uncommon|rare|epic|legendary)(?:\s)(\w+)/g
  3260. var type = type_regex.exec(tooltipTextContent);
  3261. if (type == null) {
  3262. type = "";
  3263. } else {
  3264. type = type[1];
  3265. }
  3266. if (tooltipTextContent.includes(" - ")){
  3267. // treat min max combination (like 1-2 damage) as 2 stats, except when it is a weapon
  3268. // check if item has Damage
  3269. var is_weapon = ["hammer", "bow", "staff", "sword"].includes(type);
  3270. var dmg_regex = /(\d+)(?:\s+-\s+)(\d+)/g
  3271.  
  3272. if (is_weapon) {
  3273. var replacement_string = "$1 min dmg.\n$2 max dmg.";
  3274. } else {
  3275. var replacement_string = "+ $1 min dmg.\n+ $2 max dmg."
  3276. }
  3277. tooltipTextContent = tooltipTextContent.replace(dmg_regex, replacement_string);
  3278. }
  3279.  
  3280. var plusTooltipTextContent = tooltipTextContent.split("\n").filter((line) => line.startsWith("+")).join("\n");
  3281.  
  3282.  
  3283. let filterMatchCount = 0;
  3284. filters.forEach(filter => {
  3285. // since newlines are not preserved, recreate newlines from innerHTML
  3286. // tag strip, then remove consecutive newlines, substring removes leading newline
  3287.  
  3288. if (filter === ''){
  3289. filterMatchCount++;
  3290. } else if (filter === '3stat'){
  3291. // only show 3 stat-4 stat items
  3292. if ((plusTooltipTextContent.split('+ ').length - 1) >= 3) {
  3293. filterMatchCount++;
  3294. }
  3295. } else if (filter === 'nowrongbloodline') {
  3296. var bloodlines = ["strength", "intelligence", "dexterity", "wisdom"];
  3297. var bloodline_counters = [0, 0, 0, 0];
  3298. var counter = 0;
  3299.  
  3300. for (let i = 0; i < bloodlines.length; i++) {
  3301. if (plusTooltipTextContent.includes(bloodlines[i])) {
  3302. bloodline_counters[i] += 1;
  3303. counter += 1;
  3304. }
  3305. }
  3306. if (counter == 0) {
  3307. filterMatchCount++;
  3308. } else if (counter == 1) {
  3309. var bloodline_dict = {"sword": 0, "shield": 0, "staff": 1, "orb": 1, "bow": 2, "quiver": 2, "hammer": 3, "totem": 3};
  3310. if (Object.keys(bloodline_dict).includes(type)) {
  3311. if (bloodline_counters[bloodline_dict[type]] == 1) {
  3312. filterMatchCount++;
  3313. }
  3314. } else {
  3315. filterMatchCount++;
  3316. }
  3317. }
  3318. } else if (filter === "nocrap") {
  3319. // HPr is included in HP, MPr is included in MP
  3320. var crap = ["hp", "mp"];
  3321. var counter = 0;
  3322.  
  3323. for (let i = 0; i < crap.length; i++) {
  3324. if (plusTooltipTextContent.includes(crap[i])) {
  3325. counter += 1;
  3326. }
  3327. }
  3328. if (counter == 0) {
  3329. filterMatchCount++;
  3330. }
  3331.  
  3332. } else if (filter === "properif"){
  3333. // i.e., valid only if it has both IF & luck, or neither, doesn't account for str if haste
  3334. var stats = ["luck", "item find"];
  3335. var counter = 0;
  3336.  
  3337. for (let i = 0; i < stats.length; i++) {
  3338. if (plusTooltipTextContent.includes(stats[i])) {
  3339. counter += 1;
  3340. }
  3341. }
  3342. if (counter == 0 || counter == 2) {
  3343. filterMatchCount++;
  3344. }
  3345. }
  3346.  
  3347. else {
  3348. var matchesFilter;
  3349. if (filter[0] === "+"){
  3350. filter = filter.substring(1);
  3351. matchesFilter = filter.toLowerCase().split('/').map(_ => plusTooltipTextContent.includes(_)).includes(true);
  3352. } else {
  3353. matchesFilter = filter.toLowerCase().split('/').map(_ => tooltipTextContent.includes(_)).includes(true);
  3354. }
  3355.  
  3356. if (matchesFilter) {
  3357. filterMatchCount++;
  3358. }
  3359. }
  3360. });
  3361. const matchesAllFilters = filterMatchCount === filters.length;
  3362.  
  3363. if (matchesAllFilters) {
  3364. $item.parentNode.style.display = 'grid';
  3365. } else {
  3366. $item.parentNode.style.display = 'none';
  3367. }
  3368. });
  3369. });
  3370. }
  3371.  
  3372. function _refreshMerchantFilter() {
  3373. const tempState = (0, _state.getTempState)(); // If we're already observing, we don't need to observe again
  3374.  
  3375. if (tempState.merchantLoadingObserver) return;
  3376. tempState.merchantLoadingObserver = new MutationObserver(mutation => {
  3377. // If spinner is visible, we are loading. Once spinner is not visible, we are no longer loading
  3378. if (mutation[0] && mutation[0].addedNodes[0] && mutation[0].addedNodes[0].classList.contains('spinner')) {
  3379. tempState.merchantLoading = true;
  3380. } else {
  3381. // If we were loading and now we aren't, we want to refresh the filters
  3382. if (tempState.merchantLoading) {
  3383. handleMerchantFilterInputChange();
  3384. }
  3385.  
  3386. tempState.merchantLoading = false;
  3387. }
  3388. });
  3389. tempState.merchantLoadingObserver.observe(document.querySelector('.js-merchant-initd .buy'), {
  3390. attributes: false,
  3391. childList: true,
  3392. subtree: true
  3393. });
  3394. }
  3395.  
  3396. function deleteMerchantObserver() {
  3397. const tempState = (0, _state.getTempState)();
  3398.  
  3399. if (tempState.merchantLoadingObserver) {
  3400. tempState.merchantLoading = false;
  3401. tempState.merchantLoadingObserver.disconnect();
  3402. delete tempState.merchantLoadingObserver;
  3403. }
  3404. }
  3405.  
  3406. },{"../../utils/game":49,"../../utils/state":52}],34:[function(require,module,exports){
  3407. "use strict";
  3408.  
  3409. Object.defineProperty(exports, "__esModule", {
  3410. value: true
  3411. });
  3412. exports.default = void 0;
  3413.  
  3414. var _game = require("../../utils/game");
  3415.  
  3416. var _misc = require("../../utils/misc");
  3417.  
  3418. var _ui = require("../../utils/ui");
  3419.  
  3420. var _helpers = require("./helpers");
  3421.  
  3422. function addMerchantFilter() {
  3423. const $merchant = (0, _game.getWindow)('Merchant'); // If merchant is closed or merchant filter input is already added, we dont need to do anything
  3424.  
  3425. if (!$merchant || $merchant.querySelector('.js-merchant-filter-input')) {
  3426. return;
  3427. }
  3428.  
  3429. $merchant.classList.add('js-merchant-initd');
  3430. $merchant.classList.add('uidom-merchant-with-filters');
  3431. (0, _ui.setWindowOpen)(_ui.WindowNames.merchant);
  3432. const $lvMaximumField = $merchant.querySelectorAll('input[type="number"]')[1];
  3433. const $customSearchField = (0, _misc.makeElement)({
  3434. element: 'input',
  3435. class: 'js-merchant-filter-input uidom-merchant-input',
  3436. type: 'search',
  3437. placeholder: 'Filters (comma separated)'
  3438. });
  3439. $lvMaximumField.parentNode.insertBefore($customSearchField, $lvMaximumField.nextSibling);
  3440. $merchant.querySelector('.js-merchant-filter-input').addEventListener('keyup', (0, _misc.debounce)(_helpers.handleMerchantFilterInputChange, 250));
  3441. }
  3442.  
  3443. function cleanupMerchantObserver() {
  3444. if ((0, _ui.isWindowOpen)(_ui.WindowNames.merchant)) {
  3445. const $merchant = document.querySelector('.js-merchant-initd');
  3446. if ($merchant) return;
  3447. } // Window was set to open but is actually closed, let's clean up...
  3448.  
  3449.  
  3450. (0, _ui.setWindowClosed)(_ui.WindowNames.merchant);
  3451. (0, _helpers.deleteMerchantObserver)();
  3452. }
  3453.  
  3454. var _default = {
  3455. name: 'Merchant filter',
  3456. description: 'Allows you to specify filters, or search text, for items displayed in the merchant',
  3457. run: ({
  3458. registerOnDomChange
  3459. }) => {
  3460. addMerchantFilter();
  3461. registerOnDomChange(addMerchantFilter);
  3462. registerOnDomChange(() => {
  3463. cleanupMerchantObserver();
  3464. });
  3465. }
  3466. };
  3467. exports.default = _default;
  3468.  
  3469. },{"../../utils/game":49,"../../utils/misc":50,"../../utils/ui":53,"./helpers":33}],35:[function(require,module,exports){
  3470. "use strict";
  3471.  
  3472. Object.defineProperty(exports, "__esModule", {
  3473. value: true
  3474. });
  3475. exports.resizeChat = resizeChat;
  3476.  
  3477. var _state = require("../../utils/state");
  3478.  
  3479. // Resizes chat to match what's in state
  3480. function resizeChat() {
  3481. const state = (0, _state.getState)();
  3482. const $chatContainer = document.querySelector('.js-chat-resize');
  3483. $chatContainer.style.width = state.chatWidth;
  3484. $chatContainer.style.height = state.chatHeight;
  3485. }
  3486.  
  3487. },{"../../utils/state":52}],36:[function(require,module,exports){
  3488. "use strict";
  3489.  
  3490. Object.defineProperty(exports, "__esModule", {
  3491. value: true
  3492. });
  3493. exports.default = void 0;
  3494.  
  3495. var _state = require("../../utils/state");
  3496.  
  3497. var _helpers = require("./helpers");
  3498.  
  3499. function resizableChat() {
  3500. const state = (0, _state.getState)(); // Add the appropriate classes
  3501.  
  3502. const $chatContainer = document.querySelector('#chat').parentNode;
  3503. $chatContainer.classList.add('js-chat-resize'); // Load initial chat and map size
  3504.  
  3505. if (state.chatWidth && state.chatHeight) {
  3506. (0, _helpers.resizeChat)();
  3507. } // Save chat size on resize - Disabled for now as this isn't fully working yet
  3508. // const resizeObserverChat = new ResizeObserver(() => {
  3509. // const chatWidthStr = window
  3510. // .getComputedStyle($chatContainer, null)
  3511. // .getPropertyValue('width');
  3512. // const chatHeightStr = window
  3513. // .getComputedStyle($chatContainer, null)
  3514. // .getPropertyValue('height');
  3515. // const hasWidthChanged = state.chatWidth !== chatWidthStr;
  3516. // const hasHeightChanged = state.chatHeight !== chatHeightStr;
  3517. // // If width or height has changed by 20 or more (arbitrary number), chat has been resized
  3518. // // by game, rather than by user. Don't override state in this case.
  3519. // //
  3520. // // Instead, chat should be resized to match state. This helps avoid chat resize being reset
  3521. // // by the game when the game reinitializes, i.e. when user is inactive and not focusing on game for prolonged period of time.
  3522. // const widthChangeAmount = Math.abs(parseInt(chatWidthStr) - parseInt(state.chatWidth));
  3523. // const heightChangeAmount = Math.abs(parseInt(chatHeightStr) - parseInt(state.chatHeight));
  3524. // console.log(widthChangeAmount, heightChangeAmount);
  3525. // if (widthChangeAmount >= 20 || heightChangeAmount >= 20) {
  3526. // resizeChat();
  3527. // return;
  3528. // }
  3529. // if (hasWidthChanged) state.chatWidth = chatWidthStr;
  3530. // if (hasHeightChanged) state.chatHeight = chatHeightStr;
  3531. // if (hasWidthChanged || hasHeightChanged) saveState();
  3532. // });
  3533. // resizeObserverChat.observe($chatContainer);
  3534.  
  3535. }
  3536.  
  3537. var _default = {
  3538. name: 'Resizable chat',
  3539. description: 'Allows you to resize chat by clicking and dragging from the bottom right of chat',
  3540. run: resizableChat
  3541. };
  3542. exports.default = _default;
  3543.  
  3544. },{"../../utils/state":52,"./helpers":35}],37:[function(require,module,exports){
  3545. "use strict";
  3546.  
  3547. Object.defineProperty(exports, "__esModule", {
  3548. value: true
  3549. });
  3550. exports.mapResizeHandler = mapResizeHandler;
  3551. exports.triggerMapResize = triggerMapResize;
  3552. exports.zoomAndCenterMap = zoomAndCenterMap;
  3553.  
  3554. var _state = require("../../utils/state");
  3555.  
  3556. var _misc = require("../../utils/misc");
  3557.  
  3558. // When the map container resizes, we want to update the canvas width/height and the state
  3559. function mapResizeHandler() {
  3560. if (!document.querySelector('.layout')) {
  3561. return;
  3562. }
  3563.  
  3564. const state = (0, _state.getState)();
  3565. const tempState = (0, _state.getTempState)();
  3566. const $map = document.querySelector('.container canvas').parentNode;
  3567. const $canvas = $map.querySelector('canvas'); // Get real values of map height/width, excluding padding/margin/etc
  3568. // We round the values in this file to prevent unnecessary decimal points in our map or canvas sizes
  3569. // For some people these decimal points cause the map to constantly resize, making it pretty unusable.
  3570. // Rounding the numbers fixes this.
  3571.  
  3572. const mapWidthStr = window.getComputedStyle($map, null).getPropertyValue('width');
  3573. const mapHeightStr = window.getComputedStyle($map, null).getPropertyValue('height');
  3574. const mapWidth = Math.round(Number(mapWidthStr.slice(0, -2)));
  3575. const mapHeight = Math.round(Number(mapHeightStr.slice(0, -2))); // If height/width are 0 or unset, don't resize canvas
  3576.  
  3577. if (!mapWidth || !mapHeight) {
  3578. return;
  3579. }
  3580.  
  3581. if ($canvas.width !== mapWidth) {
  3582. $canvas.width = mapWidth;
  3583. }
  3584.  
  3585. if ($canvas.height !== mapHeight) {
  3586. $canvas.height = mapHeight;
  3587. } // If we're clicking map, i.e. manually resizing, then save state
  3588. // Don't save state when minimizing/maximizing map via [M]
  3589.  
  3590.  
  3591. if (tempState.clickingMap) {
  3592. state.mapWidth = mapWidthStr;
  3593. state.mapHeight = mapHeightStr;
  3594. (0, _state.saveState)(); // If map has been resized, zoom will be reset - so we initialize it again
  3595.  
  3596. debouncedZoomAndCenterMap();
  3597. } else {
  3598. const isMaximized = mapWidth > tempState.lastMapWidth && mapHeight > tempState.lastMapHeight;
  3599.  
  3600. if (!isMaximized) {
  3601. $map.style.width = state.mapWidth;
  3602. $map.style.height = state.mapHeight; // Also update the zoom scale if map was maximized then minimized
  3603.  
  3604. debouncedZoomAndCenterMap();
  3605. }
  3606. } // Store last map width/height in temp state, so we know if we've minimized or maximized
  3607.  
  3608.  
  3609. tempState.lastMapWidth = mapWidth;
  3610. tempState.lastMapHeight = mapHeight;
  3611. } // We need to observe canvas resizes to tell when the user presses M to open the big map
  3612. // At that point, we resize the map to match the canvas
  3613.  
  3614.  
  3615. function triggerMapResize() {
  3616. if (!document.querySelector('.layout')) {
  3617. return;
  3618. }
  3619.  
  3620. const $map = document.querySelector('.container canvas').parentNode;
  3621. const $canvas = $map.querySelector('canvas'); // Get real values of map height/width, excluding padding/margin/etc
  3622.  
  3623. const mapWidthStr = window.getComputedStyle($map, null).getPropertyValue('width');
  3624. const mapHeightStr = window.getComputedStyle($map, null).getPropertyValue('height');
  3625. const mapWidth = Math.round(Number(mapWidthStr.slice(0, -2)));
  3626. const mapHeight = Math.round(Number(mapHeightStr.slice(0, -2)));
  3627. const canvasWidth = Math.round($canvas.width);
  3628. const canvasHeight = Math.round($canvas.height); // If height/width are 0 or unset, we don't care about resizing yet
  3629.  
  3630. if (!mapWidth || !mapHeight) {
  3631. return;
  3632. }
  3633.  
  3634. if (canvasWidth !== mapWidth) {
  3635. $map.style.width = `${canvasWidth}px`;
  3636. }
  3637.  
  3638. if (canvasHeight !== mapHeight) {
  3639. $map.style.height = `${canvasHeight}px`;
  3640. }
  3641. } // Scales map by specific zoom amount
  3642. // This is multiplicative on the current scale, i.e. zoom once for 110%, then zoom a second time for 110%*110% = 1.1*1.1 = 121%
  3643.  
  3644.  
  3645. function handleMapZoom(scaleAmount) {
  3646. const $map = document.querySelector('.js-map-zoom');
  3647. if (!$map) return; // This generally shouldn't get hit, except maybe when the map resize handler is hit on initialization
  3648.  
  3649. $map.getContext('2d').scale(scaleAmount, scaleAmount);
  3650. } // Resets then initializes map zoom from state, and recenters map if it's resized
  3651.  
  3652.  
  3653. function zoomAndCenterMap() {
  3654. const {
  3655. mapZoomScaleFactor
  3656. } = (0, _state.getState)();
  3657. const $map = document.querySelector('.container canvas');
  3658. if (!$map) return; // Reset map zoom first, in case it was already set
  3659.  
  3660. $map.getContext('2d').resetTransform();
  3661. handleMapZoom(mapZoomScaleFactor);
  3662. recenterMap();
  3663. } // Recenters canvas so player is in the middle of the map
  3664.  
  3665.  
  3666. function recenterMap() {
  3667. const state = (0, _state.getState)();
  3668. const $map = document.querySelector('.container canvas');
  3669. if (!$map) return; // Default Hordes minimap canvas size is 194x194
  3670.  
  3671. const defaultMapSize = 194;
  3672. const mapWidth = parseInt(state.mapWidth);
  3673. const mapHeight = parseInt(state.mapHeight); // If map is zoomed, we need to recenter by keeping the scaled map width/height in mind
  3674.  
  3675. const widthDifferential = (mapWidth / state.mapZoomScaleFactor - defaultMapSize) / 2;
  3676. const heightDifferential = (mapHeight / state.mapZoomScaleFactor - defaultMapSize) / 2;
  3677. $map.getContext('2d').translate(widthDifferential, heightDifferential);
  3678. }
  3679.  
  3680. const debouncedZoomAndCenterMap = (0, _misc.debounce)(zoomAndCenterMap, 20);
  3681.  
  3682. },{"../../utils/misc":50,"../../utils/state":52}],38:[function(require,module,exports){
  3683. "use strict";
  3684.  
  3685. Object.defineProperty(exports, "__esModule", {
  3686. value: true
  3687. });
  3688. exports.default = void 0;
  3689.  
  3690. var _state = require("../../utils/state");
  3691.  
  3692. var helpers = _interopRequireWildcard(require("./helpers"));
  3693.  
  3694. var _misc = require("../../utils/misc");
  3695.  
  3696. function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
  3697.  
  3698. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
  3699.  
  3700. function resizableMap() {
  3701. const state = (0, _state.getState)();
  3702. const tempState = (0, _state.getTempState)();
  3703. const $map = document.querySelector('.container canvas').parentNode;
  3704. const $canvas = $map.querySelector('canvas');
  3705. $map.classList.add('js-map-resize'); // Track whether we're clicking (resizing) map or not
  3706. // Used to detect if resize changes are manually done, or from minimizing/maximizing map (with [M])
  3707.  
  3708. $map.addEventListener('mousedown', () => {
  3709. tempState.clickingMap = true;
  3710. }); // Sometimes the mouseup event may be registered outside of the map - we account for this
  3711.  
  3712. document.body.addEventListener('mouseup', () => {
  3713. tempState.clickingMap = false;
  3714. });
  3715.  
  3716. if (state.mapWidth && state.mapHeight) {
  3717. $map.style.width = state.mapWidth;
  3718. $map.style.height = state.mapHeight;
  3719. helpers.mapResizeHandler(); // Update canvas size on initial load of saved map size
  3720. } // On resize of map, resize canvas to match
  3721. // Debouncing allows map to be visible while resizing
  3722.  
  3723.  
  3724. const debouncedMapResize = (0, _misc.debounce)(helpers.mapResizeHandler, 1);
  3725. const resizeObserverMap = new ResizeObserver(debouncedMapResize);
  3726. helpers.mapResizeHandler();
  3727. resizeObserverMap.observe($map); // We debounce the canvas resize, so it doesn't resize every single
  3728. // pixel you move when resizing the DOM. If this were to happen,
  3729. // resizing would constantly be interrupted. You'd have to resize a tiny bit,
  3730. // lift left click, left click again to resize a tiny bit more, etc.
  3731. // Resizing is smooth when we debounce this canvas.
  3732.  
  3733. const debouncedTriggerResize = (0, _misc.debounce)(helpers.triggerMapResize, 50);
  3734. const resizeObserverCanvas = new ResizeObserver(debouncedTriggerResize);
  3735. resizeObserverCanvas.observe($canvas);
  3736. }
  3737.  
  3738. function zoomMap() {
  3739. const state = (0, _state.getState)(); // Wire up zooming
  3740.  
  3741. const $map = document.querySelector('.container canvas:not(.js-map-zoom)');
  3742. if (!$map) return;
  3743. $map.classList.add('js-map-zoom'); // On mouse wheel, zoom in/out 10%
  3744.  
  3745. $map.addEventListener('wheel', event => {
  3746. if (event.deltaY < 0) {
  3747. // Zoom in on mouse scroll up
  3748. if (state.mapZoomScaleFactor >= 3) return; // This is a neat problem - in JS, 0.7+0.1 is not 0.8, it's 0.7999999999999999 due to floating point issues- we round here to bypass that
  3749.  
  3750. state.mapZoomScaleFactor = Math.round((state.mapZoomScaleFactor + 0.1) * 10) / 10;
  3751. (0, _state.saveState)();
  3752. helpers.zoomAndCenterMap();
  3753. } else {
  3754. // Zoom out on mouse scroll down
  3755. if (state.mapZoomScaleFactor <= 0.3) return;
  3756. state.mapZoomScaleFactor = Math.round((state.mapZoomScaleFactor - 0.1) * 10) / 10;
  3757. (0, _state.saveState)();
  3758. helpers.zoomAndCenterMap();
  3759. }
  3760. }); // Initialize current zoom if user has zoomed
  3761.  
  3762. helpers.zoomAndCenterMap();
  3763. }
  3764.  
  3765. var _default = {
  3766. name: 'Resizable, zoomable map',
  3767. description: 'Allows you to resize the map by clicking and dragging from the bottom left. Also allows you to zoom the map with your mousewheel.',
  3768. run: () => {
  3769. resizableMap();
  3770. zoomMap();
  3771. }
  3772. };
  3773. exports.default = _default;
  3774.  
  3775. },{"../../utils/misc":50,"../../utils/state":52,"./helpers":37}],39:[function(require,module,exports){
  3776. "use strict";
  3777.  
  3778. Object.defineProperty(exports, "__esModule", {
  3779. value: true
  3780. });
  3781. exports.toggleScreenshotMode = toggleScreenshotMode;
  3782.  
  3783. var _screenshotWarningUi = require("./screenshotWarningUi");
  3784.  
  3785. function toggleScreenshotMode(keyEvent) {
  3786. // All of the UI elements we want to hide
  3787. const $expBar = document.querySelector('#expbar'); // Player exp bar
  3788.  
  3789. const $actionBar = document.querySelector('.actionbarcontainer'); // Skillbar & player/target hp bar
  3790.  
  3791. const $mainUI = document.querySelector('.layout > .container'); // The rest of the UI
  3792. // On release of F9 hide/show these UI elements and the screenshot warning
  3793.  
  3794. if (keyEvent.keyCode == '120') {
  3795. if ($expBar.style.display != 'none') {
  3796. $mainUI.style.display = 'none';
  3797. $expBar.style.display = 'none';
  3798. $actionBar.style.display = 'none';
  3799. (0, _screenshotWarningUi.createScreenshotWarning)();
  3800. } else {
  3801. $mainUI.style.display = 'block';
  3802. $expBar.style.display = 'block';
  3803. $actionBar.style.display = 'block';
  3804. (0, _screenshotWarningUi.removeScreenshotWarning)();
  3805. }
  3806. }
  3807. }
  3808.  
  3809. },{"./screenshotWarningUi":41}],40:[function(require,module,exports){
  3810. "use strict";
  3811.  
  3812. Object.defineProperty(exports, "__esModule", {
  3813. value: true
  3814. });
  3815. exports.default = void 0;
  3816.  
  3817. var _helper = require("./helper");
  3818.  
  3819. function screenshotMode() {
  3820. window.addEventListener('keyup', _helper.toggleScreenshotMode);
  3821. }
  3822.  
  3823. var _default = {
  3824. name: 'Screenshot Mode',
  3825. description: 'F9 key toggles game UI visibly for cleaner screenshots',
  3826. run: screenshotMode
  3827. };
  3828. exports.default = _default;
  3829.  
  3830. },{"./helper":39}],41:[function(require,module,exports){
  3831. "use strict";
  3832.  
  3833. Object.defineProperty(exports, "__esModule", {
  3834. value: true
  3835. });
  3836. exports.createScreenshotWarning = createScreenshotWarning;
  3837. exports.removeScreenshotWarning = removeScreenshotWarning;
  3838.  
  3839. var _misc = require("../../utils/misc");
  3840.  
  3841. function createScreenshotWarning() {
  3842. // If it already exists kill it so we can remake it with a fresh fadeout
  3843. if (document.querySelector('js-screenshot-warning')) {
  3844. removeScreenshotWarning();
  3845. }
  3846.  
  3847. const $screenshotWarningContainer = (0, _misc.makeElement)({
  3848. element: 'span',
  3849. class: 'js-screenshot-warning uimod-screenshot-warning-container'
  3850. });
  3851. const $screenshotWarning = (0, _misc.makeElement)({
  3852. element: 'span',
  3853. class: 'uimod-screenshot-warning',
  3854. content: 'Press F9 to exit screenshot mode'
  3855. });
  3856. $screenshotWarningContainer.appendChild($screenshotWarning);
  3857. document.body.appendChild($screenshotWarningContainer);
  3858. setTimeout(() => {
  3859. $screenshotWarningContainer.classList.add('uimod-screenshot-warning-fadeout');
  3860. }, 3000);
  3861. }
  3862.  
  3863. function removeScreenshotWarning() {
  3864. const $screenshotWarning = document.querySelector('.js-screenshot-warning'); // If it's already removed for some reason don't bother trying to remove it
  3865.  
  3866. if (!$screenshotWarning) {
  3867. return;
  3868. }
  3869.  
  3870. $screenshotWarning.parentNode.removeChild($screenshotWarning);
  3871. }
  3872.  
  3873. },{"../../utils/misc":50}],42:[function(require,module,exports){
  3874. "use strict";
  3875.  
  3876. Object.defineProperty(exports, "__esModule", {
  3877. value: true
  3878. });
  3879. exports.default = void 0;
  3880.  
  3881. // The last clicked UI window displays above all other UI windows
  3882. // This is useful when, for example, your inventory is near the market window,
  3883. // and you want the window and the tooltips to display above the market window.
  3884. function selectedWindowIsTop() {
  3885. Array.from(document.querySelectorAll('.window:not(.js-is-top-initd)')).forEach($window => {
  3886. $window.classList.add('js-is-top-initd');
  3887. $window.addEventListener('mousedown', () => {
  3888. // First, make the other is-top window not is-top
  3889. const $otherWindowContainer = document.querySelector('.js-is-top');
  3890.  
  3891. if ($otherWindowContainer) {
  3892. $otherWindowContainer.classList.remove('js-is-top');
  3893. } // Then, make our window's container (the z-index container) is-top
  3894.  
  3895.  
  3896. $window.parentNode.classList.add('js-is-top');
  3897. });
  3898. });
  3899. }
  3900.  
  3901. var _default = {
  3902. name: 'Make Selected Window Top',
  3903. description: 'The UI window you click will always be displayed over other UI windows',
  3904. run: ({
  3905. registerOnDomChange
  3906. }) => {
  3907. selectedWindowIsTop(); // As windows are opened, we want to enable them to become the top window when they're clicked
  3908.  
  3909. registerOnDomChange(selectedWindowIsTop);
  3910. }
  3911. };
  3912. exports.default = _default;
  3913.  
  3914. },{}],43:[function(require,module,exports){
  3915. "use strict";
  3916.  
  3917. Object.defineProperty(exports, "__esModule", {
  3918. value: true
  3919. });
  3920. exports.addSkillCooldownNumbers = addSkillCooldownNumbers;
  3921.  
  3922. var _state = require("../../utils/state");
  3923.  
  3924. var _misc = require("../../utils/misc");
  3925.  
  3926. function _getCooldownText(cd) {
  3927. const timeBetweenCooldownChecks = cd.latestCooldownTimestamp - cd.initialCooldownTimestamp;
  3928. const percentCompletedWithinTime = cd.initialCooldownPcntLeft - cd.latestCooldownPcntLeft;
  3929. const secondsForOnePercent = timeBetweenCooldownChecks / percentCompletedWithinTime / 1000;
  3930. return Math.floor(secondsForOnePercent * cd.latestCooldownPcntLeft);
  3931. }
  3932.  
  3933. function _handleCooldownUpdate(mutations) {
  3934. const tempState = (0, _state.getTempState)();
  3935. mutations.forEach(mutation => {
  3936. const $cooldownOverlay = mutation.target;
  3937. const isValidCooldownOverlay = $cooldownOverlay.parentElement && // This happens for some people for some unknown reason - maybe the overlay is removed from the DOM for some reason?
  3938. !$cooldownOverlay.classList.contains('offCd') && $cooldownOverlay.classList.contains('js-cooldown-num-initd'); // TODO: Remove this once we figure out why cooldown doesnt show occasionally
  3939.  
  3940. if (!isValidCooldownOverlay || typeof $cooldownOverlay.step !== 'number') {
  3941. console.debug('cooldown not valid - overlay, parent', $cooldownOverlay, $cooldownOverlay.parentElement);
  3942. }
  3943.  
  3944. if (!isValidCooldownOverlay || typeof $cooldownOverlay.step !== 'number') return;
  3945. const skillId = $cooldownOverlay.parentNode.id;
  3946. const cooldownPercentageLeft = $cooldownOverlay.step; // `step` prop added by game, 100-0 for 100% CD left, 99% CD left, etc
  3947.  
  3948. let cdState = tempState.cooldownNums[skillId]; // If cooldown percentage left is greater than the current initial cooldown pcnt left,
  3949. // that means the skill cooldown counter is still tracking an old cooldown.
  3950. // This can happen rarely if the user casts the ability the instant it comes off cooldown.
  3951. // In this scenario, we want to reset the cooldown state.
  3952. // If we don't reset the cooldown state, the cooldown number will be wrong because
  3953. // `initialCooldownTime` will be from the previous cast, not the current cast.
  3954.  
  3955. if (cdState.initialCooldownPcntLeft && cooldownPercentageLeft >= cdState.initialCooldownPcntLeft) {
  3956. cdState.initialCooldownTimestamp = null;
  3957. cdState.initialCooldownPcntLeft = null;
  3958. cdState.latestCooldownTimestamp = null;
  3959. cdState.latestCooldownPcntLeft = null;
  3960. cdState.calculationCount = 0;
  3961. }
  3962.  
  3963. if (!cdState.initialCooldownTimestamp) {
  3964. cdState.initialCooldownTimestamp = Date.now();
  3965. cdState.initialCooldownPcntLeft = cooldownPercentageLeft;
  3966. }
  3967.  
  3968. cdState.latestCooldownTimestamp = Date.now();
  3969. cdState.latestCooldownPcntLeft = cooldownPercentageLeft;
  3970. cdState.calculationCount++; // Set the cooldown number in the UI
  3971. // NOTE: Changed `calculationCount > 2` to `calculationCount % 3` to stabilize as they're displayed in UI
  3972. // Credit for this idea: Luffa
  3973.  
  3974. if (cdState.calculationCount > 1 && cdState.calculationCount % 3) {
  3975. const $cooldownNum = $cooldownOverlay.querySelector('.js-cooldown-num');
  3976. $cooldownNum.innerText = _getCooldownText(cdState);
  3977. }
  3978. });
  3979. } // TODO: This isn't capturing the img inside of the overlay that appears on CD. Why not?
  3980. // TODO: Look into seeing if we can identify the percentage based off the image (maybe just map the images to percentages...)
  3981.  
  3982.  
  3983. function addSkillCooldownNumbers() {
  3984. const tempState = (0, _state.getTempState)(); // Add/update cooldowns
  3985.  
  3986. const $skillCooldowns = document.querySelectorAll('#skillbar .overlay:not(.js-cooldown-num-initd):not(.offCd)');
  3987. if ($skillCooldowns.length === 0) return;
  3988. Array.from($skillCooldowns).forEach($skillOverlay => {
  3989. $skillOverlay.classList.add('js-cooldown-num-initd'); // Add cooldown element to overlay
  3990.  
  3991. $skillOverlay.appendChild((0, _misc.makeElement)({
  3992. element: 'div',
  3993. class: 'js-cooldown-num'
  3994. }));
  3995. const cooldownObserver = new MutationObserver(_handleCooldownUpdate); // Add cooldown number and mutator to state
  3996.  
  3997. const skillId = $skillOverlay.parentNode.id;
  3998. tempState.cooldownNums[skillId] = {
  3999. initialCooldownTimestamp: null,
  4000. initialCooldownPcntLeft: null,
  4001. latestCooldownTimestamp: null,
  4002. latestCooldownPcntLeft: null,
  4003. calculationCount: 0
  4004. }; // Clear preexisting observer if it exists, then set new one to state
  4005.  
  4006. if (tempState.cooldownObservers[skillId]) {
  4007. tempState.cooldownObservers[skillId].disconnect();
  4008. delete tempState.cooldownObservers[skillId];
  4009. }
  4010.  
  4011. tempState.cooldownObservers[skillId] = cooldownObserver;
  4012. cooldownObserver.observe($skillOverlay, {
  4013. childList: true
  4014. });
  4015. });
  4016. }
  4017.  
  4018. },{"../../utils/misc":50,"../../utils/state":52}],44:[function(require,module,exports){
  4019. "use strict";
  4020.  
  4021. Object.defineProperty(exports, "__esModule", {
  4022. value: true
  4023. });
  4024. exports.default = void 0;
  4025.  
  4026. var _state = require("../../utils/state");
  4027.  
  4028. var _helpers = require("./helpers");
  4029.  
  4030. function skillCooldownNumbers() {
  4031. const tempState = (0, _state.getTempState)(); // If not initialized, initialize with initial observer
  4032.  
  4033. const $skillBar = document.querySelector('#skillbar:not(.js-cooldowns-skillbar-initd');
  4034. if (!$skillBar) return;
  4035. $skillBar.classList.add('js-cooldowns-skillbar-initd');
  4036.  
  4037. if (tempState.skillBarObserver) {
  4038. tempState.skillBarObserver.disconnect();
  4039. delete tempState.skillBarObserver;
  4040. }
  4041.  
  4042. tempState.skillBarObserver = new MutationObserver(_helpers.addSkillCooldownNumbers);
  4043. tempState.skillBarObserver.observe($skillBar, {
  4044. subtree: true,
  4045. childList: true
  4046. });
  4047. (0, _helpers.addSkillCooldownNumbers)();
  4048. }
  4049.  
  4050. var _default = {
  4051. name: 'Skill cooldown numbers',
  4052. description: 'Overlays time left on cooldown over skill icons',
  4053. run: () => {
  4054. skillCooldownNumbers();
  4055. }
  4056. };
  4057. exports.default = _default;
  4058.  
  4059. },{"../../utils/state":52,"./helpers":43}],45:[function(require,module,exports){
  4060. "use strict";
  4061.  
  4062. Object.defineProperty(exports, "__esModule", {
  4063. value: true
  4064. });
  4065. exports.getCurrentCharacterLvl = getCurrentCharacterLvl;
  4066. exports.getCurrentXp = getCurrentXp;
  4067. exports.getNextLevelXp = getNextLevelXp;
  4068. exports.resetXpMeterState = resetXpMeterState;
  4069. exports.msToString = msToString;
  4070.  
  4071. var _state = require("../../utils/state");
  4072.  
  4073. function getCurrentCharacterLvl() {
  4074. return Number(document.querySelector('#ufplayer .bgmana > .left').textContent.split('Lv. ')[1]);
  4075. }
  4076.  
  4077. function getCurrentXp() {
  4078. return Number(document.querySelector('#expbar .progressBar > .left').textContent.split('/')[0].replace(/,/g, '').trim());
  4079. }
  4080.  
  4081. function getNextLevelXp() {
  4082. return Number(document.querySelector('#expbar .progressBar > .left').textContent.split('/')[1].replace(/,/g, '').replace('EXP', '').trim());
  4083. } // user invoked reset of xp meter stats
  4084.  
  4085.  
  4086. function resetXpMeterState() {
  4087. const state = (0, _state.getState)();
  4088. state.xpMeterState.xpGains = []; // array of xp deltas every second
  4089.  
  4090. state.xpMeterState.averageXp = 0;
  4091. state.xpMeterState.gainedXp = 0;
  4092. (0, _state.saveState)();
  4093. document.querySelector('.js-xp-time').textContent = '-:-:-';
  4094. }
  4095.  
  4096. function msToString(ms) {
  4097. const pad = value => value < 10 ? `0${value}` : value;
  4098.  
  4099. const hours = pad(Math.floor(ms / (1000 * 60 * 60) % 60));
  4100. const minutes = pad(Math.floor(ms / (1000 * 60) % 60));
  4101. const seconds = pad(Math.floor(ms / 1000 % 60));
  4102. return `${hours}:${minutes}:${seconds}`;
  4103. }
  4104.  
  4105. },{"../../utils/state":52}],46:[function(require,module,exports){
  4106. "use strict";
  4107.  
  4108. Object.defineProperty(exports, "__esModule", {
  4109. value: true
  4110. });
  4111. exports.default = void 0;
  4112.  
  4113. var _state = require("../../utils/state");
  4114.  
  4115. var helpers = _interopRequireWildcard(require("./helpers"));
  4116.  
  4117. var _ui = require("../../utils/ui");
  4118.  
  4119. var _xpMeterUi = require("./xpMeterUi");
  4120.  
  4121. function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
  4122.  
  4123. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
  4124.  
  4125. // TODO: Consider adding start button to start interval, and stop after X minutes of no EXP
  4126. // Or maybe watch XP bar and start it once XP bar first moves?
  4127. // Adds XP Meter DOM icon and window, starts continuous interval to get current xp over time
  4128. function xpMeter() {
  4129. const state = (0, _state.getState)();
  4130. const tempState = (0, _state.getTempState)();
  4131. _ui.WindowNames.xpMeter = 'xp-meter';
  4132. (0, _xpMeterUi.createXpMeter)(); // If it was open when the game last closed keep it open
  4133.  
  4134. if ((0, _ui.isWindowOpen)(_ui.WindowNames.xpMeter)) {
  4135. (0, _xpMeterUi.toggleXpMeterVisibility)();
  4136. } // Wire up icon and xpmeter window
  4137.  
  4138.  
  4139. (0, _ui.createNavButton)('xpmeter', 'XP', 'XP Meter', _xpMeterUi.toggleXpMeterVisibility);
  4140. document.querySelector('.js-xpmeter-close-icon').addEventListener('click', _xpMeterUi.toggleXpMeterVisibility);
  4141. document.querySelector('.js-xpmeter-reset-button').addEventListener('click', helpers.resetXpMeterState);
  4142. const currentXp = helpers.getCurrentXp();
  4143. const currentCharLvl = helpers.getCurrentCharacterLvl();
  4144. if (currentXp !== state.xpMeterState.currentXp) state.xpMeterState.currentXp = currentXp;
  4145. if (currentCharLvl !== state.xpMeterState.currentLvl) state.xpMeterState.currentLvl = currentCharLvl;
  4146. (0, _state.saveState)();
  4147. if (tempState.xpMeterInterval) clearInterval(tempState.xpMeterInterval); // every second we run the operations for xp meter, update xps, calc delta, etc
  4148. // TODO Cleanup: This interval may not be cleaned up if the UI mod reinitializes,
  4149. // e.g. user is away from tab for a while then comes back
  4150. // Should confirm if this is an issue, and try to fix it if possible.
  4151.  
  4152. tempState.xpMeterInterval = setInterval(() => {
  4153. if (!document.querySelector('#expbar')) {
  4154. return;
  4155. } // This _shouldn't_ happen, but in case it does, reset xp meter state instead of throwing error
  4156.  
  4157.  
  4158. if (!Array.isArray(state.xpMeterState.xpGains)) {
  4159. helpers.resetXpMeterState();
  4160. }
  4161.  
  4162. const currentXp = helpers.getCurrentXp();
  4163. const nextLvlXp = helpers.getNextLevelXp();
  4164. const currentLvl = helpers.getCurrentCharacterLvl(); // Only update and save state if it has changed
  4165.  
  4166. const gainedXp = currentXp - state.xpMeterState.currentXp;
  4167. const xpGains = currentXp - state.xpMeterState.currentXp;
  4168. const averageXp = state.xpMeterState.xpGains.length > 0 ? state.xpMeterState.xpGains.reduce((a, b) => a + b, 0) / state.xpMeterState.xpGains.length : 0; // Our algorithms and session time depend on an xpGain being pushed every second, even if it is 0
  4169.  
  4170. state.xpMeterState.xpGains.push(xpGains); // array of xp deltas every second
  4171.  
  4172. if (gainedXp !== 0) state.xpMeterState.gainedXp += gainedXp;
  4173. if (currentXp !== state.xpMeterState.currentXp) state.xpMeterState.currentXp = currentXp;
  4174. if (averageXp !== state.xpMeterState.averageXp) state.xpMeterState.averageXp = averageXp;
  4175. (0, _state.saveState)();
  4176.  
  4177. if (document.querySelector('.js-xpmeter')) {
  4178. document.querySelector('.js-xpm').textContent = parseInt((state.xpMeterState.averageXp * 60).toFixed(0)).toLocaleString();
  4179. document.querySelector('.js-xph').textContent = parseInt((state.xpMeterState.averageXp * 60 * 60).toFixed(0)).toLocaleString();
  4180. document.querySelector('.js-xpg').textContent = state.xpMeterState.gainedXp.toLocaleString();
  4181. document.querySelector('.js-xpl').textContent = (nextLvlXp - currentXp).toLocaleString();
  4182. document.querySelector('.js-xp-s-time').textContent = helpers.msToString(state.xpMeterState.xpGains.length * 1000); // need a positive integer for averageXp to calc time left
  4183.  
  4184. if (state.xpMeterState.averageXp > 0) document.querySelector('.js-xp-time').textContent = helpers.msToString((nextLvlXp - currentXp) / state.xpMeterState.averageXp * 1000);
  4185. }
  4186.  
  4187. if (state.xpMeterState.currentLvl < currentLvl) {
  4188. helpers.resetXpMeterState();
  4189. state.xpMeterState.currentLvl = currentLvl;
  4190. (0, _state.saveState)();
  4191. }
  4192. }, 1000);
  4193. }
  4194.  
  4195. var _default = {
  4196. name: 'XP Meter',
  4197. description: "Tracks your XP/minute and displays how much XP you're getting and lets you know how long until you level up",
  4198. run: xpMeter
  4199. };
  4200. exports.default = _default;
  4201.  
  4202. },{"../../utils/state":52,"../../utils/ui":53,"./helpers":45,"./xpMeterUi":47}],47:[function(require,module,exports){
  4203. "use strict";
  4204.  
  4205. Object.defineProperty(exports, "__esModule", {
  4206. value: true
  4207. });
  4208. exports.toggleXpMeterVisibility = toggleXpMeterVisibility;
  4209. exports.createXpMeter = createXpMeter;
  4210.  
  4211. var _ui = require("../../utils/ui");
  4212.  
  4213. var _misc = require("../../utils/misc");
  4214.  
  4215. function toggleXpMeterVisibility() {
  4216. const xpMeterContainer = document.querySelector('.js-xpmeter'); // Make it if it doesn't exist for some reason
  4217.  
  4218. if (!xpMeterContainer) {
  4219. createXpMeter();
  4220. }
  4221.  
  4222. xpMeterContainer.style.display = xpMeterContainer.style.display === 'none' ? 'block' : 'none'; // Save whether xpMeter is currently open or closed in the state
  4223.  
  4224. if (xpMeterContainer.style.display === 'none') {
  4225. (0, _ui.setWindowClosed)(_ui.WindowNames.xpMeter);
  4226. } else {
  4227. (0, _ui.setWindowOpen)(_ui.WindowNames.xpMeter);
  4228. }
  4229. }
  4230.  
  4231. function createXpMeter() {
  4232. const $layoutContainer = document.querySelector('body > div.layout > div.container:nth-child(1)');
  4233. const xpMeterHTMLString = `
  4234. <div class="l-corner-lr container uimod-xpmeter-1 js-xpmeter" style="display: none">
  4235. <div class="window panel-black uimod-xpmeter-2">
  4236. <div class="titleframe uimod-xpmeter-2">
  4237. <img src="/assets/ui/icons/trophy.svg?v=3282286" class="titleicon svgicon uimod-xpmeter-2">
  4238. <div class="textprimary title uimod-xpmeter-2">
  4239. <div name="title">Experience / XP</div>
  4240. </div>
  4241. <img src="/assets/ui/icons/cross.svg?v=3282286" class="js-xpmeter-close-icon btn black svgicon">
  4242. </div>
  4243. <div class="slot uimod-xpmeter-2" style="">
  4244. <div class="wrapper uimod-xpmeter-1">
  4245. <div class="bar uimod-xpmeter-3" style="z-index: 0;">
  4246. <div class="progressBar bgc1 uimod-xpmeter-3" style="width: 100%; font-size: 1em;">
  4247. <span class="left uimod-xpmeter-3">XP per minute:</span>
  4248. <span class="right uimod-xpmeter-3 js-xpm">-</span>
  4249. </div>
  4250. <div class="progressBar bgc1 uimod-xpmeter-3" style="width: 100%; font-size: 1em;">
  4251. <span class="left uimod-xpmeter-3">XP per hour:</span>
  4252. <span class="right uimod-xpmeter-3 js-xph">-</span>
  4253. </div>
  4254. <div class="progressBar bgc1 uimod-xpmeter-3" style="width: 100%; font-size: 1em;">
  4255. <span class="left uimod-xpmeter-3">XP Gained:</span>
  4256. <span class="right uimod-xpmeter-3 js-xpg">-</span>
  4257. </div>
  4258. <div class="progressBar bgc1 uimod-xpmeter-3" style="width: 100%; font-size: 1em;">
  4259. <span class="left uimod-xpmeter-3">XP Left:</span>
  4260. <span class="right uimod-xpmeter-3 js-xpl">-</span>
  4261. </div>
  4262. <div class="progressBar bgc1 uimod-xpmeter-3" style="width: 100%; font-size: 1em;">
  4263. <span class="left uimod-xpmeter-3">Session Time: </span>
  4264. <span class="right uimod-xpmeter-3 js-xp-s-time">-</span>
  4265. </div>
  4266. <div class="progressBar bgc1 uimod-xpmeter-3" style="width: 100%; font-size: 1em;">
  4267. <span class="left uimod-xpmeter-3">Time to lvl: </span>
  4268. <span class="right uimod-xpmeter-3 js-xp-time">-</span>
  4269. </div>
  4270. </div>
  4271. </div>
  4272. <div class="grid buttons marg-top uimod-xpmeter-1 js-xpmeter-reset-button">
  4273. <div class="btn grey">Reset</div>
  4274. </div>
  4275. </div>
  4276. </div>
  4277. </div>
  4278. `;
  4279. const $xpMeterElement = (0, _misc.makeElement)({
  4280. element: 'div',
  4281. content: xpMeterHTMLString.trim()
  4282. });
  4283. $layoutContainer.appendChild($xpMeterElement.firstChild);
  4284. }
  4285.  
  4286. },{"../../utils/misc":50,"../../utils/ui":53}],48:[function(require,module,exports){
  4287. "use strict";
  4288.  
  4289. Object.defineProperty(exports, "__esModule", {
  4290. value: true
  4291. });
  4292. exports.filterAllChat = filterAllChat;
  4293. exports.whisperPlayer = whisperPlayer;
  4294. exports.partyPlayer = partyPlayer;
  4295. exports.addChatMessage = addChatMessage;
  4296.  
  4297. var _state = require("./state");
  4298.  
  4299. var _misc = require("./misc");
  4300.  
  4301. // Filters all chat based on custom filters
  4302. function filterAllChat() {
  4303. const state = (0, _state.getState)(); // Blocked user filter
  4304.  
  4305. Object.keys(state.blockList).forEach(blockedName => {
  4306. // Get the `.name` elements from the blocked user, if we haven't already hidden their messages
  4307. const $blockedChatNames = Array.from(document.querySelectorAll(`[data-chat-name="${blockedName}"]:not(.js-line-blocked)`)); // Hide each of their messages
  4308.  
  4309. $blockedChatNames.forEach($name => {
  4310. // Add the class name to $name so we can track whether it's been hidden in our CSS selector $blockedChatNames
  4311. $name.classList.add('js-line-blocked');
  4312. const $line = $name.parentNode.parentNode.parentNode; // Add the class name to $line so we can visibly hide the entire chat line
  4313.  
  4314. $line.classList.add('js-line-blocked');
  4315. });
  4316. });
  4317. }
  4318.  
  4319. function enterTextIntoChat(text) {
  4320. // Open chat input
  4321. const enterEvent = new KeyboardEvent('keydown', {
  4322. bubbles: true,
  4323. cancelable: true,
  4324. keyCode: 13
  4325. });
  4326. document.body.dispatchEvent(enterEvent); // Place text into chat
  4327.  
  4328. const $input = document.querySelector('#chatinput input');
  4329. $input.value = text; // Get chat input to recognize slash commands and change the channel
  4330. // by triggering the `input` event.
  4331. // (Did some debugging to figure out the channel only changes when the
  4332. // svelte `input` event listener exists.)
  4333.  
  4334. const inputEvent = new KeyboardEvent('input', {
  4335. bubbles: true,
  4336. cancelable: true
  4337. });
  4338. $input.dispatchEvent(inputEvent);
  4339. }
  4340.  
  4341. function submitChat() {
  4342. const $input = document.querySelector('#chatinput input');
  4343. const kbEvent = new KeyboardEvent('keydown', {
  4344. bubbles: true,
  4345. cancelable: true,
  4346. keyCode: 13
  4347. });
  4348. $input.dispatchEvent(kbEvent);
  4349. } // Automated chat command helpers
  4350. // (We've been OK'd to do these by the dev - all automation like this should receive approval from the dev)
  4351.  
  4352.  
  4353. function whisperPlayer(playerName) {
  4354. enterTextIntoChat(`/${playerName} `);
  4355. }
  4356.  
  4357. function partyPlayer(playerName) {
  4358. enterTextIntoChat(`/partyinvite ${playerName}`);
  4359. submitChat();
  4360. } // Pushes message to chat
  4361. // TODO: The margins for the message are off slightly compared to other messages - why?
  4362.  
  4363.  
  4364. function addChatMessage(text) {
  4365. const newMessageHTML = `
  4366. <div class="linewrap svelte-1vrlsr3">
  4367. <span class="time svelte-1vrlsr3">00.00</span>
  4368. <span class="textuimod content svelte-1vrlsr3">
  4369. <span class="capitalize channel svelte-1vrlsr3">UIMod</span>
  4370. </span>
  4371. <span class="svelte-1vrlsr3">${text}</span>
  4372. </div>
  4373. `;
  4374. const element = (0, _misc.makeElement)({
  4375. element: 'article',
  4376. class: 'line svelte-1vrlsr3',
  4377. content: newMessageHTML
  4378. });
  4379. const $chat = document.querySelector('#chat');
  4380. $chat.appendChild(element); // Scroll to bottom of chat
  4381.  
  4382. $chat.scrollTop = $chat.scrollHeight;
  4383. }
  4384.  
  4385. },{"./misc":50,"./state":52}],49:[function(require,module,exports){
  4386. "use strict";
  4387.  
  4388. Object.defineProperty(exports, "__esModule", {
  4389. value: true
  4390. });
  4391. exports.getTooltipContent = getTooltipContent;
  4392. exports.getWindow = getWindow;
  4393.  
  4394. var _state = require("./state");
  4395.  
  4396. // Gets the node of a tooltip for any element, emulates shift keypress to get tooltip with quality details
  4397. // Must be `await`'d to use, e.g. `await getTooltipContent($element)`
  4398. // Optionally pass `getDetailedTooltips` as `true` if you want detailed tooltips by holding shift
  4399. // ^ is laggier, do not use when looking at more than one item
  4400. async function getTooltipContent($elementToHoverOver, getDetailedTooltips) {
  4401. const tempState = (0, _state.getTempState)(); // Emulate holding down shift when getting tooltip
  4402. // Don't need to emulate if user is already holding it down
  4403.  
  4404. if (getDetailedTooltips && !tempState.keyModifiers.shift) {
  4405. // Set this so the keymodifiers mod knows our shift press shouldn't be tracked in tempState
  4406. tempState.gettingTooltipContentShiftPress = true;
  4407. document.body.dispatchEvent(new KeyboardEvent('keydown', {
  4408. bubbles: true,
  4409. cancelable: true,
  4410. key: 'Shift'
  4411. }));
  4412. }
  4413.  
  4414. $elementToHoverOver.dispatchEvent(new Event('pointerenter'));
  4415. const closeTooltipPromise = new Promise(resolve => setTimeout(() => {
  4416. const resolveWithTooltip = () => {
  4417. // If there is no slotdescription at this point, the item element passed very likely has no tooltip
  4418. const $tooltip = document.querySelector('.slotdescription');
  4419.  
  4420. if (!$tooltip || !$tooltip.cloneNode) {
  4421. resolve(false);
  4422. } else {
  4423. resolve($tooltip.cloneNode(true));
  4424. }
  4425.  
  4426. if (tempState.gettingTooltipContentShiftPress) {
  4427. // Release our emulated shift press
  4428. document.body.dispatchEvent(new KeyboardEvent('keyup', {
  4429. bubbles: true,
  4430. cancelable: true,
  4431. key: 'Shift'
  4432. }));
  4433. tempState.gettingTooltipContentShiftPress = false;
  4434. }
  4435.  
  4436. $elementToHoverOver.dispatchEvent(new Event('pointerleave'));
  4437. }; // Very occasionally the 0ms wait time on our timeout doesn't show the tooltip,
  4438. // so we set a second timeout to account for this. Not the most perfect user experience,
  4439. // but it rarely hapens, and it's better than getting an error.
  4440.  
  4441.  
  4442. if (getDetailedTooltips && !document.querySelector('.slotdescription')) {
  4443. setTimeout(resolveWithTooltip, 1);
  4444. } else {
  4445. resolveWithTooltip();
  4446. }
  4447. }, 0));
  4448. const $tooltip = await closeTooltipPromise;
  4449. return $tooltip;
  4450. } // Use this to get a specific window, rather than using the svelte class, which is not preferable
  4451. // Only returns window if it is visible. Some windows are kept in DOM at all times, but are not visible until opened, e.g. Inventory.
  4452. // To get window even if it isn't visible (but is still in DOM), pass `true` to second argument
  4453.  
  4454.  
  4455. function getWindow(windowTitle, getInvisibleWindow) {
  4456. const $specificWindowTitle = Array.from(document.querySelectorAll('.window [name="title"]')).find($windowTitle => $windowTitle.textContent.toLowerCase() === windowTitle.toLowerCase());
  4457. const $window = $specificWindowTitle ? $specificWindowTitle.parentNode.parentNode.parentNode : $specificWindowTitle; // If window is invisible, don't return it unless we are overriding with `getInvisibleWindow`
  4458.  
  4459. if (!$window || !$window.offsetParent && !getInvisibleWindow) {
  4460. return;
  4461. } else {
  4462. return $specificWindowTitle ? $specificWindowTitle.parentNode.parentNode.parentNode : $specificWindowTitle;
  4463. }
  4464. }
  4465.  
  4466. },{"./state":52}],50:[function(require,module,exports){
  4467. "use strict";
  4468.  
  4469. Object.defineProperty(exports, "__esModule", {
  4470. value: true
  4471. });
  4472. exports.makeElement = makeElement;
  4473. exports.debounce = debounce;
  4474. exports.uuid = uuid;
  4475.  
  4476. // Nicer impl to create elements in one method call
  4477. function makeElement(args) {
  4478. const $node = document.createElement(args.element);
  4479. if (args.class) $node.className = args.class;
  4480. if (args.content) $node.innerHTML = args.content;
  4481. if (args.src) $node.src = args.src;
  4482. if (args.type) $node.type = args.type;
  4483. if (args.placeholder) $node.placeholder = args.placeholder;
  4484. return $node;
  4485. } // Credit: David Walsh
  4486.  
  4487.  
  4488. function debounce(func, wait, immediate) {
  4489. var timeout;
  4490. return function () {
  4491. var context = this,
  4492. args = arguments;
  4493.  
  4494. var later = function () {
  4495. timeout = null;
  4496. if (!immediate) func.apply(context, args);
  4497. };
  4498.  
  4499. var callNow = immediate && !timeout;
  4500. clearTimeout(timeout);
  4501. timeout = setTimeout(later, wait);
  4502. if (callNow) func.apply(context, args);
  4503. };
  4504. } // Credit: https://gist.github.com/jcxplorer/823878
  4505. // Generate random UUID string
  4506.  
  4507.  
  4508. function uuid() {
  4509. var uuid = '',
  4510. i,
  4511. random;
  4512.  
  4513. for (i = 0; i < 32; i++) {
  4514. random = Math.random() * 16 | 0;
  4515.  
  4516. if (i == 8 || i == 12 || i == 16 || i == 20) {
  4517. uuid += '-';
  4518. }
  4519.  
  4520. uuid += (i == 12 ? 4 : i == 16 ? random & 3 | 8 : random).toString(16);
  4521. }
  4522.  
  4523. return uuid;
  4524. }
  4525.  
  4526. },{}],51:[function(require,module,exports){
  4527. "use strict";
  4528.  
  4529. Object.defineProperty(exports, "__esModule", {
  4530. value: true
  4531. });
  4532. exports.friendPlayer = friendPlayer;
  4533. exports.unfriendPlayer = unfriendPlayer;
  4534. exports.blockPlayer = blockPlayer;
  4535. exports.unblockPlayer = unblockPlayer;
  4536.  
  4537. var _state = require("./state");
  4538.  
  4539. var chat = _interopRequireWildcard(require("./chat"));
  4540.  
  4541. var ui = _interopRequireWildcard(require("./ui"));
  4542.  
  4543. var _friendsList = require("../mods/friendsList");
  4544.  
  4545. var _blockList = require("../mods/blockList");
  4546.  
  4547. function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
  4548.  
  4549. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
  4550.  
  4551. function friendPlayer(playerName) {
  4552. const state = (0, _state.getState)();
  4553.  
  4554. if (state.friendsList[playerName]) {
  4555. return;
  4556. }
  4557.  
  4558. state.friendsList[playerName] = true;
  4559. chat.addChatMessage(`${playerName} has been added to your friends list.`);
  4560. (0, _state.saveState)(); // If UI is open remake it with new changes
  4561.  
  4562. if (ui.isWindowOpen(ui.WindowNames.friendsList)) {
  4563. (0, _friendsList.removeFriendsList)();
  4564. (0, _friendsList.createFriendsList)();
  4565. }
  4566. }
  4567.  
  4568. function unfriendPlayer(playerName) {
  4569. const state = (0, _state.getState)();
  4570.  
  4571. if (!state.friendsList[playerName]) {
  4572. return;
  4573. }
  4574.  
  4575. delete state.friendsList[playerName];
  4576. delete state.friendNotes[playerName];
  4577. chat.addChatMessage(`${playerName} is no longer on your friends list.`);
  4578. (0, _state.saveState)(); // If UI is open remake it with new changes
  4579.  
  4580. if (ui.isWindowOpen(ui.WindowNames.friendsList)) {
  4581. (0, _friendsList.removeFriendsList)();
  4582. (0, _friendsList.createFriendsList)();
  4583. }
  4584. } // Adds player to block list, to be filtered out of chat
  4585.  
  4586.  
  4587. function blockPlayer(playerName) {
  4588. const state = (0, _state.getState)();
  4589.  
  4590. if (state.blockList[playerName]) {
  4591. return;
  4592. }
  4593.  
  4594. state.blockList[playerName] = true;
  4595. chat.filterAllChat();
  4596. chat.addChatMessage(`${playerName} has been blocked.`);
  4597. (0, _state.saveState)(); // If UI is open remake it with new changes
  4598.  
  4599. if (ui.isWindowOpen(ui.WindowNames.blockList)) {
  4600. (0, _blockList.removeBlockList)();
  4601. (0, _blockList.createBlockList)();
  4602. }
  4603. } // Removes player from block list and makes their messages visible again
  4604.  
  4605.  
  4606. function unblockPlayer(playerName) {
  4607. const state = (0, _state.getState)();
  4608. delete state.blockList[playerName];
  4609. chat.addChatMessage(`${playerName} has been unblocked.`);
  4610. (0, _state.saveState)(); // Make messages visible again
  4611.  
  4612. const $chatNames = Array.from(document.querySelectorAll(`.js-line-blocked[data-chat-name="${playerName}"]`));
  4613. $chatNames.forEach($name => {
  4614. $name.classList.remove('js-line-blocked');
  4615. const $line = $name.parentNode.parentNode.parentNode;
  4616. $line.classList.remove('js-line-blocked');
  4617. });
  4618. }
  4619.  
  4620. },{"../mods/blockList":8,"../mods/friendsList":24,"./chat":48,"./state":52,"./ui":53}],52:[function(require,module,exports){
  4621. "use strict";
  4622.  
  4623. Object.defineProperty(exports, "__esModule", {
  4624. value: true
  4625. });
  4626. exports.getState = getState;
  4627. exports.getTempState = getTempState;
  4628. exports.saveState = saveState;
  4629. exports.loadState = loadState;
  4630. exports.testSaveState = testSaveState;
  4631.  
  4632. var _version = require("./version");
  4633.  
  4634. const STORAGE_STATE_KEY = 'hordesio-uimodsakaiyo-state';
  4635. let state = {
  4636. breakingVersion: _version.BREAKING_VERSION,
  4637. windowsPos: {},
  4638. blockList: {},
  4639. friendsList: {},
  4640. mapOpacity: 70,
  4641. // e.g. 70 = opacity: 0.7
  4642. friendNotes: {},
  4643. chatTabs: [],
  4644. xpMeterState: {
  4645. currentXp: 0,
  4646. xpGains: [],
  4647. // array of xp deltas every second
  4648. averageXp: 0,
  4649. gainedXp: 0,
  4650. currentLvl: 0
  4651. },
  4652. openWindows: {
  4653. friendsList: false,
  4654. blockList: false,
  4655. xpMeter: false,
  4656. merchant: false,
  4657. modToggler: false,
  4658. uiModOptions: false
  4659. },
  4660. clanLastActiveMembers: {},
  4661. lockedItemSlots: [],
  4662. disabledMods: [],
  4663. enableWindowDragging: true,
  4664. enableFrameDragging: true,
  4665. healthBarFadeColor: 'orange',
  4666. // 'orange' or 'red'
  4667. healthBarFadePercentage: 100,
  4668. // 100 or 50
  4669. mapZoomScaleFactor: 1.0
  4670. }; // tempState is saved only between page refreshes.
  4671.  
  4672. const tempState = {
  4673. // The last name clicked in chat
  4674. chatName: null,
  4675. lastMapWidth: 0,
  4676. lastMapHeight: 0,
  4677. xpMeterInterval: null,
  4678. // tracks the interval for fetching xp data
  4679. keyModifiers: {
  4680. shift: false,
  4681. control: false,
  4682. alt: false
  4683. },
  4684. // set by _keyModifiers mod
  4685. cooldownNums: {},
  4686. cooldownObservers: {}
  4687. };
  4688.  
  4689. function getState() {
  4690. return state;
  4691. }
  4692.  
  4693. function getTempState() {
  4694. return tempState;
  4695. }
  4696.  
  4697. function saveState() {// localStorage.setItem(STORAGE_STATE_KEY, JSON.stringify(state));
  4698. }
  4699.  
  4700. function testSaveState() {
  4701. localStorage.setItem(STORAGE_STATE_KEY, JSON.stringify(state));
  4702. }
  4703.  
  4704. function loadState() {
  4705. const storedStateJson = localStorage.getItem(STORAGE_STATE_KEY);
  4706.  
  4707. if (storedStateJson) {
  4708. const storedState = JSON.parse(storedStateJson);
  4709.  
  4710. if (storedState.breakingVersion !== _version.BREAKING_VERSION) {
  4711. localStorage.setItem(STORAGE_STATE_KEY, JSON.stringify(state));
  4712. return;
  4713. }
  4714.  
  4715. for (let [key, value] of Object.entries(storedState)) {
  4716. state[key] = value;
  4717. }
  4718. }
  4719. }
  4720.  
  4721. },{"./version":54}],53:[function(require,module,exports){
  4722. "use strict";
  4723.  
  4724. Object.defineProperty(exports, "__esModule", {
  4725. value: true
  4726. });
  4727. exports.resetUiPositions = resetUiPositions;
  4728. exports.setWindowOpen = setWindowOpen;
  4729. exports.setWindowClosed = setWindowClosed;
  4730. exports.isWindowOpen = isWindowOpen;
  4731. exports.createNavButton = createNavButton;
  4732. exports.WindowNames = void 0;
  4733.  
  4734. var _state = require("./state");
  4735.  
  4736. var _misc = require("./misc");
  4737.  
  4738. var chat = _interopRequireWildcard(require("./chat"));
  4739.  
  4740. function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
  4741.  
  4742. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
  4743.  
  4744. const WindowNames = {
  4745. merchant: 'merchant',
  4746. clan: 'clan',
  4747. stash: 'stash',
  4748. inventory: 'inventory'
  4749. };
  4750. exports.WindowNames = WindowNames;
  4751.  
  4752. function resetUiPositions() {
  4753. const state = (0, _state.getState)();
  4754. state.windowsPos = {};
  4755. (0, _state.saveState)();
  4756. chat.addChatMessage('Please refresh the page for the reset frame & window positions to take effect.');
  4757. }
  4758.  
  4759. function createNavButton(shortname, icon, tooltip, callback) {
  4760. const iconClass = 'js-' + shortname + '-icon';
  4761. const tooltipClass = 'js-' + shortname + '-tooltip'; // Create the icon
  4762.  
  4763. const $newIcon = (0, _misc.makeElement)({
  4764. element: 'div',
  4765. class: 'btn border black ' + iconClass,
  4766. content: icon
  4767. }); // Add the icon to the right of Elixir icon
  4768.  
  4769. const $elixirIcon = document.querySelector('#sysgem');
  4770. $elixirIcon.parentNode.insertBefore($newIcon, $elixirIcon.nextSibling); // Add tooltip onhover
  4771.  
  4772. $newIcon.addEventListener('mouseenter', () => {
  4773. const $newTooltip = (0, _misc.makeElement)({
  4774. element: 'div',
  4775. class: 'btn border grey ' + tooltipClass,
  4776. content: tooltip
  4777. }); // Add the tooltip to the left of Elixir icon
  4778.  
  4779. $elixirIcon.parentNode.insertBefore($newTooltip, $elixirIcon);
  4780. }); // Remove tooltip after hover
  4781.  
  4782. $newIcon.addEventListener('mouseleave', () => {
  4783. const $newTooltip = document.querySelector('.' + tooltipClass);
  4784. $newTooltip.parentNode.removeChild($newTooltip);
  4785. }); // Call the appropriate function when clicked
  4786.  
  4787. document.querySelector('.' + iconClass).addEventListener('click', callback);
  4788. } // state.openWindows should always only be managed by this file
  4789. // Sometimes we want to track when a UI window we don't control is opened/closed
  4790. // We use these methods to help facilitate that
  4791. // To use these methods correctly, you need to track when the window opens _and_ when it closes
  4792. // If you don't _need_ to do both those things, then don't do that, and don't use these methods
  4793.  
  4794.  
  4795. function setWindowOpen(windowName) {
  4796. const state = (0, _state.getState)();
  4797. state.openWindows[windowName] = true;
  4798. (0, _state.saveState)();
  4799. }
  4800.  
  4801. function setWindowClosed(windowName) {
  4802. const state = (0, _state.getState)();
  4803. state.openWindows[windowName] = false;
  4804. (0, _state.saveState)();
  4805. }
  4806.  
  4807. function isWindowOpen(windowName) {
  4808. const state = (0, _state.getState)();
  4809. return state.openWindows[windowName];
  4810. }
  4811.  
  4812. },{"./chat":48,"./misc":50,"./state":52}],54:[function(require,module,exports){
  4813. "use strict";
  4814.  
  4815. Object.defineProperty(exports, "__esModule", {
  4816. value: true
  4817. });
  4818. exports.VERSION = exports.BREAKING_VERSION = void 0;
  4819. // If this version is different from the user's stored state,
  4820. // e.g. they have upgraded the version of this script and there are breaking changes,
  4821. // then their stored state will be deleted.
  4822. const BREAKING_VERSION = 1; // Used for initialization message in chat, and userscript version
  4823.  
  4824. exports.BREAKING_VERSION = BREAKING_VERSION;
  4825. const VERSION = '1.5.1';
  4826. exports.VERSION = VERSION;
  4827.  
  4828. },{}]},{},[1]);