Hordes UI Mod

Various UI mods for Hordes.io.

目前为 2020-02-28 提交的版本。查看 最新版本

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