Hordes UI Mod

Various UI mods for Hordes.io.

当前为 2020-03-04 提交的版本,查看 最新版本

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