Hordes UI Mod & Party Selector

Various UI mods for Hordes.io. & Party Selector

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