Greasy Fork 还支持 简体中文。

Hordes UI Mod

Various UI mods for Hordes.io.

目前為 2020-01-04 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name Hordes UI Mod
  3. // @version 1.2.1
  4. // @description Various UI mods for Hordes.io.
  5. // @author Sakaiyo & Chandog#6373 & Cullen
  6. // @match https://hordes.io/play
  7. // @grant GM_addStyle
  8. // @namespace https://greasyfork.org/users/160017
  9. // ==/UserScript==
  10.  
  11. GM_addStyle(`/* 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')).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":15}],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":33}],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":29,"../../utils/state":33,"../../utils/version":35}],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":33}],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 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":29,"../../utils/misc":31,"../../utils/player":32,"../../utils/state":33,"./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":29,"../../utils/misc":31,"../../utils/state":33}],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":29,"../../utils/misc":31,"../../utils/state":33}],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":31,"../../utils/state":33,"./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-table)');
  1106. if (!$clanMemberTable) return; // Initialize the table column if we haven't already
  1107.  
  1108. if (!$clanWindow.classList.contains('js-clan-members-table-initd')) {
  1109. $clanWindow.classList.add('js-clan-members-table-initd');
  1110. $clanMemberTable.classList.add('uimod-clan-members-table'); // We add a new table next to the preexisting table.
  1111. // We don't just add a new column because Svelte changes the columns and rows around
  1112. // a lot, pretty randomly. This leads to our right-most column occasionally bugging out
  1113. // and ending up as the left-most column.
  1114. // Using our own table lets us control everything about it without Svelte interfering.
  1115.  
  1116. $clanMemberTable.parentNode.appendChild((0, _misc.makeElement)({
  1117. element: 'table',
  1118. class: 'marg-top panel-black js-clan-lastseen-table uimod-clan-lastseen-table',
  1119. content: `
  1120. <thead>
  1121. <tr class="textprimary">
  1122. <th>Last seen</th>
  1123. </tr>
  1124. </thead>
  1125. <tbody>
  1126. <tr class="striped js-clan-lastseen-row">
  1127. <td></td>
  1128. </tr>
  1129. </tbody>
  1130. `
  1131. })); // Reset last active members state if clan has changed
  1132.  
  1133. const clanName = $clanWindow.querySelector('.textcenter h1').textContent;
  1134.  
  1135. if (clanName !== state.currentClanName) {
  1136. state.currentClanName = clanName.trim();
  1137. state.clanLastActiveMembers = {};
  1138. (0, _state.saveState)();
  1139. }
  1140. }
  1141.  
  1142. if (!tempState.clanTableObserver) {
  1143. _handleClanMemberTableChange();
  1144.  
  1145. tempState.clanTableObserver = new MutationObserver(_handleClanMemberTableChange);
  1146. tempState.clanTableObserver.observe($clanMemberTable, {
  1147. attributes: true,
  1148. childList: true,
  1149. subtree: true
  1150. });
  1151. }
  1152. }
  1153.  
  1154. },{"../../utils/misc":31,"../../utils/state":33}],10:[function(require,module,exports){
  1155. "use strict";
  1156.  
  1157. Object.defineProperty(exports, "__esModule", {
  1158. value: true
  1159. });
  1160. exports.default = void 0;
  1161.  
  1162. var _ui = require("../../utils/ui");
  1163.  
  1164. var _state = require("../../utils/state");
  1165.  
  1166. var _helpers = require("./helpers");
  1167.  
  1168. // When clan window is open, initialize the mutation observer to add Last seen and track last seen in state
  1169. function clanActivityTracker() {
  1170. const tempState = (0, _state.getTempState)();
  1171. 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
  1172.  
  1173. if (!$clanWindow) {
  1174. if ((0, _ui.isWindowOpen)(_ui.WindowNames.clan)) {
  1175. if (tempState.clanWindowObserver) {
  1176. tempState.clanWindowObserver.disconnect();
  1177. delete tempState.clanWindowObserver;
  1178. }
  1179.  
  1180. if (tempState.clanTableObserver) {
  1181. tempState.clanTableObserver.disconnect();
  1182. delete tempState.clanTableObserver;
  1183. }
  1184.  
  1185. (0, _ui.setWindowClosed)(_ui.WindowNames.clan);
  1186. }
  1187. } else if (!tempState.clanWindowObserver) {
  1188. (0, _ui.setWindowOpen)(_ui.WindowNames.clan);
  1189. (0, _helpers.handleClanWindowChange)();
  1190. tempState.clanWindowObserver = new MutationObserver(_helpers.handleClanWindowChange);
  1191. tempState.clanWindowObserver.observe($clanWindow, {
  1192. attributes: true,
  1193. childList: true
  1194. });
  1195. }
  1196. } // Update last seen for clan members when they type in chat
  1197.  
  1198.  
  1199. function refreshLastSeenClanMember(mutations) {
  1200. const state = (0, _state.getState)();
  1201. let updatedState = false;
  1202. const $newChatLines = mutations.map(mutation => Array.from(mutation.addedNodes)).flat();
  1203. $newChatLines.forEach($chatLine => {
  1204. const $name = $chatLine.querySelector('.name');
  1205. if (!$name) return;
  1206. const name = $name.textContent.trim(); // If not clan member, don't update state
  1207.  
  1208. if (!state.clanLastActiveMembers.hasOwnProperty(name)) return;
  1209. updatedState = true;
  1210. state.clanLastActiveMembers[name] = Date.now();
  1211. });
  1212. if (updatedState) (0, _state.saveState)();
  1213. }
  1214.  
  1215. var _default = {
  1216. name: 'Clan activity tracker',
  1217. description: 'Updates clan member table with a Last seen column',
  1218. run: ({
  1219. registerOnDomChange,
  1220. registerOnChatChange
  1221. }) => {
  1222. clanActivityTracker(); // Run it initially once in case clan is already open on mod load
  1223.  
  1224. registerOnDomChange(clanActivityTracker); // Run it on dom change for whenever the clan window is opened/closed
  1225.  
  1226. registerOnChatChange(refreshLastSeenClanMember); // Run it on chat change so whenever a clan member chats, their last seen is updated
  1227. }
  1228. };
  1229. exports.default = _default;
  1230.  
  1231. },{"../../utils/state":33,"../../utils/ui":34,"./helpers":9}],11:[function(require,module,exports){
  1232. "use strict";
  1233.  
  1234. Object.defineProperty(exports, "__esModule", {
  1235. value: true
  1236. });
  1237. exports.default = void 0;
  1238.  
  1239. var _misc = require("../../utils/misc");
  1240.  
  1241. var _ui = require("../../utils/ui");
  1242.  
  1243. function customSettings() {
  1244. const $settings = document.querySelector('.divide:not(.js-settings-initd)');
  1245.  
  1246. if (!$settings) {
  1247. return;
  1248. }
  1249.  
  1250. $settings.classList.add('js-settings-initd');
  1251. const $settingsChoiceList = $settings.querySelector('.choice').parentNode;
  1252. $settingsChoiceList.appendChild((0, _misc.makeElement)({
  1253. element: 'div',
  1254. class: 'choice js-blocked-players',
  1255. content: 'Blocked players'
  1256. }));
  1257. $settingsChoiceList.appendChild((0, _misc.makeElement)({
  1258. element: 'div',
  1259. class: 'choice js-reset-ui-pos',
  1260. content: 'Reset UI Positions'
  1261. })); // Upon click, we display our custom settings window UI
  1262.  
  1263. document.querySelector('.js-blocked-players').addEventListener('click', _ui.createBlockList); // Reset positions immediately upon click
  1264.  
  1265. document.querySelector('.js-reset-ui-pos').addEventListener('click', _ui.resetUiPositions); // If it was open when the game last closed keep it open
  1266.  
  1267. if ((0, _ui.isWindowOpen)(_ui.WindowNames.blockList)) {
  1268. (0, _ui.createBlockList)();
  1269. }
  1270. }
  1271.  
  1272. var _default = {
  1273. name: 'Custom settings',
  1274. description: 'Allows you to view and remove blocked players from the Settings window. Also adds Reset UI Position to settings',
  1275. run: ({
  1276. registerOnDomChange
  1277. }) => {
  1278. customSettings(); // If the settings window becomes visible/invisible, we want to update it
  1279.  
  1280. registerOnDomChange(customSettings);
  1281. }
  1282. };
  1283. exports.default = _default;
  1284.  
  1285. },{"../../utils/misc":31,"../../utils/ui":34}],12:[function(require,module,exports){
  1286. "use strict";
  1287.  
  1288. Object.defineProperty(exports, "__esModule", {
  1289. value: true
  1290. });
  1291. exports.dragElement = dragElement;
  1292.  
  1293. // Influenced by: https://gist.github.com/remarkablemark/5002d27442600510d454a5aeba370579 & https://stackoverflow.com/a/45831670
  1294. // $draggedElement is the item that will be dragged.
  1295. // $dragTrigger is optional, if passed, this element that must be held down to drag $draggedElement
  1296. // If $dragTrigger is not passed, clicking anywhere on $draggedElement will drag it
  1297. function dragElement($draggedElement, $dragTrigger) {
  1298. let offset = [0, 0];
  1299. let mouseDownPos = [0, 0];
  1300. let elementPos = [0, 0];
  1301. let isDown = false;
  1302. const $trigger = $dragTrigger || $draggedElement;
  1303. $trigger.addEventListener('mousedown', e => {
  1304. isDown = true; // Offset is used when there is a separate $dragTrigger
  1305.  
  1306. offset = [$draggedElement.offsetLeft - e.clientX, $draggedElement.offsetTop - e.clientY]; // mouseDownPos and elementPos are used when $draggedElement is also the trigger
  1307.  
  1308. mouseDownPos = [e.clientX, e.clientY];
  1309. elementPos = [parseInt($draggedElement.style.left) || 0, parseInt($draggedElement.style.top) || 0];
  1310. }, true);
  1311. document.addEventListener('mouseup', () => {
  1312. isDown = false;
  1313. }, true);
  1314. document.addEventListener('mousemove', e => {
  1315. e.preventDefault();
  1316.  
  1317. if (isDown) {
  1318. const deltaX = $dragTrigger ? e.clientX + offset[0] : elementPos[0] + e.clientX - mouseDownPos[0];
  1319. const deltaY = $dragTrigger ? e.clientY + offset[1] : elementPos[1] + e.clientY - mouseDownPos[1];
  1320. $draggedElement.style.left = `${deltaX}px`;
  1321. $draggedElement.style.top = `${deltaY}px`;
  1322. }
  1323. }, true);
  1324. }
  1325.  
  1326. },{}],13:[function(require,module,exports){
  1327. "use strict";
  1328.  
  1329. Object.defineProperty(exports, "__esModule", {
  1330. value: true
  1331. });
  1332. exports.default = void 0;
  1333.  
  1334. var helpers = _interopRequireWildcard(require("./helpers"));
  1335.  
  1336. var _state = require("../../utils/state");
  1337.  
  1338. function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
  1339.  
  1340. 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; }
  1341.  
  1342. // Drag all windows by their header
  1343. function draggableUIWindows() {
  1344. Array.from(document.querySelectorAll('.window:not(.js-can-move)')).forEach($window => {
  1345. $window.classList.add('js-can-move');
  1346. helpers.dragElement($window, $window.querySelector('.titleframe'));
  1347. });
  1348. Array.from(document.querySelectorAll(`
  1349. .partyframes:not(.js-can-move),
  1350. #ufplayer:not(.js-can-move),
  1351. #uftarget:not(.js-can-move),
  1352. #skillbar:not(.js-can-move)
  1353. `)).forEach($frame => {
  1354. $frame.classList.add('js-can-move');
  1355. helpers.dragElement($frame);
  1356. });
  1357. } // Save dragged UI windows position to state
  1358.  
  1359.  
  1360. function saveDraggedUIWindows() {
  1361. const state = (0, _state.getState)();
  1362. Array.from(document.querySelectorAll('.window:not(.js-ui-is-saving)')).forEach($window => {
  1363. $window.classList.add('js-ui-is-saving');
  1364. const $draggableTarget = $window.querySelector('.titleframe');
  1365. const windowName = $draggableTarget.querySelector('[name="title"]').textContent;
  1366. $draggableTarget.addEventListener('mouseup', () => {
  1367. state.windowsPos[windowName] = $window.getAttribute('style');
  1368. (0, _state.saveState)();
  1369. });
  1370. });
  1371.  
  1372. const saveFramePos = ($element, name) => {
  1373. if (!$element) return;
  1374. $element.classList.add('js-ui-is-saving');
  1375. $element.addEventListener('mouseup', () => {
  1376. state.windowsPos[name] = $element.getAttribute('style');
  1377. });
  1378. };
  1379.  
  1380. saveFramePos(document.querySelector('.partyframes:not(.js-ui-is-saving)'), 'partyFrame');
  1381. saveFramePos(document.querySelector('#ufplayer:not(.js-ui-is-saving)'), 'playerFrame');
  1382. saveFramePos(document.querySelector('#uftarget:not(.js-ui-is-saving)'), 'targetFrame');
  1383. } // Loads draggable UI windows position from state
  1384.  
  1385.  
  1386. function loadDraggedUIWindowsPositions() {
  1387. const state = (0, _state.getState)();
  1388. Array.from(document.querySelectorAll('.window:not(.js-has-loaded-pos)')).forEach($window => {
  1389. $window.classList.add('js-has-loaded-pos');
  1390. const windowName = $window.querySelector('[name="title"]').textContent;
  1391. const pos = state.windowsPos[windowName];
  1392.  
  1393. if (pos) {
  1394. $window.setAttribute('style', pos);
  1395. }
  1396. });
  1397.  
  1398. const loadFramePos = ($element, name) => {
  1399. if (!$element) return;
  1400. $element.classList.add('js-has-loaded-pos');
  1401. const pos = state.windowsPos[name];
  1402.  
  1403. if (pos) {
  1404. $element.setAttribute('style', pos);
  1405. }
  1406. };
  1407.  
  1408. loadFramePos(document.querySelector('.partyframes:not(.js-has-loaded-pos)'), 'partyFrame');
  1409. loadFramePos(document.querySelector('#ufplayer:not(.js-has-loaded-pos)'), 'playerFrame');
  1410. loadFramePos(document.querySelector('#uftarget:not(.js-has-loaded-pos)'), 'targetFrame');
  1411. }
  1412.  
  1413. var _default = {
  1414. name: 'Draggable Windows',
  1415. description: 'Allows you to drag windows in the UI',
  1416. run: ({
  1417. registerOnDomChange
  1418. }) => {
  1419. draggableUIWindows();
  1420. saveDraggedUIWindows();
  1421. loadDraggedUIWindowsPositions(); // As windows open, we want to make them draggable
  1422.  
  1423. registerOnDomChange(saveDraggedUIWindows);
  1424. registerOnDomChange(draggableUIWindows);
  1425. registerOnDomChange(loadDraggedUIWindowsPositions);
  1426. }
  1427. };
  1428. exports.default = _default;
  1429.  
  1430. },{"../../utils/state":33,"./helpers":12}],14:[function(require,module,exports){
  1431. "use strict";
  1432.  
  1433. Object.defineProperty(exports, "__esModule", {
  1434. value: true
  1435. });
  1436. exports.default = void 0;
  1437.  
  1438. var _misc = require("../../utils/misc");
  1439.  
  1440. var _ui = require("../../utils/ui");
  1441.  
  1442. // The F icon and the UI that appears when you click it
  1443. function customFriendsList() {
  1444. var friendsIconElement = (0, _misc.makeElement)({
  1445. element: 'div',
  1446. class: 'btn border black js-friends-list-icon',
  1447. content: 'F'
  1448. }); // Add the icon to the right of Elixir icon
  1449.  
  1450. const $elixirIcon = document.querySelector('#sysgem');
  1451. $elixirIcon.parentNode.insertBefore(friendsIconElement, $elixirIcon.nextSibling); // Create the friends list UI
  1452.  
  1453. document.querySelector('.js-friends-list-icon').addEventListener('click', _ui.toggleFriendsList); // If it was open when the game last closed keep it open
  1454.  
  1455. if ((0, _ui.isWindowOpen)(_ui.WindowNames.friendsList)) {
  1456. (0, _ui.createFriendsList)();
  1457. }
  1458. }
  1459.  
  1460. var _default = {
  1461. name: 'Friends list',
  1462. description: 'Allows access to your friends list from the top right F icon',
  1463. run: customFriendsList
  1464. };
  1465. exports.default = _default;
  1466.  
  1467. },{"../../utils/misc":31,"../../utils/ui":34}],15:[function(require,module,exports){
  1468. "use strict";
  1469.  
  1470. Object.defineProperty(exports, "__esModule", {
  1471. value: true
  1472. });
  1473. exports.default = void 0;
  1474.  
  1475. var _modStart = _interopRequireDefault(require("./_modStart"));
  1476.  
  1477. var _customSettings = _interopRequireDefault(require("./customSettings"));
  1478.  
  1479. var _chatContextMenu = _interopRequireDefault(require("./chatContextMenu"));
  1480.  
  1481. var _chatFilters = _interopRequireDefault(require("./chatFilters"));
  1482.  
  1483. var _chatTabs = _interopRequireDefault(require("./chatTabs"));
  1484.  
  1485. var _draggableUI = _interopRequireDefault(require("./draggableUI"));
  1486.  
  1487. var _friendsList = _interopRequireDefault(require("./friendsList"));
  1488.  
  1489. var _mapControls = _interopRequireDefault(require("./mapControls"));
  1490.  
  1491. var _resizableChat = _interopRequireDefault(require("./resizableChat"));
  1492.  
  1493. var _resizableMap = _interopRequireDefault(require("./resizableMap"));
  1494.  
  1495. var _selectedWindowIsTop = _interopRequireDefault(require("./selectedWindowIsTop"));
  1496.  
  1497. var _xpMeter = _interopRequireDefault(require("./xpMeter"));
  1498.  
  1499. var _merchantFilter = _interopRequireDefault(require("./merchantFilter"));
  1500.  
  1501. var _itemStatsCopy = _interopRequireDefault(require("./itemStatsCopy"));
  1502.  
  1503. var _keyPressTracker = _interopRequireDefault(require("./_keyPressTracker"));
  1504.  
  1505. var _clanActivityTracker = _interopRequireDefault(require("./clanActivityTracker"));
  1506.  
  1507. var _skillCooldownNumbers = _interopRequireDefault(require("./skillCooldownNumbers"));
  1508.  
  1509. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1510.  
  1511. // The array here dictates the order of which mods are executed, from top to bottom
  1512. var _default = [_modStart.default, _keyPressTracker.default, _resizableMap.default, _mapControls.default, _friendsList.default, _customSettings.default, _resizableChat.default, _chatFilters.default, _chatContextMenu.default, _chatTabs.default, _draggableUI.default, _selectedWindowIsTop.default, _xpMeter.default, _merchantFilter.default, _itemStatsCopy.default, _clanActivityTracker.default, _skillCooldownNumbers.default];
  1513. exports.default = _default;
  1514.  
  1515. },{"./_keyPressTracker":2,"./_modStart":3,"./chatContextMenu":5,"./chatFilters":6,"./chatTabs":8,"./clanActivityTracker":10,"./customSettings":11,"./draggableUI":13,"./friendsList":14,"./itemStatsCopy":16,"./mapControls":18,"./merchantFilter":20,"./resizableChat":21,"./resizableMap":23,"./selectedWindowIsTop":24,"./skillCooldownNumbers":26,"./xpMeter":28}],16:[function(require,module,exports){
  1516. "use strict";
  1517.  
  1518. Object.defineProperty(exports, "__esModule", {
  1519. value: true
  1520. });
  1521. exports.default = void 0;
  1522.  
  1523. var chat = _interopRequireWildcard(require("../../utils/chat"));
  1524.  
  1525. var _game = require("../../utils/game");
  1526.  
  1527. var _state = require("../../utils/state");
  1528.  
  1529. function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
  1530.  
  1531. 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; }
  1532.  
  1533. async function itemStatsCopy(clickEvent) {
  1534. const tempState = (0, _state.getTempState)(); // This mod only triggers if you alt+right click
  1535.  
  1536. if (!tempState.keyModifiers.alt) {
  1537. return;
  1538. }
  1539.  
  1540. 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
  1541.  
  1542. const $bagSlot = $elementMouseIsOver.parentNode; // No item in slot
  1543.  
  1544. if (!$bagSlot.querySelector('img')) {
  1545. return;
  1546. } // Once we confirm we want to copy to clipboard, hide context menu
  1547.  
  1548.  
  1549. const $itemContextMenuChoice = document.body.querySelector('.container > .panel > .choice');
  1550.  
  1551. if (!$itemContextMenuChoice) {
  1552. // If context menu isn't open, something is not right - stop what we're doing and exit
  1553. // Seen this happen very rarely when testing
  1554. return;
  1555. }
  1556.  
  1557. const $itemContextMenu = $itemContextMenuChoice.parentNode;
  1558.  
  1559. if ($itemContextMenu) {
  1560. $itemContextMenu.style.display = 'none';
  1561. } // Get the texts we want from the tooltip
  1562.  
  1563.  
  1564. const getDetailedTooltips = true;
  1565. const $tooltip = await (0, _game.getTooltipContent)($bagSlot, getDetailedTooltips);
  1566.  
  1567. if (!$tooltip) {
  1568. // This _shouldn't_ happen, but very occasionally there is a (likely timing-related) problem getting the tooltip
  1569. return;
  1570. } // We get the detailed tooltip, which may have a second comparison tooltip. Remove the comparison tooltip if we have it.
  1571.  
  1572.  
  1573. const $comparisonTooltip = $tooltip.querySelector('.slotdescription');
  1574. if ($comparisonTooltip) $comparisonTooltip.parentNode.removeChild($comparisonTooltip); // Collect item name/stats into strings
  1575.  
  1576. const itemName = $tooltip.querySelector('.slottitle').textContent;
  1577. const $itemQuality = $tooltip.querySelector('.type span');
  1578. const itemQuality = $itemQuality.textContent; // It's not a piece of equipment, just copy item name and exit
  1579.  
  1580. if (!itemQuality.includes('%')) {
  1581. let trimmedItemName = itemName; // If item name starts with T#, e.g. T1, T5, etc, then this was added onto the detailed tooltip
  1582. // It's usually unnecessary information, so we remove it
  1583. // (e.g. shows as "T94 Centrifugal Laceration Lv. 4" instead of "Centrifugal Laceration Lv. 4")
  1584.  
  1585. if (itemName.substr(0, 2).match(/T[0-9]/)) {
  1586. trimmedItemName = itemName.substr(itemName.indexOf(' ') + 1);
  1587. }
  1588.  
  1589. navigator.clipboard.writeText(trimmedItemName);
  1590. chat.addChatMessage(`Copied ${trimmedItemName} to clipboard.`);
  1591. return;
  1592. } // We only want the lvl number, so pop off the level number from the "Requires Lv. 17" line
  1593.  
  1594.  
  1595. const itemLvl = $tooltip.querySelector('.requirements').textContent.split(' ').pop(); // Grab the stats we care about, i.e. not part of the requirements or item type
  1596.  
  1597. const $stats = Array.from($tooltip.querySelectorAll(`
  1598. .container > .textpurp,
  1599. .container > .textblue,
  1600. .container > .textgreen:not(.slottitle):not(.requirements),
  1601. .container > .textwhite:not(.type)
  1602. `));
  1603. const statsText = $stats.map($stat => {
  1604. // Return quality percentage only if it exists, otherwise return normal stat
  1605. const $quality = $stat.querySelector('span');
  1606.  
  1607. if ($quality) {
  1608. const quality = $quality.textContent;
  1609. const statLineChunks = $stat.textContent.replace(/\+\s/g, '+').split(' ');
  1610. statLineChunks.pop(); // Remove quality at end
  1611.  
  1612. statLineChunks.shift(); // Remove specific +# at the beginning
  1613.  
  1614. const statName = statLineChunks.join(' ');
  1615. return `${statName} ${quality}`;
  1616. } else {
  1617. return $stat.textContent.trim();
  1618. }
  1619. }).join(', ');
  1620. navigator.clipboard.writeText(`${itemName} ${itemQuality} Lv.${itemLvl}: ${statsText}`);
  1621. chat.addChatMessage(`Copied ${itemName}'s stats to clipboard.`);
  1622. }
  1623.  
  1624. var _default = {
  1625. name: 'Items stats copy',
  1626. description: 'When ctrl+left clicking a piece of equipment in your inventory, its stats will be copied to your clipboard',
  1627. run: ({
  1628. registerOnRightClick
  1629. }) => {
  1630. registerOnRightClick(itemStatsCopy);
  1631. }
  1632. };
  1633. exports.default = _default;
  1634.  
  1635. },{"../../utils/chat":29,"../../utils/game":30,"../../utils/state":33}],17:[function(require,module,exports){
  1636. "use strict";
  1637.  
  1638. Object.defineProperty(exports, "__esModule", {
  1639. value: true
  1640. });
  1641. exports.updateMapOpacity = updateMapOpacity;
  1642.  
  1643. var _state = require("../../utils/state");
  1644.  
  1645. // On load, update map opacity to match state
  1646. // We modify the opacity of the canvas and the background color alpha of the parent container
  1647. // We do this to allow our opacity buttons to be visible on hover with 100% opacity
  1648. // (A surprisingly difficult enough task to require this implementation)
  1649. function updateMapOpacity() {
  1650. const state = (0, _state.getState)();
  1651. const $map = document.querySelector('.container canvas');
  1652. const $mapContainer = document.querySelector('.js-map');
  1653. $map.style.opacity = String(state.mapOpacity / 100);
  1654. 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
  1655.  
  1656. let opacity = state.mapOpacity / 100; // This is a slightly lazy browser workaround to fix a bug.
  1657. // If the opacity is `1`, and it sets `rgba` to `1`, then the browser changes the
  1658. // rgba to rgb, dropping the alpha. We could account for that and add the `alpha` back in
  1659. // later, but setting the max opacity to very close to 1 makes sure the issue never crops up.
  1660. // Fun fact: 0.99 retains the alpha, but setting this to 0.999 still causes the browser to drop the alpha. Rude.
  1661.  
  1662. if (opacity === 1) {
  1663. opacity = 0.99;
  1664. }
  1665.  
  1666. const newBgColor = mapContainerBgColor.replace(/[\d\.]+\)$/g, `${opacity})`);
  1667. $mapContainer.style['background-color'] = newBgColor; // Update the button opacity
  1668.  
  1669. const $addBtn = document.querySelector('.js-map-opacity-add');
  1670. const $minusBtn = document.querySelector('.js-map-opacity-minus'); // Hide plus button if the opacity is max
  1671.  
  1672. if (state.mapOpacity === 100) {
  1673. $addBtn.style.visibility = 'hidden';
  1674. } else {
  1675. $addBtn.style.visibility = 'visible';
  1676. } // Hide minus button if the opacity is lowest
  1677.  
  1678.  
  1679. if (state.mapOpacity === 0) {
  1680. $minusBtn.style.visibility = 'hidden';
  1681. } else {
  1682. $minusBtn.style.visibility = 'visible';
  1683. }
  1684. }
  1685.  
  1686. },{"../../utils/state":33}],18:[function(require,module,exports){
  1687. "use strict";
  1688.  
  1689. Object.defineProperty(exports, "__esModule", {
  1690. value: true
  1691. });
  1692. exports.default = void 0;
  1693.  
  1694. var _state = require("../../utils/state");
  1695.  
  1696. var helpers = _interopRequireWildcard(require("./helpers"));
  1697.  
  1698. var _misc = require("../../utils/misc");
  1699.  
  1700. function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
  1701.  
  1702. 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; }
  1703.  
  1704. function mapControls() {
  1705. const state = (0, _state.getState)();
  1706. const $map = document.querySelector('.container canvas');
  1707.  
  1708. if (!$map.parentNode.classList.contains('js-map')) {
  1709. $map.parentNode.classList.add('js-map');
  1710. }
  1711.  
  1712. const $mapContainer = document.querySelector('.js-map'); // We only use the `js-map-move` button in the `draggableUI` mod
  1713.  
  1714. const $mapButtons = (0, _misc.makeElement)({
  1715. element: 'div',
  1716. class: 'js-map-btns',
  1717. content: `
  1718. <button class="js-map-opacity-add">+</button>
  1719. <button class="js-map-opacity-minus">-</button>
  1720. <button class="js-map-reset">r</button>
  1721. `
  1722. }); // Add it right before the map container div
  1723.  
  1724. $map.parentNode.insertBefore($mapButtons, $map);
  1725. helpers.updateMapOpacity();
  1726. const $addBtn = document.querySelector('.js-map-opacity-add');
  1727. const $minusBtn = document.querySelector('.js-map-opacity-minus');
  1728. const $resetBtn = document.querySelector('.js-map-reset'); // Hide the buttons if map opacity is maxed/minimum
  1729.  
  1730. if (state.mapOpacity === 100) {
  1731. $addBtn.style.visibility = 'hidden';
  1732. }
  1733.  
  1734. if (state.mapOpacity === 0) {
  1735. $minusBtn.style.visibility = 'hidden';
  1736. } // Wire it up
  1737.  
  1738.  
  1739. $addBtn.addEventListener('click', () => {
  1740. // Update opacity
  1741. state.mapOpacity += 10;
  1742. (0, _state.saveState)();
  1743. helpers.updateMapOpacity();
  1744. });
  1745. $minusBtn.addEventListener('click', () => {
  1746. // Update opacity
  1747. state.mapOpacity -= 10;
  1748. (0, _state.saveState)();
  1749. helpers.updateMapOpacity();
  1750. });
  1751. $resetBtn.addEventListener('click', () => {
  1752. state.mapOpacity = 70;
  1753. state.mapWidth = '174px';
  1754. state.mapHeight = '174px';
  1755. (0, _state.saveState)();
  1756. helpers.updateMapOpacity();
  1757. $mapContainer.style.width = state.mapWidth;
  1758. $mapContainer.style.height = state.mapHeight;
  1759. });
  1760. helpers.updateMapOpacity();
  1761. }
  1762.  
  1763. var _default = {
  1764. name: 'Map controls',
  1765. 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',
  1766. run: mapControls
  1767. };
  1768. exports.default = _default;
  1769.  
  1770. },{"../../utils/misc":31,"../../utils/state":33,"./helpers":17}],19:[function(require,module,exports){
  1771. "use strict";
  1772.  
  1773. Object.defineProperty(exports, "__esModule", {
  1774. value: true
  1775. });
  1776. exports.handleMerchantFilterInputChange = handleMerchantFilterInputChange;
  1777. exports.deleteMerchantObserver = deleteMerchantObserver;
  1778.  
  1779. var _game = require("../../utils/game");
  1780.  
  1781. var _state = require("../../utils/state");
  1782.  
  1783. function handleMerchantFilterInputChange() {
  1784. const $filterInput = document.querySelector('.js-merchant-filter-input');
  1785.  
  1786. if (!$filterInput) {
  1787. return;
  1788. }
  1789.  
  1790. const value = $filterInput.value;
  1791.  
  1792. if (value) {
  1793. _refreshMerchantFilter(); // When we're filtering, start refreshing merchant filter if we haven't already
  1794.  
  1795. } // If no filters, include single empty string, to make every item visible
  1796.  
  1797.  
  1798. const filters = value.split(',').map(v => v.trim()) || [''];
  1799. const $items = Array.from(document.querySelectorAll('.js-merchant-initd .items .slot'));
  1800. $items.forEach($item => {
  1801. const tooltipContentPromise = (0, _game.getTooltipContent)($item);
  1802. tooltipContentPromise.then(tooltipContent => {
  1803. if (!tooltipContent) {
  1804. // Something weird happened, probably related to lag from looking at tooltips in bulk
  1805. // In this case where we unexpectedly don't have the tooltip, just show the item rather than error out
  1806. $item.parentNode.style.display = 'grid';
  1807. return;
  1808. }
  1809.  
  1810. let filterMatchCount = 0;
  1811. filters.forEach(filter => {
  1812. const matchesFilter = tooltipContent.textContent.toLowerCase().includes(filter.toLowerCase());
  1813.  
  1814. if (matchesFilter) {
  1815. filterMatchCount++;
  1816. }
  1817. });
  1818. const matchesAllFilters = filterMatchCount === filters.length;
  1819.  
  1820. if (matchesAllFilters) {
  1821. $item.parentNode.style.display = 'grid';
  1822. } else {
  1823. $item.parentNode.style.display = 'none';
  1824. }
  1825. });
  1826. });
  1827. }
  1828.  
  1829. function _refreshMerchantFilter() {
  1830. const tempState = (0, _state.getTempState)(); // If we're already observing, we don't need to observe again
  1831.  
  1832. if (tempState.merchantLoadingObserver) return;
  1833. tempState.merchantLoadingObserver = new MutationObserver(mutation => {
  1834. // If spinner is visible, we are loading. Once spinner is not visible, we are no longer loading
  1835. if (mutation[0] && mutation[0].addedNodes[0] && mutation[0].addedNodes[0].classList.contains('spinner')) {
  1836. tempState.merchantLoading = true;
  1837. } else {
  1838. // If we were loading and now we aren't, we want to refresh the filters
  1839. if (tempState.merchantLoading) {
  1840. handleMerchantFilterInputChange();
  1841. }
  1842.  
  1843. tempState.merchantLoading = false;
  1844. }
  1845. });
  1846. tempState.merchantLoadingObserver.observe(document.querySelector('.js-merchant-initd .buy'), {
  1847. attributes: false,
  1848. childList: true,
  1849. subtree: true
  1850. });
  1851. }
  1852.  
  1853. function deleteMerchantObserver() {
  1854. const tempState = (0, _state.getTempState)();
  1855.  
  1856. if (tempState.merchantLoadingObserver) {
  1857. tempState.merchantLoading = false;
  1858. tempState.merchantLoadingObserver.disconnect();
  1859. delete tempState.merchantLoadingObserver;
  1860. }
  1861. }
  1862.  
  1863. },{"../../utils/game":30,"../../utils/state":33}],20:[function(require,module,exports){
  1864. "use strict";
  1865.  
  1866. Object.defineProperty(exports, "__esModule", {
  1867. value: true
  1868. });
  1869. exports.default = void 0;
  1870.  
  1871. var _game = require("../../utils/game");
  1872.  
  1873. var _misc = require("../../utils/misc");
  1874.  
  1875. var _ui = require("../../utils/ui");
  1876.  
  1877. var _helpers = require("./helpers");
  1878.  
  1879. function addMerchantFilter() {
  1880. const $merchant = (0, _game.getWindow)('Merchant'); // If merchant is closed or merchant filter input is already added, we dont need to do anything
  1881.  
  1882. if (!$merchant || $merchant.querySelector('.js-merchant-filter-input')) {
  1883. return;
  1884. }
  1885.  
  1886. $merchant.classList.add('js-merchant-initd');
  1887. $merchant.classList.add('uidom-merchant-with-filters');
  1888. (0, _ui.setWindowOpen)(_ui.WindowNames.merchant);
  1889. const $lvMaximumField = $merchant.querySelectorAll('input[type="number"]')[1];
  1890. const $customSearchField = (0, _misc.makeElement)({
  1891. element: 'input',
  1892. class: 'js-merchant-filter-input uidom-merchant-input',
  1893. type: 'search',
  1894. placeholder: 'Filters (comma separated)'
  1895. });
  1896. $lvMaximumField.parentNode.insertBefore($customSearchField, $lvMaximumField.nextSibling);
  1897. $merchant.querySelector('.js-merchant-filter-input').addEventListener('keyup', (0, _misc.debounce)(_helpers.handleMerchantFilterInputChange, 250));
  1898. }
  1899.  
  1900. function cleanupMerchantObserver() {
  1901. if ((0, _ui.isWindowOpen)(_ui.WindowNames.merchant)) {
  1902. const $merchant = document.querySelector('.js-merchant-initd');
  1903. if ($merchant) return;
  1904. } // Window was set to open but is actually closed, let's clean up...
  1905.  
  1906.  
  1907. (0, _ui.setWindowClosed)(_ui.WindowNames.merchant);
  1908. (0, _helpers.deleteMerchantObserver)();
  1909. }
  1910.  
  1911. var _default = {
  1912. name: 'Merchant filter',
  1913. description: 'Allows you to specify filters, or search text, for items displayed in the merchant',
  1914. run: ({
  1915. registerOnDomChange
  1916. }) => {
  1917. addMerchantFilter();
  1918. registerOnDomChange(addMerchantFilter);
  1919. registerOnDomChange(() => {
  1920. cleanupMerchantObserver();
  1921. });
  1922. }
  1923. };
  1924. exports.default = _default;
  1925.  
  1926. },{"../../utils/game":30,"../../utils/misc":31,"../../utils/ui":34,"./helpers":19}],21:[function(require,module,exports){
  1927. "use strict";
  1928.  
  1929. Object.defineProperty(exports, "__esModule", {
  1930. value: true
  1931. });
  1932. exports.default = void 0;
  1933.  
  1934. var _state = require("../../utils/state");
  1935.  
  1936. function resizableChat() {
  1937. const state = (0, _state.getState)(); // Add the appropriate classes
  1938.  
  1939. const $chatContainer = document.querySelector('#chat').parentNode;
  1940. $chatContainer.classList.add('js-chat-resize'); // Load initial chat and map size
  1941.  
  1942. if (state.chatWidth && state.chatHeight) {
  1943. $chatContainer.style.width = state.chatWidth;
  1944. $chatContainer.style.height = state.chatHeight;
  1945. } // Save chat size on resize
  1946.  
  1947.  
  1948. const resizeObserverChat = new ResizeObserver(() => {
  1949. const chatWidthStr = window.getComputedStyle($chatContainer, null).getPropertyValue('width');
  1950. const chatHeightStr = window.getComputedStyle($chatContainer, null).getPropertyValue('height');
  1951. const hasWidthChanged = state.chatWidth !== chatWidthStr;
  1952. const hasHeightChanged = state.chatHeight !== chatHeightStr;
  1953. if (hasWidthChanged) state.chatWidth = chatWidthStr;
  1954. if (hasHeightChanged) state.chatHeight = chatHeightStr;
  1955. if (hasWidthChanged || hasHeightChanged) (0, _state.saveState)();
  1956. });
  1957. resizeObserverChat.observe($chatContainer);
  1958. }
  1959.  
  1960. var _default = {
  1961. name: 'Resizable chat',
  1962. description: 'Allows you to resize chat by clicking and dragging from the bottom right of chat',
  1963. run: resizableChat
  1964. };
  1965. exports.default = _default;
  1966.  
  1967. },{"../../utils/state":33}],22:[function(require,module,exports){
  1968. "use strict";
  1969.  
  1970. Object.defineProperty(exports, "__esModule", {
  1971. value: true
  1972. });
  1973. exports.mapResizeHandler = mapResizeHandler;
  1974. exports.triggerMapResize = triggerMapResize;
  1975.  
  1976. var _state = require("../../utils/state");
  1977.  
  1978. // When the map container resizes, we want to update the canvas width/height and the state
  1979. function mapResizeHandler() {
  1980. if (!document.querySelector('.layout')) {
  1981. return;
  1982. }
  1983.  
  1984. const state = (0, _state.getState)();
  1985. const tempState = (0, _state.getTempState)();
  1986. const $map = document.querySelector('.container canvas').parentNode;
  1987. const $canvas = $map.querySelector('canvas'); // Get real values of map height/width, excluding padding/margin/etc
  1988. // We round the values in this file to prevent unnecessary decimal points in our map or canvas sizes
  1989. // For some people these decimal points cause the map to constantly resize, making it pretty unusable.
  1990. // Rounding the numbers fixes this.
  1991.  
  1992. const mapWidthStr = window.getComputedStyle($map, null).getPropertyValue('width');
  1993. const mapHeightStr = window.getComputedStyle($map, null).getPropertyValue('height');
  1994. const mapWidth = Math.round(Number(mapWidthStr.slice(0, -2)));
  1995. const mapHeight = Math.round(Number(mapHeightStr.slice(0, -2))); // If height/width are 0 or unset, don't resize canvas
  1996.  
  1997. if (!mapWidth || !mapHeight) {
  1998. return;
  1999. }
  2000.  
  2001. if ($canvas.width !== mapWidth) {
  2002. $canvas.width = mapWidth;
  2003. }
  2004.  
  2005. if ($canvas.height !== mapHeight) {
  2006. $canvas.height = mapHeight;
  2007. } // If we're clicking map, i.e. manually resizing, then save state
  2008. // Don't save state when minimizing/maximizing map via [M]
  2009.  
  2010.  
  2011. if (tempState.clickingMap) {
  2012. state.mapWidth = mapWidthStr;
  2013. state.mapHeight = mapHeightStr;
  2014. (0, _state.saveState)();
  2015. } else {
  2016. const isMaximized = mapWidth > tempState.lastMapWidth && mapHeight > tempState.lastMapHeight;
  2017.  
  2018. if (!isMaximized) {
  2019. $map.style.width = state.mapWidth;
  2020. $map.style.height = state.mapHeight;
  2021. }
  2022. } // Store last map width/height in temp state, so we know if we've minimized or maximized
  2023.  
  2024.  
  2025. tempState.lastMapWidth = mapWidth;
  2026. tempState.lastMapHeight = mapHeight;
  2027. } // We need to observe canvas resizes to tell when the user presses M to open the big map
  2028. // At that point, we resize the map to match the canvas
  2029.  
  2030.  
  2031. function triggerMapResize() {
  2032. if (!document.querySelector('.layout')) {
  2033. return;
  2034. }
  2035.  
  2036. const $map = document.querySelector('.container canvas').parentNode;
  2037. const $canvas = $map.querySelector('canvas'); // Get real values of map height/width, excluding padding/margin/etc
  2038.  
  2039. const mapWidthStr = window.getComputedStyle($map, null).getPropertyValue('width');
  2040. const mapHeightStr = window.getComputedStyle($map, null).getPropertyValue('height');
  2041. const mapWidth = Math.round(Number(mapWidthStr.slice(0, -2)));
  2042. const mapHeight = Math.round(Number(mapHeightStr.slice(0, -2)));
  2043. const canvasWidth = Math.round($canvas.width);
  2044. const canvasHeight = Math.round($canvas.height); // If height/width are 0 or unset, we don't care about resizing yet
  2045.  
  2046. if (!mapWidth || !mapHeight) {
  2047. return;
  2048. }
  2049.  
  2050. if (canvasWidth !== mapWidth) {
  2051. $map.style.width = `${canvasWidth}px`;
  2052. }
  2053.  
  2054. if (canvasHeight !== mapHeight) {
  2055. $map.style.height = `${canvasHeight}px`;
  2056. }
  2057. }
  2058.  
  2059. },{"../../utils/state":33}],23:[function(require,module,exports){
  2060. "use strict";
  2061.  
  2062. Object.defineProperty(exports, "__esModule", {
  2063. value: true
  2064. });
  2065. exports.default = void 0;
  2066.  
  2067. var _state = require("../../utils/state");
  2068.  
  2069. var helpers = _interopRequireWildcard(require("./helpers"));
  2070.  
  2071. var _misc = require("../../utils/misc");
  2072.  
  2073. function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
  2074.  
  2075. 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; }
  2076.  
  2077. function resizableMap() {
  2078. const state = (0, _state.getState)();
  2079. const tempState = (0, _state.getTempState)();
  2080. const $map = document.querySelector('.container canvas').parentNode;
  2081. const $canvas = $map.querySelector('canvas');
  2082. $map.classList.add('js-map-resize'); // Track whether we're clicking (resizing) map or not
  2083. // Used to detect if resize changes are manually done, or from minimizing/maximizing map (with [M])
  2084.  
  2085. $map.addEventListener('mousedown', () => {
  2086. tempState.clickingMap = true;
  2087. }); // Sometimes the mouseup event may be registered outside of the map - we account for this
  2088.  
  2089. document.body.addEventListener('mouseup', () => {
  2090. tempState.clickingMap = false;
  2091. });
  2092.  
  2093. if (state.mapWidth && state.mapHeight) {
  2094. $map.style.width = state.mapWidth;
  2095. $map.style.height = state.mapHeight;
  2096. helpers.mapResizeHandler(); // Update canvas size on initial load of saved map size
  2097. } // On resize of map, resize canvas to match
  2098. // Debouncing allows map to be visible while resizing
  2099.  
  2100.  
  2101. const debouncedMapResize = (0, _misc.debounce)(helpers.mapResizeHandler, 1);
  2102. const resizeObserverMap = new ResizeObserver(debouncedMapResize);
  2103. helpers.mapResizeHandler();
  2104. resizeObserverMap.observe($map); // We debounce the canvas resize, so it doesn't resize every single
  2105. // pixel you move when resizing the DOM. If this were to happen,
  2106. // resizing would constantly be interrupted. You'd have to resize a tiny bit,
  2107. // lift left click, left click again to resize a tiny bit more, etc.
  2108. // Resizing is smooth when we debounce this canvas.
  2109.  
  2110. const debouncedTriggerResize = (0, _misc.debounce)(helpers.triggerMapResize, 50);
  2111. const resizeObserverCanvas = new ResizeObserver(debouncedTriggerResize);
  2112. resizeObserverCanvas.observe($canvas);
  2113. }
  2114.  
  2115. var _default = {
  2116. name: 'Resizable map',
  2117. description: 'Allows you to resize the map by clicking and dragging from the bottom left',
  2118. run: resizableMap
  2119. };
  2120. exports.default = _default;
  2121.  
  2122. },{"../../utils/misc":31,"../../utils/state":33,"./helpers":22}],24:[function(require,module,exports){
  2123. "use strict";
  2124.  
  2125. Object.defineProperty(exports, "__esModule", {
  2126. value: true
  2127. });
  2128. exports.default = void 0;
  2129.  
  2130. // The last clicked UI window displays above all other UI windows
  2131. // This is useful when, for example, your inventory is near the market window,
  2132. // and you want the window and the tooltips to display above the market window.
  2133. function selectedWindowIsTop() {
  2134. Array.from(document.querySelectorAll('.window:not(.js-is-top-initd)')).forEach($window => {
  2135. $window.classList.add('js-is-top-initd');
  2136. $window.addEventListener('mousedown', () => {
  2137. // First, make the other is-top window not is-top
  2138. const $otherWindowContainer = document.querySelector('.js-is-top');
  2139.  
  2140. if ($otherWindowContainer) {
  2141. $otherWindowContainer.classList.remove('js-is-top');
  2142. } // Then, make our window's container (the z-index container) is-top
  2143.  
  2144.  
  2145. $window.parentNode.classList.add('js-is-top');
  2146. });
  2147. });
  2148. }
  2149.  
  2150. var _default = {
  2151. name: 'Make Selected Window Top',
  2152. description: 'The UI window you click will always be displayed over other UI windows',
  2153. run: ({
  2154. registerOnDomChange
  2155. }) => {
  2156. selectedWindowIsTop(); // As windows are opened, we want to enable them to become the top window when they're clicked
  2157.  
  2158. registerOnDomChange(selectedWindowIsTop);
  2159. }
  2160. };
  2161. exports.default = _default;
  2162.  
  2163. },{}],25:[function(require,module,exports){
  2164. "use strict";
  2165.  
  2166. Object.defineProperty(exports, "__esModule", {
  2167. value: true
  2168. });
  2169. exports.addSkillCooldownNumbers = addSkillCooldownNumbers;
  2170.  
  2171. var _state = require("../../utils/state");
  2172.  
  2173. var _misc = require("../../utils/misc");
  2174.  
  2175. function _getCooldownText(cd) {
  2176. const timeBetweenCooldownChecks = cd.latestCooldownTimestamp - cd.initialCooldownTimestamp;
  2177. const percentCompletedWithinTime = cd.initialCooldownPcntLeft - cd.latestCooldownPcntLeft;
  2178. const secondsForOnePercent = timeBetweenCooldownChecks / percentCompletedWithinTime / 1000;
  2179. return Math.floor(secondsForOnePercent * cd.latestCooldownPcntLeft);
  2180. }
  2181.  
  2182. function _handleCooldownUpdate(mutations) {
  2183. const tempState = (0, _state.getTempState)();
  2184. mutations.forEach(mutation => {
  2185. if (!mutation.target.classList.contains('cd')) return;
  2186. const $cooldownOverlay = mutation.target;
  2187. const skillId = $cooldownOverlay.parentNode.id;
  2188. const cooldownPercentageLeft = parseInt($cooldownOverlay.style.height);
  2189. const cooldownState = tempState.cooldownNums[skillId];
  2190.  
  2191. if (!cooldownState.initialCooldownTimestamp) {
  2192. cooldownState.initialCooldownTimestamp = Date.now();
  2193. cooldownState.initialCooldownPcntLeft = cooldownPercentageLeft;
  2194. }
  2195.  
  2196. cooldownState.latestCooldownTimestamp = Date.now();
  2197. cooldownState.latestCooldownPcntLeft = cooldownPercentageLeft;
  2198. cooldownState.calculationCount++; // Minimum number of numbers to figure out an accurate enough real cooldown number = 3
  2199. // Set the cooldown number in the UI
  2200.  
  2201. if (cooldownState.calculationCount > 2) {
  2202. const $cooldownNum = $cooldownOverlay.querySelector('.js-cooldown-num');
  2203. $cooldownNum.innerText = _getCooldownText(cooldownState);
  2204. }
  2205. });
  2206. }
  2207.  
  2208. function addSkillCooldownNumbers() {
  2209. const tempState = (0, _state.getTempState)(); // Add/update cooldowns
  2210.  
  2211. const $skillCooldowns = Array.from(document.querySelectorAll('#skillbar .cd:not(.js-cooldown-num-initd'));
  2212. $skillCooldowns.forEach($cooldownOverlay => {
  2213. $cooldownOverlay.classList.add('js-cooldown-num-initd'); // Add cooldown element to overlay
  2214.  
  2215. $cooldownOverlay.appendChild((0, _misc.makeElement)({
  2216. element: 'div',
  2217. class: 'js-cooldown-num'
  2218. }));
  2219. const cooldownObserver = new MutationObserver(_handleCooldownUpdate); // Add cooldown number and mutator to state
  2220.  
  2221. const skillId = $cooldownOverlay.parentNode.id;
  2222. tempState.cooldownNums[skillId] = {
  2223. initialCooldownTimestamp: null,
  2224. initialCooldownPcntLeft: null,
  2225. latestCooldownTimestamp: null,
  2226. latestCooldownPcntLeft: null,
  2227. calculationCount: 0
  2228. }; // Clear preexisting observer if it exists, then set new one to state
  2229.  
  2230. if (tempState.cooldownObservers[skillId]) {
  2231. tempState.cooldownObservers[skillId].disconnect();
  2232. delete tempState.cooldownObservers[skillId];
  2233. }
  2234.  
  2235. tempState.cooldownObservers[skillId] = cooldownObserver;
  2236. cooldownObserver.observe($cooldownOverlay, {
  2237. attributes: true
  2238. });
  2239. });
  2240. }
  2241.  
  2242. },{"../../utils/misc":31,"../../utils/state":33}],26:[function(require,module,exports){
  2243. "use strict";
  2244.  
  2245. Object.defineProperty(exports, "__esModule", {
  2246. value: true
  2247. });
  2248. exports.default = void 0;
  2249.  
  2250. var _state = require("../../utils/state");
  2251.  
  2252. var _helpers = require("./helpers");
  2253.  
  2254. function skillCooldownNumbers() {
  2255. const tempState = (0, _state.getTempState)(); // If not initialized, initialize with initial observer
  2256.  
  2257. const $skillBar = document.querySelector('#skillbar:not(.js-cooldowns-skillbar-initd');
  2258. if (!$skillBar) return;
  2259. $skillBar.classList.add('js-cooldowns-skillbar-initd');
  2260.  
  2261. if (tempState.skillBarObserver) {
  2262. tempState.skillBarObserver.disconnect();
  2263. delete tempState.skillBarObserver;
  2264. }
  2265.  
  2266. tempState.skillBarObserver = new MutationObserver(_helpers.addSkillCooldownNumbers);
  2267. tempState.skillBarObserver.observe($skillBar, {
  2268. subtree: true,
  2269. childList: true,
  2270. attributes: true
  2271. });
  2272. }
  2273.  
  2274. var _default = {
  2275. name: 'Skill cooldown numbers',
  2276. description: 'Overlays time left on cooldown over skill icons',
  2277. run: () => {
  2278. skillCooldownNumbers();
  2279. }
  2280. };
  2281. exports.default = _default;
  2282.  
  2283. },{"../../utils/state":33,"./helpers":25}],27:[function(require,module,exports){
  2284. "use strict";
  2285.  
  2286. Object.defineProperty(exports, "__esModule", {
  2287. value: true
  2288. });
  2289. exports.getCurrentCharacterLvl = getCurrentCharacterLvl;
  2290. exports.getCurrentXp = getCurrentXp;
  2291. exports.getNextLevelXp = getNextLevelXp;
  2292. exports.resetXpMeterState = resetXpMeterState;
  2293. exports.msToString = msToString;
  2294.  
  2295. var _state = require("../../utils/state");
  2296.  
  2297. function getCurrentCharacterLvl() {
  2298. return Number(document.querySelector('#ufplayer .bgmana > .left').textContent.split('Lv. ')[1]);
  2299. }
  2300.  
  2301. function getCurrentXp() {
  2302. return Number(document.querySelector('#expbar .progressBar > .left').textContent.split('/')[0].trim());
  2303. }
  2304.  
  2305. function getNextLevelXp() {
  2306. return Number(document.querySelector('#expbar .progressBar > .left').textContent.split('/')[1].trim());
  2307. } // user invoked reset of xp meter stats
  2308.  
  2309.  
  2310. function resetXpMeterState() {
  2311. const state = (0, _state.getState)();
  2312. state.xpMeterState.xpGains = []; // array of xp deltas every second
  2313.  
  2314. state.xpMeterState.averageXp = 0;
  2315. state.xpMeterState.gainedXp = 0;
  2316. (0, _state.saveState)();
  2317. document.querySelector('.js-xp-time').textContent = '-:-:-';
  2318. }
  2319.  
  2320. function msToString(ms) {
  2321. const pad = value => value < 10 ? `0${value}` : value;
  2322.  
  2323. const hours = pad(Math.floor(ms / (1000 * 60 * 60) % 60));
  2324. const minutes = pad(Math.floor(ms / (1000 * 60) % 60));
  2325. const seconds = pad(Math.floor(ms / 1000 % 60));
  2326. return `${hours}:${minutes}:${seconds}`;
  2327. }
  2328.  
  2329. },{"../../utils/state":33}],28:[function(require,module,exports){
  2330. "use strict";
  2331.  
  2332. Object.defineProperty(exports, "__esModule", {
  2333. value: true
  2334. });
  2335. exports.default = void 0;
  2336.  
  2337. var _state = require("../../utils/state");
  2338.  
  2339. var helpers = _interopRequireWildcard(require("./helpers"));
  2340.  
  2341. var _ui = require("../../utils/ui");
  2342.  
  2343. function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
  2344.  
  2345. 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; }
  2346.  
  2347. // TODO: Consider adding start button to start interval, and stop after X minutes of no EXP
  2348. // Or maybe watch XP bar and start it once XP bar first moves?
  2349. // Adds XP Meter DOM icon and window, starts continuous interval to get current xp over time
  2350. function xpMeter() {
  2351. const state = (0, _state.getState)();
  2352. const tempState = (0, _state.getTempState)();
  2353. (0, _ui.createXpMeter)(); // If it was open when the game last closed keep it open
  2354.  
  2355. if ((0, _ui.isWindowOpen)(_ui.WindowNames.xpMeter)) {
  2356. (0, _ui.toggleXpMeterVisibility)();
  2357. } // Wire up icon and xpmeter window
  2358.  
  2359.  
  2360. document.querySelector('.js-sysxp').addEventListener('click', _ui.toggleXpMeterVisibility);
  2361. document.querySelector('.js-xpmeter-close-icon').addEventListener('click', _ui.toggleXpMeterVisibility);
  2362. document.querySelector('.js-xpmeter-reset-button').addEventListener('click', helpers.resetXpMeterState);
  2363. const currentXp = helpers.getCurrentXp();
  2364. const currentCharLvl = helpers.getCurrentCharacterLvl();
  2365. if (currentXp !== state.xpMeterState.currentXp) state.xpMeterState.currentXp = currentXp;
  2366. if (currentCharLvl !== state.xpMeterState.currentLvl) state.xpMeterState.currentLvl = currentCharLvl;
  2367. (0, _state.saveState)();
  2368. if (tempState.xpMeterInterval) clearInterval(tempState.xpMeterInterval); // every second we run the operations for xp meter, update xps, calc delta, etc
  2369. // TODO Cleanup: This interval may not be cleaned up if the UI mod reinitializes,
  2370. // e.g. user is away from tab for a while then comes back
  2371. // Should confirm if this is an issue, and try to fix it if possible.
  2372.  
  2373. tempState.xpMeterInterval = setInterval(() => {
  2374. if (!document.querySelector('#expbar')) {
  2375. return;
  2376. } // This _shouldn't_ happen, but in case it does, reset xp meter state instead of throwing error
  2377.  
  2378.  
  2379. if (!Array.isArray(state.xpMeterState.xpGains)) {
  2380. helpers.resetXpMeterState();
  2381. }
  2382.  
  2383. const currentXp = helpers.getCurrentXp();
  2384. const nextLvlXp = helpers.getNextLevelXp();
  2385. const currentLvl = helpers.getCurrentCharacterLvl(); // Only update and save state if it has changed
  2386.  
  2387. const gainedXp = currentXp - state.xpMeterState.currentXp;
  2388. const xpGains = currentXp - state.xpMeterState.currentXp;
  2389. 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
  2390.  
  2391. state.xpMeterState.xpGains.push(xpGains); // array of xp deltas every second
  2392.  
  2393. if (gainedXp !== 0) state.xpMeterState.gainedXp += gainedXp;
  2394. if (currentXp !== state.xpMeterState.currentXp) state.xpMeterState.currentXp = currentXp;
  2395. if (averageXp !== state.xpMeterState.averageXp) state.xpMeterState.averageXp = averageXp;
  2396. (0, _state.saveState)();
  2397.  
  2398. if (document.querySelector('.js-xpmeter')) {
  2399. document.querySelector('.js-xpm').textContent = parseInt((state.xpMeterState.averageXp * 60).toFixed(0)).toLocaleString();
  2400. document.querySelector('.js-xph').textContent = parseInt((state.xpMeterState.averageXp * 60 * 60).toFixed(0)).toLocaleString();
  2401. document.querySelector('.js-xpg').textContent = state.xpMeterState.gainedXp.toLocaleString();
  2402. document.querySelector('.js-xpl').textContent = (nextLvlXp - currentXp).toLocaleString();
  2403. document.querySelector('.js-xp-s-time').textContent = helpers.msToString(state.xpMeterState.xpGains.length * 1000); // need a positive integer for averageXp to calc time left
  2404.  
  2405. if (state.xpMeterState.averageXp > 0) document.querySelector('.js-xp-time').textContent = helpers.msToString((nextLvlXp - currentXp) / state.xpMeterState.averageXp * 1000);
  2406. }
  2407.  
  2408. if (state.xpMeterState.currentLvl < currentLvl) {
  2409. helpers.resetXpMeterState();
  2410. state.xpMeterState.currentLvl = currentLvl;
  2411. (0, _state.saveState)();
  2412. }
  2413. }, 1000);
  2414. }
  2415.  
  2416. var _default = {
  2417. name: 'XP Meter',
  2418. description: "Tracks your XP/minute and displays how much XP you're getting and lets you know how long until you level up",
  2419. run: xpMeter
  2420. };
  2421. exports.default = _default;
  2422.  
  2423. },{"../../utils/state":33,"../../utils/ui":34,"./helpers":27}],29:[function(require,module,exports){
  2424. "use strict";
  2425.  
  2426. Object.defineProperty(exports, "__esModule", {
  2427. value: true
  2428. });
  2429. exports.setGMChatVisibility = setGMChatVisibility;
  2430. exports.filterAllChat = filterAllChat;
  2431. exports.whisperPlayer = whisperPlayer;
  2432. exports.partyPlayer = partyPlayer;
  2433. exports.addChatMessage = addChatMessage;
  2434.  
  2435. var _state = require("./state");
  2436.  
  2437. var _misc = require("./misc");
  2438.  
  2439. // Updates state.chat.GM and the DOM to make text white/grey depending on if gm chat is visible/filtered
  2440. // Then filters chat and saves updated chat state
  2441. function setGMChatVisibility(isGMChatVisible) {
  2442. const state = (0, _state.getState)();
  2443. const $chatGM = document.querySelector(`.js-chat-gm`);
  2444. state.chat.GM = isGMChatVisible;
  2445. $chatGM.classList.toggle('textgrey', !state.chat.GM);
  2446. filterAllChat();
  2447. (0, _state.saveState)();
  2448. } // Filters all chat based on custom filters
  2449.  
  2450.  
  2451. function filterAllChat() {
  2452. const state = (0, _state.getState)(); // Blocked user filter
  2453.  
  2454. Object.keys(state.blockList).forEach(blockedName => {
  2455. // Get the `.name` elements from the blocked user, if we haven't already hidden their messages
  2456. const $blockedChatNames = Array.from(document.querySelectorAll(`[data-chat-name="${blockedName}"]:not(.js-line-blocked)`)); // Hide each of their messages
  2457.  
  2458. $blockedChatNames.forEach($name => {
  2459. // Add the class name to $name so we can track whether it's been hidden in our CSS selector $blockedChatNames
  2460. $name.classList.add('js-line-blocked');
  2461. const $line = $name.parentNode.parentNode.parentNode; // Add the class name to $line so we can visibly hide the entire chat line
  2462.  
  2463. $line.classList.add('js-line-blocked');
  2464. });
  2465. }); // Custom channel filter
  2466.  
  2467. Object.keys(state.chat).forEach(channel => {
  2468. Array.from(document.querySelectorAll(`.text${channel}.content`)).forEach($textItem => {
  2469. const $line = $textItem.parentNode.parentNode;
  2470. $line.classList.toggle('js-line-hidden', !state.chat[channel]);
  2471. });
  2472. });
  2473. }
  2474.  
  2475. function enterTextIntoChat(text) {
  2476. // Open chat input
  2477. const enterEvent = new KeyboardEvent('keydown', {
  2478. bubbles: true,
  2479. cancelable: true,
  2480. keyCode: 13
  2481. });
  2482. document.body.dispatchEvent(enterEvent); // Place text into chat
  2483.  
  2484. const $input = document.querySelector('#chatinput input');
  2485. $input.value = text; // Get chat input to recognize slash commands and change the channel
  2486. // by triggering the `input` event.
  2487. // (Did some debugging to figure out the channel only changes when the
  2488. // svelte `input` event listener exists.)
  2489.  
  2490. const inputEvent = new KeyboardEvent('input', {
  2491. bubbles: true,
  2492. cancelable: true
  2493. });
  2494. $input.dispatchEvent(inputEvent);
  2495. }
  2496.  
  2497. function submitChat() {
  2498. const $input = document.querySelector('#chatinput input');
  2499. const kbEvent = new KeyboardEvent('keydown', {
  2500. bubbles: true,
  2501. cancelable: true,
  2502. keyCode: 13
  2503. });
  2504. $input.dispatchEvent(kbEvent);
  2505. } // Automated chat command helpers
  2506. // (We've been OK'd to do these by the dev - all automation like this should receive approval from the dev)
  2507.  
  2508.  
  2509. function whisperPlayer(playerName) {
  2510. enterTextIntoChat(`/${playerName} `);
  2511. }
  2512.  
  2513. function partyPlayer(playerName) {
  2514. enterTextIntoChat(`/partyinvite ${playerName}`);
  2515. submitChat();
  2516. } // Pushes message to chat
  2517. // TODO: The margins for the message are off slightly compared to other messages - why?
  2518.  
  2519.  
  2520. function addChatMessage(text) {
  2521. const newMessageHTML = `
  2522. <div class="linewrap svelte-1vrlsr3">
  2523. <span class="time svelte-1vrlsr3">00.00</span>
  2524. <span class="textuimod content svelte-1vrlsr3">
  2525. <span class="capitalize channel svelte-1vrlsr3">UIMod</span>
  2526. </span>
  2527. <span class="svelte-1vrlsr3">${text}</span>
  2528. </div>
  2529. `;
  2530. const element = (0, _misc.makeElement)({
  2531. element: 'article',
  2532. class: 'line svelte-1vrlsr3',
  2533. content: newMessageHTML
  2534. });
  2535. const $chat = document.querySelector('#chat');
  2536. $chat.appendChild(element); // Scroll to bottom of chat
  2537.  
  2538. $chat.scrollTop = $chat.scrollHeight;
  2539. }
  2540.  
  2541. },{"./misc":31,"./state":33}],30:[function(require,module,exports){
  2542. "use strict";
  2543.  
  2544. Object.defineProperty(exports, "__esModule", {
  2545. value: true
  2546. });
  2547. exports.getTooltipContent = getTooltipContent;
  2548. exports.getWindow = getWindow;
  2549.  
  2550. var _state = require("./state");
  2551.  
  2552. // Gets the node of a tooltip for any element, emulates shift keypress to get tooltip with quality details
  2553. // Must be `await`'d to use, e.g. `await getTooltipContent($element)`
  2554. // Optionally pass `getDetailedTooltips` as `true` if you want detailed tooltips by holding shift
  2555. // ^ is laggier, do not use when looking at more than one item
  2556. async function getTooltipContent($elementToHoverOver, getDetailedTooltips) {
  2557. const tempState = (0, _state.getTempState)(); // Emulate holding down shift when getting tooltip
  2558. // Don't need to emulate if user is already holding it down
  2559.  
  2560. if (getDetailedTooltips && !tempState.keyModifiers.shift) {
  2561. // Set this so the keymodifiers mod knows our shift press shouldn't be tracked in tempState
  2562. tempState.gettingTooltipContentShiftPress = true;
  2563. document.body.dispatchEvent(new KeyboardEvent('keydown', {
  2564. bubbles: true,
  2565. cancelable: true,
  2566. key: 'Shift'
  2567. }));
  2568. }
  2569.  
  2570. $elementToHoverOver.dispatchEvent(new Event('pointerenter'));
  2571. const closeTooltipPromise = new Promise(resolve => setTimeout(() => {
  2572. const resolveWithTooltip = () => {
  2573. // If there is no slotdescription at this point, the item element passed very likely has no tooltip
  2574. const $tooltip = document.querySelector('.slotdescription');
  2575.  
  2576. if (!$tooltip || !$tooltip.cloneNode) {
  2577. resolve(false);
  2578. } else {
  2579. resolve($tooltip.cloneNode(true));
  2580. }
  2581.  
  2582. if (tempState.gettingTooltipContentShiftPress) {
  2583. // Release our emulated shift press
  2584. document.body.dispatchEvent(new KeyboardEvent('keyup', {
  2585. bubbles: true,
  2586. cancelable: true,
  2587. key: 'Shift'
  2588. }));
  2589. tempState.gettingTooltipContentShiftPress = false;
  2590. }
  2591.  
  2592. $elementToHoverOver.dispatchEvent(new Event('pointerleave'));
  2593. }; // Very occasionally the 0ms wait time on our timeout doesn't show the tooltip,
  2594. // so we set a second timeout to account for this. Not the most perfect user experience,
  2595. // but it rarely hapens, and it's better than getting an error.
  2596.  
  2597.  
  2598. if (getDetailedTooltips && !document.querySelector('.slotdescription')) {
  2599. setTimeout(resolveWithTooltip, 1);
  2600. } else {
  2601. resolveWithTooltip();
  2602. }
  2603. }, 0));
  2604. const $tooltip = await closeTooltipPromise;
  2605. return $tooltip;
  2606. } // Use this to get a specific window, rather than using the svelte class, which is not preferable
  2607.  
  2608.  
  2609. function getWindow(windowTitle) {
  2610. const $specificWindowTitle = Array.from(document.querySelectorAll('.window [name="title"]')).find($windowTitle => $windowTitle.textContent.toLowerCase() === windowTitle.toLowerCase());
  2611. return $specificWindowTitle ? $specificWindowTitle.parentNode.parentNode.parentNode : $specificWindowTitle;
  2612. }
  2613.  
  2614. },{"./state":33}],31:[function(require,module,exports){
  2615. "use strict";
  2616.  
  2617. Object.defineProperty(exports, "__esModule", {
  2618. value: true
  2619. });
  2620. exports.makeElement = makeElement;
  2621. exports.debounce = debounce;
  2622. exports.uuid = uuid;
  2623. exports.deepClone = deepClone;
  2624.  
  2625. // Nicer impl to create elements in one method call
  2626. function makeElement(args) {
  2627. const $node = document.createElement(args.element);
  2628. if (args.class) $node.className = args.class;
  2629. if (args.content) $node.innerHTML = args.content;
  2630. if (args.src) $node.src = args.src;
  2631. if (args.type) $node.type = args.type;
  2632. if (args.placeholder) $node.placeholder = args.placeholder;
  2633. return $node;
  2634. } // Credit: David Walsh
  2635.  
  2636.  
  2637. function debounce(func, wait, immediate) {
  2638. var timeout;
  2639. return function () {
  2640. var context = this,
  2641. args = arguments;
  2642.  
  2643. var later = function () {
  2644. timeout = null;
  2645. if (!immediate) func.apply(context, args);
  2646. };
  2647.  
  2648. var callNow = immediate && !timeout;
  2649. clearTimeout(timeout);
  2650. timeout = setTimeout(later, wait);
  2651. if (callNow) func.apply(context, args);
  2652. };
  2653. } // Credit: https://gist.github.com/jcxplorer/823878
  2654. // Generate random UUID string
  2655.  
  2656.  
  2657. function uuid() {
  2658. var uuid = '',
  2659. i,
  2660. random;
  2661.  
  2662. for (i = 0; i < 32; i++) {
  2663. random = Math.random() * 16 | 0;
  2664.  
  2665. if (i == 8 || i == 12 || i == 16 || i == 20) {
  2666. uuid += '-';
  2667. }
  2668.  
  2669. uuid += (i == 12 ? 4 : i == 16 ? random & 3 | 8 : random).toString(16);
  2670. }
  2671.  
  2672. return uuid;
  2673. } // Credit: http://voidcanvas.com/clone-an-object-in-vanilla-js-in-depth/
  2674.  
  2675.  
  2676. function deepClone(obj) {
  2677. //in case of premitives
  2678. if (obj === null || typeof obj !== 'object') {
  2679. return obj;
  2680. } //date objects should be
  2681.  
  2682.  
  2683. if (obj instanceof Date) {
  2684. return new Date(obj.getTime());
  2685. } //handle Array
  2686.  
  2687.  
  2688. if (Array.isArray(obj)) {
  2689. var clonedArr = [];
  2690. obj.forEach(function (element) {
  2691. clonedArr.push(deepClone(element));
  2692. });
  2693. return clonedArr;
  2694. } //lastly, handle objects
  2695.  
  2696.  
  2697. let clonedObj = new obj.constructor();
  2698.  
  2699. for (var prop in obj) {
  2700. if (obj.hasOwnProperty(prop)) {
  2701. clonedObj[prop] = deepClone(obj[prop]);
  2702. }
  2703. }
  2704.  
  2705. return clonedObj;
  2706. }
  2707.  
  2708. },{}],32:[function(require,module,exports){
  2709. "use strict";
  2710.  
  2711. Object.defineProperty(exports, "__esModule", {
  2712. value: true
  2713. });
  2714. exports.friendPlayer = friendPlayer;
  2715. exports.unfriendPlayer = unfriendPlayer;
  2716. exports.blockPlayer = blockPlayer;
  2717. exports.unblockPlayer = unblockPlayer;
  2718.  
  2719. var _state = require("./state");
  2720.  
  2721. var chat = _interopRequireWildcard(require("./chat"));
  2722.  
  2723. var ui = _interopRequireWildcard(require("./ui"));
  2724.  
  2725. function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
  2726.  
  2727. 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; }
  2728.  
  2729. function friendPlayer(playerName) {
  2730. const state = (0, _state.getState)();
  2731.  
  2732. if (state.friendsList[playerName]) {
  2733. return;
  2734. }
  2735.  
  2736. state.friendsList[playerName] = true;
  2737. chat.addChatMessage(`${playerName} has been added to your friends list.`);
  2738. (0, _state.saveState)(); // If UI is open remake it with new changes
  2739.  
  2740. if (ui.isWindowOpen(ui.WindowNames.friendsList)) {
  2741. ui.removeFriendsList();
  2742. ui.createFriendsList();
  2743. }
  2744. }
  2745.  
  2746. function unfriendPlayer(playerName) {
  2747. const state = (0, _state.getState)();
  2748.  
  2749. if (!state.friendsList[playerName]) {
  2750. return;
  2751. }
  2752.  
  2753. delete state.friendsList[playerName];
  2754. delete state.friendNotes[playerName];
  2755. chat.addChatMessage(`${playerName} is no longer on your friends list.`);
  2756. (0, _state.saveState)(); // If UI is open remake it with new changes
  2757.  
  2758. if (ui.isWindowOpen(ui.WindowNames.friendsList)) {
  2759. ui.removeFriendsList();
  2760. ui.createFriendsList();
  2761. }
  2762. } // Adds player to block list, to be filtered out of chat
  2763.  
  2764.  
  2765. function blockPlayer(playerName) {
  2766. const state = (0, _state.getState)();
  2767.  
  2768. if (state.blockList[playerName]) {
  2769. return;
  2770. }
  2771.  
  2772. state.blockList[playerName] = true;
  2773. chat.filterAllChat();
  2774. chat.addChatMessage(`${playerName} has been blocked.`);
  2775. (0, _state.saveState)(); // If UI is open remake it with new changes
  2776.  
  2777. if (ui.isWindowOpen(ui.WindowNames.blockList)) {
  2778. ui.removeBlockList();
  2779. ui.createBlockList();
  2780. }
  2781. } // Removes player from block list and makes their messages visible again
  2782.  
  2783.  
  2784. function unblockPlayer(playerName) {
  2785. const state = (0, _state.getState)();
  2786. delete state.blockList[playerName];
  2787. chat.addChatMessage(`${playerName} has been unblocked.`);
  2788. (0, _state.saveState)(); // Make messages visible again
  2789.  
  2790. const $chatNames = Array.from(document.querySelectorAll(`.js-line-blocked[data-chat-name="${playerName}"]`));
  2791. $chatNames.forEach($name => {
  2792. $name.classList.remove('js-line-blocked');
  2793. const $line = $name.parentNode.parentNode.parentNode;
  2794. $line.classList.remove('js-line-blocked');
  2795. });
  2796. }
  2797.  
  2798. },{"./chat":29,"./state":33,"./ui":34}],33:[function(require,module,exports){
  2799. "use strict";
  2800.  
  2801. Object.defineProperty(exports, "__esModule", {
  2802. value: true
  2803. });
  2804. exports.getState = getState;
  2805. exports.getTempState = getTempState;
  2806. exports.saveState = saveState;
  2807. exports.loadState = loadState;
  2808.  
  2809. var _version = require("./version");
  2810.  
  2811. const STORAGE_STATE_KEY = 'hordesio-uimodsakaiyo-state';
  2812. let state = {
  2813. breakingVersion: _version.BREAKING_VERSION,
  2814. chat: {
  2815. GM: true
  2816. },
  2817. windowsPos: {},
  2818. blockList: {},
  2819. friendsList: {},
  2820. mapOpacity: 70,
  2821. // e.g. 70 = opacity: 0.7
  2822. friendNotes: {},
  2823. chatTabs: [],
  2824. xpMeterState: {
  2825. currentXp: 0,
  2826. xpGains: [],
  2827. // array of xp deltas every second
  2828. averageXp: 0,
  2829. gainedXp: 0,
  2830. currentLvl: 0
  2831. },
  2832. openWindows: {
  2833. friendsList: false,
  2834. blockList: false,
  2835. xpMeter: false,
  2836. merchant: false
  2837. }
  2838. }; // tempState is saved only between page refreshes.
  2839.  
  2840. const tempState = {
  2841. // The last name clicked in chat
  2842. chatName: null,
  2843. lastMapWidth: 0,
  2844. lastMapHeight: 0,
  2845. xpMeterInterval: null,
  2846. // tracks the interval for fetching xp data
  2847. keyModifiers: {
  2848. shift: false,
  2849. control: false,
  2850. alt: false
  2851. },
  2852. // set by _keyModifiers mod
  2853. cooldownNums: {},
  2854. cooldownObservers: {}
  2855. };
  2856.  
  2857. function getState() {
  2858. return state;
  2859. }
  2860.  
  2861. function getTempState() {
  2862. return tempState;
  2863. }
  2864.  
  2865. function saveState() {
  2866. localStorage.setItem(STORAGE_STATE_KEY, JSON.stringify(state));
  2867. }
  2868.  
  2869. function loadState() {
  2870. const storedStateJson = localStorage.getItem(STORAGE_STATE_KEY);
  2871.  
  2872. if (storedStateJson) {
  2873. const storedState = JSON.parse(storedStateJson);
  2874.  
  2875. if (storedState.breakingVersion !== _version.BREAKING_VERSION) {
  2876. localStorage.setItem(STORAGE_STATE_KEY, JSON.stringify(state));
  2877. return;
  2878. }
  2879.  
  2880. for (let [key, value] of Object.entries(storedState)) {
  2881. state[key] = value;
  2882. }
  2883. }
  2884. }
  2885.  
  2886. },{"./version":35}],34:[function(require,module,exports){
  2887. "use strict";
  2888.  
  2889. Object.defineProperty(exports, "__esModule", {
  2890. value: true
  2891. });
  2892. exports.createBlockList = createBlockList;
  2893. exports.removeBlockList = removeBlockList;
  2894. exports.createFriendsList = createFriendsList;
  2895. exports.removeFriendsList = removeFriendsList;
  2896. exports.toggleFriendsList = toggleFriendsList;
  2897. exports.toggleXpMeterVisibility = toggleXpMeterVisibility;
  2898. exports.createXpMeter = createXpMeter;
  2899. exports.resetUiPositions = resetUiPositions;
  2900. exports.setWindowOpen = setWindowOpen;
  2901. exports.setWindowClosed = setWindowClosed;
  2902. exports.isWindowOpen = isWindowOpen;
  2903. exports.WindowNames = void 0;
  2904.  
  2905. var _state = require("./state");
  2906.  
  2907. var _misc = require("./misc");
  2908.  
  2909. var chat = _interopRequireWildcard(require("./chat"));
  2910.  
  2911. var player = _interopRequireWildcard(require("./player"));
  2912.  
  2913. function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
  2914.  
  2915. 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; }
  2916.  
  2917. const WindowNames = {
  2918. friendsList: 'friendsList',
  2919. blockList: 'blockList',
  2920. xpMeter: 'xpMeter',
  2921. merchant: 'merchant',
  2922. clan: 'clan'
  2923. };
  2924. exports.WindowNames = WindowNames;
  2925.  
  2926. function createBlockList() {
  2927. const state = (0, _state.getState)();
  2928. let blockedPlayersHTML = '';
  2929. Object.keys(state.blockList).sort().forEach(blockedName => {
  2930. blockedPlayersHTML += `
  2931. <div data-player-name="${blockedName}">${blockedName}</div>
  2932. <div class="btn orange js-unblock-player" data-player-name="${blockedName}">Unblock player</div>
  2933. `;
  2934. });
  2935. const customSettingsHTML = `
  2936. <h3 class="textprimary">Blocked players</h3>
  2937. <div class="settings uimod-settings">${blockedPlayersHTML}</div>
  2938. <p></p>
  2939. <div class="btn purp js-close-custom-settings">Close</div>
  2940. `;
  2941. const $customSettings = (0, _misc.makeElement)({
  2942. element: 'div',
  2943. class: 'menu panel-black uimod-custom-window js-blocked-list',
  2944. content: customSettingsHTML
  2945. });
  2946. document.body.appendChild($customSettings);
  2947. setWindowOpen(WindowNames.blockList); // Wire up all the unblock buttons
  2948.  
  2949. Array.from(document.querySelectorAll('.js-unblock-player')).forEach($button => {
  2950. $button.addEventListener('click', clickEvent => {
  2951. const name = clickEvent.target.getAttribute('data-player-name');
  2952. player.unblockPlayer(name); // Remove the blocked player from the list
  2953.  
  2954. Array.from(document.querySelectorAll(`.js-blocked-list [data-player-name="${name}"]`)).forEach($element => {
  2955. $element.parentNode.removeChild($element);
  2956. });
  2957. });
  2958. }); // And the close button for our custom UI
  2959.  
  2960. document.querySelector('.js-close-custom-settings').addEventListener('click', removeBlockList);
  2961. }
  2962.  
  2963. function removeBlockList() {
  2964. const $customSettingsWindow = document.querySelector('.js-blocked-list');
  2965. $customSettingsWindow.parentNode.removeChild($customSettingsWindow);
  2966. setWindowClosed(WindowNames.blockList);
  2967. }
  2968.  
  2969. function createFriendsList() {
  2970. const state = (0, _state.getState)();
  2971.  
  2972. if (document.querySelector('.js-friends-list')) {
  2973. // Don't open the friends list twice.
  2974. return;
  2975. }
  2976.  
  2977. let friendsListHTML = '';
  2978. Object.keys(state.friendsList).sort().forEach(friendName => {
  2979. friendsListHTML += `
  2980. <div data-player-name="${friendName}">${friendName}</div>
  2981. <div class="btn blue js-whisper-player" data-player-name="${friendName}">Whisper</div>
  2982. <div class="btn blue js-party-player" data-player-name="${friendName}">Party invite</div>
  2983. <div class="btn orange js-unfriend-player" data-player-name="${friendName}">X</div>
  2984. <input type="text" class="js-friend-note" data-player-name="${friendName}" value="${state.friendNotes[friendName] || ''}"></input>
  2985. `;
  2986. });
  2987. const customFriendsWindowHTML = `
  2988. <div class="titleframe uimod-friends-list-helper">
  2989. <div class="textprimary title uimod-friends-list-helper">
  2990. <div name="title">Friends list</div>
  2991. </div>
  2992. <img src="/assets/ui/icons/cross.svg?v=3282286" class="js-close-custom-friends-list btn black svgicon">
  2993. </div>
  2994. <div class="uimod-friends-intro">To add someone as a friend, click their name in chat and then click Friend :)</div>
  2995. <div class="uimod-friends">${friendsListHTML}</div>
  2996. `;
  2997. const $customFriendsList = (0, _misc.makeElement)({
  2998. element: 'div',
  2999. class: 'menu window panel-black js-friends-list uimod-custom-window',
  3000. content: customFriendsWindowHTML
  3001. });
  3002. document.body.appendChild($customFriendsList);
  3003. setWindowOpen(WindowNames.friendsList); // Wire up the buttons
  3004.  
  3005. Array.from(document.querySelectorAll('.js-whisper-player')).forEach($button => {
  3006. $button.addEventListener('click', clickEvent => {
  3007. const name = clickEvent.target.getAttribute('data-player-name');
  3008. player.whisperPlayer(name);
  3009. });
  3010. });
  3011. Array.from(document.querySelectorAll('.js-party-player')).forEach($button => {
  3012. $button.addEventListener('click', clickEvent => {
  3013. const name = clickEvent.target.getAttribute('data-player-name');
  3014. player.partyPlayer(name);
  3015. });
  3016. });
  3017. Array.from(document.querySelectorAll('.js-unfriend-player')).forEach($button => {
  3018. $button.addEventListener('click', clickEvent => {
  3019. const name = clickEvent.target.getAttribute('data-player-name');
  3020. player.unfriendPlayer(name); // Remove the blocked player from the list
  3021.  
  3022. Array.from(document.querySelectorAll(`.js-friends-list [data-player-name="${name}"]`)).forEach($element => {
  3023. $element.parentNode.removeChild($element);
  3024. });
  3025. });
  3026. });
  3027. Array.from(document.querySelectorAll('.js-friend-note')).forEach($element => {
  3028. $element.addEventListener('change', clickEvent => {
  3029. const name = clickEvent.target.getAttribute('data-player-name');
  3030. state.friendNotes[name] = clickEvent.target.value;
  3031. });
  3032. }); // The close button for our custom UI
  3033.  
  3034. document.querySelector('.js-close-custom-friends-list').addEventListener('click', removeFriendsList);
  3035. }
  3036.  
  3037. function removeFriendsList() {
  3038. const $friendsListWindow = document.querySelector('.js-friends-list');
  3039. $friendsListWindow.parentNode.removeChild($friendsListWindow);
  3040. setWindowClosed(WindowNames.friendsList);
  3041. }
  3042.  
  3043. function toggleFriendsList() {
  3044. if (isWindowOpen(WindowNames.friendsList)) {
  3045. removeFriendsList();
  3046. } else {
  3047. createFriendsList();
  3048. }
  3049. }
  3050.  
  3051. function toggleXpMeterVisibility() {
  3052. const xpMeterContainer = document.querySelector('.js-xpmeter'); // Make it if it doesn't exist for some reason
  3053.  
  3054. if (!xpMeterContainer) {
  3055. createXpMeter();
  3056. }
  3057.  
  3058. xpMeterContainer.style.display = xpMeterContainer.style.display === 'none' ? 'block' : 'none'; // Save whether xpMeter is currently open or closed in the state
  3059.  
  3060. if (xpMeterContainer.style.display === 'none') {
  3061. setWindowClosed(WindowNames.xpMeter);
  3062. } else {
  3063. setWindowOpen(WindowNames.xpMeter);
  3064. }
  3065. }
  3066.  
  3067. function createXpMeter() {
  3068. const $layoutContainer = document.querySelector('body > div.layout > div.container:nth-child(1)');
  3069. const $dpsMeterToggleElement = document.querySelector('#systrophy');
  3070. const $xpMeterToggleElement = (0, _misc.makeElement)({
  3071. element: 'div',
  3072. class: 'js-sysxp js-xpmeter-icon btn border black',
  3073. content: 'XP'
  3074. });
  3075. const xpMeterHTMLString = `
  3076. <div class="l-corner-lr container uimod-xpmeter-1 js-xpmeter" style="display: none">
  3077. <div class="window panel-black uimod-xpmeter-2">
  3078. <div class="titleframe uimod-xpmeter-2">
  3079. <img src="/assets/ui/icons/trophy.svg?v=3282286" class="titleicon svgicon uimod-xpmeter-2">
  3080. <div class="textprimary title uimod-xpmeter-2">
  3081. <div name="title">Experience / XP</div>
  3082. </div>
  3083. <img src="/assets/ui/icons/cross.svg?v=3282286" class="js-xpmeter-close-icon btn black svgicon">
  3084. </div>
  3085. <div class="slot uimod-xpmeter-2" style="">
  3086. <div class="wrapper uimod-xpmeter-1">
  3087. <div class="bar uimod-xpmeter-3" style="z-index: 0;">
  3088. <div class="progressBar bgc1 uimod-xpmeter-3" style="width: 100%; font-size: 1em;">
  3089. <span class="left uimod-xpmeter-3">XP per minute:</span>
  3090. <span class="right uimod-xpmeter-3 js-xpm">-</span>
  3091. </div>
  3092. <div class="progressBar bgc1 uimod-xpmeter-3" style="width: 100%; font-size: 1em;">
  3093. <span class="left uimod-xpmeter-3">XP per hour:</span>
  3094. <span class="right uimod-xpmeter-3 js-xph">-</span>
  3095. </div>
  3096. <div class="progressBar bgc1 uimod-xpmeter-3" style="width: 100%; font-size: 1em;">
  3097. <span class="left uimod-xpmeter-3">XP Gained:</span>
  3098. <span class="right uimod-xpmeter-3 js-xpg">-</span>
  3099. </div>
  3100. <div class="progressBar bgc1 uimod-xpmeter-3" style="width: 100%; font-size: 1em;">
  3101. <span class="left uimod-xpmeter-3">XP Left:</span>
  3102. <span class="right uimod-xpmeter-3 js-xpl">-</span>
  3103. </div>
  3104. <div class="progressBar bgc1 uimod-xpmeter-3" style="width: 100%; font-size: 1em;">
  3105. <span class="left uimod-xpmeter-3">Session Time: </span>
  3106. <span class="right uimod-xpmeter-3 js-xp-s-time">-</span>
  3107. </div>
  3108. <div class="progressBar bgc1 uimod-xpmeter-3" style="width: 100%; font-size: 1em;">
  3109. <span class="left uimod-xpmeter-3">Time to lvl: </span>
  3110. <span class="right uimod-xpmeter-3 js-xp-time">-</span>
  3111. </div>
  3112. </div>
  3113. </div>
  3114. <div class="grid buttons marg-top uimod-xpmeter-1 js-xpmeter-reset-button">
  3115. <div class="btn grey">Reset</div>
  3116. </div>
  3117. </div>
  3118. </div>
  3119. </div>
  3120. `;
  3121. $dpsMeterToggleElement.parentNode.insertBefore($xpMeterToggleElement, $dpsMeterToggleElement.nextSibling);
  3122. const $xpMeterElement = (0, _misc.makeElement)({
  3123. element: 'div',
  3124. content: xpMeterHTMLString.trim()
  3125. });
  3126. $layoutContainer.appendChild($xpMeterElement.firstChild);
  3127. }
  3128.  
  3129. function resetUiPositions() {
  3130. const state = (0, _state.getState)();
  3131. state.windowsPos = {};
  3132. (0, _state.saveState)();
  3133. chat.addChatMessage('Please refresh the page for the reset frame & window positions to take effect.');
  3134. } // state.openWindows should always only be managed by this file
  3135. // Sometimes we want to track when a UI window we don't control is opened/closed
  3136. // We use these methods to help facilitate that
  3137. // To use these methods correctly, you need to track when the window opens _and_ when it closes
  3138. // If you don't _need_ to do both those things, then don't do that, and don't use these methods
  3139.  
  3140.  
  3141. function setWindowOpen(windowName) {
  3142. const state = (0, _state.getState)();
  3143. state.openWindows[windowName] = true;
  3144. (0, _state.saveState)();
  3145. }
  3146.  
  3147. function setWindowClosed(windowName) {
  3148. const state = (0, _state.getState)();
  3149. state.openWindows[windowName] = false;
  3150. (0, _state.saveState)();
  3151. }
  3152.  
  3153. function isWindowOpen(windowName) {
  3154. const state = (0, _state.getState)();
  3155. return state.openWindows[windowName];
  3156. }
  3157.  
  3158. },{"./chat":29,"./misc":31,"./player":32,"./state":33}],35:[function(require,module,exports){
  3159. "use strict";
  3160.  
  3161. Object.defineProperty(exports, "__esModule", {
  3162. value: true
  3163. });
  3164. exports.VERSION = exports.BREAKING_VERSION = void 0;
  3165. // If this version is different from the user's stored state,
  3166. // e.g. they have upgraded the version of this script and there are breaking changes,
  3167. // then their stored state will be deleted.
  3168. const BREAKING_VERSION = 1; // Used for initialization message in chat, and userscript version
  3169.  
  3170. exports.BREAKING_VERSION = BREAKING_VERSION;
  3171. const VERSION = '1.2.1';
  3172. exports.VERSION = VERSION;
  3173.  
  3174. },{}]},{},[1]);