[Updated] UI Mods Hordes.io - Merchant Filter

Various UI mods for Hordes.io.

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