Hordes UI Mod

Various UI mods for Hordes.io.

当前为 2020-01-05 提交的版本,查看 最新版本

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