SigMod Client (Macros)

The best mod you can find for Sigmally - Agar.io: Macros, Friends, tag system (minimap, chat), color mod, custom skins, AutoRespawn, save names, themes and more!

当前为 2025-03-22 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name SigMod Client (Macros)
  3. // @version 10.1.9.2
  4. // @description The best mod you can find for Sigmally - Agar.io: Macros, Friends, tag system (minimap, chat), color mod, custom skins, AutoRespawn, save names, themes and more!
  5. // @author Cursed
  6. // @match https://*.sigmally.com/*
  7. // @icon https://czrsd.com/static/sigmod/SigMod25-rounded.png
  8. // @run-at document-end
  9. // @license MIT
  10. // @grant none
  11. // @namespace https://greasyfork.org/users/981958
  12. // ==/UserScript==
  13.  
  14. (function () {
  15. 'use strict';
  16. const version = 10;
  17. const serverVersion = '4.0.3';
  18. const storageVersion = 1.0;
  19. const storageName = 'SigModClient-settings';
  20. const headerAnim = 'https://czrsd.com/static/sigmod/sigmodclient.gif';
  21.  
  22. const libs = {
  23. chart: 'https://cdn.jsdelivr.net/npm/chart.js',
  24. colorPicker: {
  25. js: 'https://unpkg.com/alwan/dist/js/alwan.min.js',
  26. css: 'https://unpkg.com/alwan/dist/css/alwan.min.css',
  27. },
  28. jszip: 'https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js',
  29. };
  30.  
  31. const defaultSettings = {
  32. storageVersion,
  33. macros: {
  34. feedSpeed: 40,
  35. keys: {
  36. rapidFeed: 'w',
  37. respawn: 'b',
  38. location: 'y',
  39. saveImage: null,
  40. splits: {
  41. double: 'd',
  42. triple: 'f',
  43. quad: 'g',
  44. doubleTrick: null,
  45. selfTrick: null,
  46. },
  47. line: {
  48. horizontal: 's',
  49. vertical: 't',
  50. fixed: null,
  51. instantSplit: 0,
  52. },
  53. toggle: {
  54. menu: 'v',
  55. chat: 'z',
  56. names: null,
  57. skins: null,
  58. autoRespawn: null,
  59. },
  60. },
  61. mouse: {
  62. left: null,
  63. right: null,
  64. },
  65. },
  66. game: {
  67. font: 'Ubuntu',
  68. borderColor: null,
  69. foodColor: null,
  70. cellColor: null,
  71. virusImage: '/assets/images/viruses/2.png',
  72. shortenNames: false,
  73. removeOutlines: false,
  74. skins: {
  75. original: null,
  76. replacement: null,
  77. },
  78. map: {
  79. color: null,
  80. image: '',
  81. },
  82. name: {
  83. color: null,
  84. gradient: {
  85. enabled: false,
  86. left: null,
  87. right: null,
  88. },
  89. },
  90. },
  91. themes: {
  92. current: 'Dark',
  93. custom: [],
  94. inputBorderRadius: null,
  95. menuBorderRadius: null,
  96. inputBorder: '1px',
  97. hideDiscordBtns: false,
  98. hideLangs: false,
  99. },
  100. settings: {
  101. tag: null,
  102. savedNames: [],
  103. autoRespawn: false,
  104. playTimer: false,
  105. mouseTracker: false,
  106. autoClaimCoins: false,
  107. showChallenges: false,
  108. deathScreenPos: 'center',
  109. removeShopPopup: false,
  110. },
  111. chat: {
  112. bgColor: '#00000040',
  113. textColor: '#ffffff',
  114. compact: false,
  115. themeColor: '#8a25e5',
  116. showTime: true,
  117. showNameColors: true,
  118. showClientChat: false,
  119. showChatButtons: true,
  120. blurTag: false,
  121. locationText: '{pos}',
  122. },
  123. modAccount: {
  124. authorized: false,
  125. },
  126. };
  127.  
  128. let modSettings;
  129. const stored = localStorage.getItem(storageName);
  130. try {
  131. modSettings = stored ? JSON.parse(stored) : defaultSettings;
  132. } catch (e) {
  133. modSettings = defaultSettings;
  134. }
  135.  
  136. // really rare cases, but in case the storage structure changes completely again
  137. if (
  138. modSettings.storageVersion &&
  139. modSettings.storageVersion !== storageVersion
  140. ) {
  141. localStorage.removeItem(storageName);
  142. location.reload();
  143. }
  144.  
  145. if (!stored) updateStorage();
  146.  
  147. // intercept fetches
  148. let fetchedUser = 0;
  149. const originalFetch = window.fetch;
  150.  
  151. window.fetch = new Proxy(originalFetch, {
  152. async apply(target, thisArg, argumentsList) {
  153. const [url] = argumentsList;
  154. const response = await target.apply(thisArg, argumentsList);
  155.  
  156. if (typeof url === 'string') {
  157. if (url.includes('/server/auth')) {
  158. const data = await response.clone().json();
  159. if (data) mods.handleGoogleAuth(data.body?.user);
  160. }
  161. }
  162.  
  163. return response;
  164. },
  165. });
  166.  
  167. // for development
  168. let isDev = false;
  169. let port = 3001;
  170.  
  171. // global sigmod
  172. window.sigmod = {
  173. version,
  174. server_version: serverVersion,
  175. storageName,
  176. settings: modSettings,
  177. };
  178.  
  179. // Global gameSettings object to store the Sigmally WebSocket, User instance and playing status
  180. /*
  181. * @typedef {Object} User
  182. * @property {string} _id
  183. * @property {number} boost
  184. * @property {Object.<string, number>} cards
  185. * @property {string} clan
  186. * @property {string} createTime
  187. * @property {string} email
  188. * @property {number} exp
  189. * @property {string} fullName
  190. * @property {string} givenName
  191. * @property {number} gold
  192. * @property {string} googleID
  193. * @property {number} hourlyTime
  194. * @property {string} imageURL
  195. * @property {any[]} lastSkinUsed
  196. * @property {number} level
  197. * @property {number} nextLevel
  198. * @property {number} progress
  199. * @property {number} seasonExp
  200. * @property {Object.<string, any>} sigma
  201. * @property {string[]} skins
  202. * @property {number} subscription
  203. * @property {string} updateTime
  204. * @property {string} token
  205. *
  206. * @property {WebSocket} ws
  207. * @property {User} user
  208. * @property {boolean} isPlaying
  209. */
  210. window.gameSettings = {
  211. ws: null,
  212. user: null,
  213. isPlaying: false,
  214. };
  215.  
  216. // --------- HELPER FUNCTIONS --------- \\
  217. // --- General
  218. // --- Colors
  219. // --- Game
  220. // --- Time
  221. // --- (Coordinates)
  222.  
  223. const updateStorage = () => {
  224. localStorage.setItem(storageName, JSON.stringify(modSettings));
  225. }
  226.  
  227. const byId = (id) => document.getElementById(id);
  228.  
  229. const debounce = (func, delay) => {
  230. let timeoutId;
  231. return function (...args) {
  232. clearTimeout(timeoutId);
  233. timeoutId = setTimeout(() => {
  234. func.apply(this, args);
  235. }, delay);
  236. };
  237. }
  238.  
  239. const wait = async (ms) => {
  240. return new Promise((r) => setTimeout(r, ms));
  241. }
  242.  
  243. const noXSS = (text) => {
  244. return text
  245. .replace(/&/g, '&amp;')
  246. .replace(/</g, '&lt;')
  247. .replace(/>/g, '&gt;')
  248. .replace(/"/g, '&quot;')
  249. .replace(/'/g, '&#039;');
  250. }
  251.  
  252. // generate random string
  253. const rdmString = (length) => {
  254. return [...Array(length)]
  255. .map(() => Math.random().toString(36).charAt(2))
  256. .join('');
  257. };
  258.  
  259. // --------- Colors --------- //
  260.  
  261. // rgba values to hex color code
  262. const RgbaToHex = (code) => {
  263. const rgbaValues = code.match(/\d+/g);
  264. const [r, g, b] = rgbaValues.slice(0, 3);
  265. return `#${Number(r).toString(16).padStart(2, '0')}${Number(g)
  266. .toString(16)
  267. .padStart(2, '0')}${Number(b).toString(16).padStart(2, '0')}`;
  268. }
  269.  
  270. const bytesToHex = (r, g, b) => {
  271. return (
  272. '#' + ((1 << 24) | (r << 16) | (g << 8) | b).toString(16).slice(1)
  273. );
  274. }
  275.  
  276. // --------- Game --------- //
  277.  
  278. const menuClosed = () => {
  279. const menuWrapper = byId('menu-wrapper');
  280.  
  281. return menuWrapper.style.display === 'none';
  282. }
  283.  
  284. const isDead = () => {
  285. const __line2 = byId('__line2');
  286. return !__line2.classList.contains('line--hidden');
  287. }
  288.  
  289. const getGameMode = () => {
  290. const gameMode = byId('gamemode');
  291. if (!gameMode.value) {
  292. return 'Tourney';
  293. }
  294. const options = Object.values(gameMode.querySelectorAll('option'));
  295. const selectedOption = options.filter(
  296. (option) => option.value === gameMode.value
  297. )[0];
  298. return selectedOption.textContent.split(' ')[0];
  299. }
  300.  
  301. function keypress(key, keycode) {
  302. const keyDownEvent = new KeyboardEvent('keydown', {
  303. key: key,
  304. code: keycode,
  305. });
  306. const keyUpEvent = new KeyboardEvent('keyup', {
  307. key: key,
  308. code: keycode,
  309. });
  310.  
  311. window.dispatchEvent(keyDownEvent);
  312. window.dispatchEvent(keyUpEvent);
  313. }
  314.  
  315. function mousemove(sx, sy) {
  316. const mouseMoveEvent = new MouseEvent('mousemove', {
  317. clientX: sx,
  318. clientY: sy,
  319. });
  320. const canvas = byId('canvas');
  321. canvas.dispatchEvent(mouseMoveEvent);
  322. }
  323.  
  324. const getCoordinates = (border, gridCount = 5) => {
  325. const { left, top, width, height } = border;
  326. const gridSize = width / gridCount;
  327. const coordinates = {};
  328.  
  329. for (let i = 0; i < gridCount; i++) {
  330. for (let j = 0; j < gridCount; j++) {
  331. const label = String.fromCharCode(65 + i) + (j + 1);
  332.  
  333. coordinates[label] = {
  334. min: { x: left + i * gridSize, y: top + j * gridSize },
  335. max: { x: left + (i + 1) * gridSize, y: top + (j + 1) * gridSize },
  336. };
  337. }
  338. }
  339.  
  340. return coordinates;
  341. };
  342.  
  343. // time formatters
  344. const prettyTime = {
  345. fullDate: (dateTimestamp, time = false) => {
  346. const date = new Date(dateTimestamp);
  347. const day = String(date.getDate()).padStart(2, '0');
  348. const month = String(date.getMonth() + 1).padStart(2, '0');
  349. const year = date.getFullYear();
  350. const formattedDate = `${day}.${month}.${year}`;
  351.  
  352. if (time) {
  353. const hours = String(date.getHours()).padStart(2, '0');
  354. const minutes = String(date.getMinutes()).padStart(2, '0');
  355. const seconds = String(date.getSeconds()).padStart(2, '0');
  356. return `${hours}:${minutes}:${seconds} ${formattedDate}`;
  357. }
  358.  
  359. return formattedDate;
  360. },
  361. am_pm: (date) => {
  362. if (!date) return '';
  363.  
  364. const d = new Date(date);
  365. const hours = d.getHours();
  366. const minutes = String(d.getMinutes()).padStart(2, '0');
  367. const ampm = hours >= 12 ? 'PM' : 'AM';
  368. const formattedHours = (hours % 12 || 12)
  369. .toString()
  370. .padStart(2, '0');
  371.  
  372. return `${formattedHours}:${minutes} ${ampm}`;
  373. },
  374. time_ago: (timestamp, isIso = false) => {
  375. if (!timestamp) return '';
  376. const currentTime = new Date();
  377. const elapsedTime = isIso
  378. ? currentTime - new Date(timestamp)
  379. : currentTime - timestamp;
  380.  
  381. const seconds = Math.floor(elapsedTime / 1000);
  382. const minutes = Math.floor(seconds / 60);
  383. const hours = Math.floor(minutes / 60);
  384. const days = Math.floor(hours / 24);
  385. const years = Math.floor(days / 365);
  386.  
  387. if (years > 0) {
  388. return years === 1 ? '1 year ago' : `${years} years ago`;
  389. } else if (days > 0) {
  390. return days === 1 ? '1 day ago' : `${days} days ago`;
  391. } else if (hours > 0) {
  392. return hours === 1 ? '1 hour ago' : `${hours} hours ago`;
  393. } else if (minutes > 0) {
  394. return minutes === 1
  395. ? '1 minute ago'
  396. : `${minutes} minutes ago`;
  397. } else {
  398. return seconds <= 1 ? '1s>' : `${seconds}s ago`;
  399. }
  400. },
  401. getTimeLeft(timestamp) {
  402. let totalSeconds = Math.max(0, Math.floor((timestamp - Date.now()) / 1000));
  403. const timeUnits = [['d', 86400], ['h', 3600], ['m', 60], ['s', 1]];
  404. let result = '';
  405.  
  406. for (const [unit, seconds] of timeUnits) {
  407. if (totalSeconds >= seconds) {
  408. const value = Math.floor(totalSeconds / seconds);
  409. totalSeconds %= seconds;
  410. result += `${value}${unit}`;
  411. }
  412. }
  413.  
  414. return result || '0s';
  415. }
  416. };
  417.  
  418. class Reader {
  419. constructor(view, offset, littleEndian) {
  420. this._e = littleEndian;
  421. if (view) this.repurpose(view, offset);
  422. }
  423.  
  424. repurpose(view, offset) {
  425. this.view = view;
  426. this._o = offset || 0;
  427. }
  428.  
  429. getUint8() {
  430. return this.view.getUint8(this._o++, this._e);
  431. }
  432.  
  433. getFloat64() {
  434. return this.view.getFloat64((this._o += 8) - 8, this._e);
  435. }
  436.  
  437. getStringUTF8(decode = true) {
  438. let bytes = [];
  439. let b;
  440. while ((b = this.view.getUint8(this._o++)) !== 0) bytes.push(b);
  441.  
  442. let uint8Array = new Uint8Array(bytes);
  443. let decoder = new TextDecoder('utf-8');
  444. let s = decoder.decode(uint8Array);
  445.  
  446. return decode ? s : uint8Array;
  447. }
  448.  
  449. raw(len = 0) {
  450. const buf = this.view.buffer.slice(this._o, this._o + len);
  451. this._o += len;
  452. return buf;
  453. }
  454. }
  455.  
  456. const __buf = new DataView(new ArrayBuffer(8));
  457.  
  458. class Writer {
  459. constructor(littleEndian) {
  460. this._e = littleEndian;
  461. this.reset();
  462. }
  463.  
  464. reset() {
  465. this._b = [];
  466. this._o = 0;
  467. }
  468.  
  469. setUint8(a) {
  470. if (a >= 0 && a < 256) this._b.push(a);
  471. return this;
  472. }
  473.  
  474. setUint32(a) {
  475. __buf.setUint32(0, a, this._e);
  476. this._move(4);
  477. return this;
  478. }
  479.  
  480. _move(b) {
  481. for (let i = 0; i < b; i++) this._b.push(__buf.getUint8(i));
  482. }
  483.  
  484. setStringUTF8(s) {
  485. const bytesStr = unescape(encodeURIComponent(s));
  486. for (let i = 0, l = bytesStr.length; i < l; i++) {
  487. this._b.push(bytesStr.charCodeAt(i));
  488. }
  489. this._b.push(0);
  490. return this;
  491. }
  492.  
  493. build() {
  494. return new Uint8Array(this._b);
  495. }
  496. }
  497.  
  498. // --------- END HELPER FUNCTIONS --------- //
  499.  
  500. let client = null;
  501. let freezepos = false;
  502.  
  503. // --------- Sigmally WebSocket Handler --------- //
  504. class SigWsHandler {
  505. constructor() {
  506. this.handshake = false;
  507. this.C = new Uint8Array(256);
  508. this.R = new Uint8Array(256);
  509.  
  510. this.overrideWebSocketSend();
  511. }
  512.  
  513. overrideWebSocketSend() {
  514. const handler = this;
  515.  
  516. window.WebSocket = new Proxy(window.WebSocket, {
  517. construct(target, args) {
  518. const wsInstance = new target(...args);
  519.  
  520. if (args[0].includes('sigmally.com')) {
  521. handler.setupWebSocket(wsInstance);
  522. }
  523.  
  524. return wsInstance;
  525. },
  526. });
  527. }
  528.  
  529. setupWebSocket(ws) {
  530. window.gameSettings.ws = ws;
  531.  
  532. // if 'save' is in localstorage, it indicates that you are logged in to Google; if that is the case, it
  533. // will load the client after the authorization to load the modClient correctly.
  534. // This loads the client instantly if you're not logged in to Google
  535. if (!localStorage.getItem('save') && !client) {
  536. client = new modClient();
  537. }
  538.  
  539. ws.addEventListener('close', () => this.handleWebSocketClose());
  540. ws.sendPacket = this.sendPacket.bind(this);
  541.  
  542. window.sendPlay = this.sendPlay.bind(this);
  543. window.sendChat = this.sendChat.bind(this);
  544. window.sendMouseMove = this.sendMouseMove.bind(this);
  545.  
  546. const originalSend = ws.send.bind(ws);
  547. ws.send = (data) => {
  548. try {
  549. const arrayBuffer =
  550. data instanceof ArrayBuffer ? data : data.buffer;
  551. const dataView = new DataView(arrayBuffer);
  552. const reader = new Reader(dataView, 0, true);
  553. const r = reader.getUint8();
  554.  
  555. if (this.R[r] === 0) {
  556. window.gameSettings.isPlaying = true;
  557. }
  558.  
  559. if (!window.sigfix && freezepos && this.R[r] === 16) {
  560. return;
  561. }
  562.  
  563. originalSend(data);
  564. } catch (e) {
  565. console.error(e);
  566. }
  567. };
  568.  
  569. ws.addEventListener('message', (event) =>
  570. this.handleMessage(event)
  571. );
  572. }
  573.  
  574. handleWebSocketClose() {
  575. this.handshake = false;
  576. window.gameSettings.isPlaying = false;
  577.  
  578. playerPosition.x = null;
  579. playerPosition.y = null;
  580. byId('mod-messages').innerHTML = '';
  581. setTimeout(mods.showOverlays, 500);
  582. }
  583.  
  584. sendPacket(packet) {
  585. if (!window.gameSettings.ws) {
  586. console.error('WebSocket is not defined.');
  587. return;
  588. }
  589.  
  590. if (packet.build)
  591. return window.gameSettings.ws.send(packet.build());
  592. window.gameSettings.ws.send(packet);
  593. }
  594.  
  595. sendPlay(playData) {
  596. const { sigfix } = window;
  597. if (sigfix) {
  598. sigfix.net.play(sigfix.world.selected, JSON.parse(playData));
  599. return;
  600. }
  601.  
  602. const writer = new Writer(true);
  603. writer.setUint8(this.C[0x00]);
  604. writer.setStringUTF8(playData);
  605. this.sendPacket(writer);
  606. }
  607.  
  608. sendChat(text) {
  609. if (mods.aboveRespawnLimit && text === mods.respawnCommand) return;
  610.  
  611. if (window.sigfix) {
  612. window.sigfix.net.chat(text);
  613. return;
  614. }
  615.  
  616. const writer = new Writer();
  617. writer.setUint8(this.C[0x63]);
  618. writer.setUint8(0);
  619. writer.setStringUTF8(text);
  620. this.sendPacket(writer);
  621. }
  622.  
  623. sendMouseMove(x, y) {
  624. const writer = new Writer(true);
  625. writer.setUint8(this.C[0x10]);
  626. writer.setUint32(x);
  627. writer.setUint32(y);
  628. writer._b.push(0, 0, 0, 0);
  629. this.sendPacket(writer);
  630. }
  631.  
  632. removePlayer(id) {
  633. const index = this.cells.players.indexOf(id);
  634. if (index !== -1) {
  635. this.cells.players.splice(index, 1);
  636. }
  637. }
  638.  
  639. handleMessage(event) {
  640. const reader = new Reader(new DataView(event.data), 0, true);
  641.  
  642. if (!this.handshake) {
  643. this.performHandshake(reader);
  644. return;
  645. }
  646.  
  647. const r = reader.getUint8();
  648. switch (this.R[r]) {
  649. case 0x63:
  650. this.handleChatMessage(reader);
  651. break;
  652. case 0x40:
  653. this.updateBorder(reader);
  654. break;
  655. }
  656. }
  657.  
  658. performHandshake(reader) {
  659. reader.getStringUTF8(false);
  660. this.C.set(new Uint8Array(reader.raw(256)));
  661.  
  662. for (const i in this.C) {
  663. this.R[this.C[i]] = ~~i;
  664. }
  665.  
  666. this.handshake = true;
  667. }
  668.  
  669. handleChatMessage(reader) {
  670. const flags = reader.getUint8();
  671. const [r, g, b] = [reader.getUint8(), reader.getUint8(), reader.getUint8()];
  672. const color = bytesToHex(r, g, b);
  673. let name = reader.getStringUTF8();
  674. const message = reader.getStringUTF8();
  675.  
  676. const server = Boolean(flags & 0x80);
  677. const admin = Boolean(flags & 0x40);
  678. const mod = Boolean(flags & 0x20);
  679.  
  680. name = this.formatName(name, server, admin, mod);
  681.  
  682. if (mods.mutedUsers.includes(name) || mods.spamMessage(name, message) || modSettings.chat.showClientChat)
  683. return;
  684.  
  685. mods.updateChat({
  686. server,
  687. admin,
  688. mod,
  689. color: modSettings.chat.showNameColors ? color : '#fafafa',
  690. name,
  691. message,
  692. time: modSettings.chat.showTime ? Date.now() : null,
  693. });
  694. }
  695.  
  696. formatName(name, server, admin, mod) {
  697. if (server && name !== 'SERVER') name = '[SERVER]';
  698. if (admin) name = '[ADMIN] ' + name;
  699. if (mod) name = '[MOD] ' + name;
  700. if (name === '') name = 'Unnamed';
  701. return name;
  702. }
  703.  
  704. updateBorder(reader) {
  705. mods.border.left = reader.getFloat64();
  706. mods.border.top = reader.getFloat64();
  707. mods.border.right = reader.getFloat64();
  708. mods.border.bottom = reader.getFloat64();
  709.  
  710. mods.border.width = mods.border.right - mods.border.left;
  711. mods.border.height = mods.border.bottom - mods.border.top;
  712. mods.border.centerX = (mods.border.left + mods.border.right) / 2;
  713. mods.border.centerY = (mods.border.top + mods.border.bottom) / 2;
  714. }
  715. }
  716.  
  717. class SigFixHandler {
  718. constructor() {
  719. this.lastHadCells = false;
  720.  
  721. this.checkInterval = null;
  722. this.updatePosInterval = null;
  723. this.init();
  724. }
  725.  
  726. overrideMoveFunction() {
  727. if (!window.sigfix?.net?.move) return;
  728.  
  729. const originalMove = window.sigfix.net.move;
  730. let isHandlingFreeze = false;
  731.  
  732. window.sigfix.net.move = (...args) => {
  733. if (freezepos) {
  734. if (!isHandlingFreeze) {
  735. isHandlingFreeze = true;
  736. originalMove.call(
  737. this,
  738. playerPosition.x,
  739. playerPosition.y
  740. );
  741. isHandlingFreeze = false;
  742. }
  743. return;
  744. }
  745. return originalMove.apply(this, args);
  746. };
  747. }
  748. updatePlayerPos() {
  749. let myName = '';
  750. let ownN = 0;
  751. let ownX = 0;
  752. let ownY = 0;
  753. let hadCells = this.lastHadCells ?? true;
  754.  
  755. const ownedCells = window.sigfix.world.views.get(window.sigfix.world.selected)?.owned || [];
  756.  
  757. ownedCells.forEach(id => {
  758. const cell = window.sigfix.world.cells.get(id)?.merged;
  759. if (!cell) return;
  760.  
  761. myName = cell.name || 'An unnamed cell';
  762. ++ownN;
  763. ownX += cell.nx;
  764. ownY += cell.ny;
  765. });
  766.  
  767. if (ownN > 0) {
  768. ownX /= ownN;
  769. ownY /= ownN;
  770.  
  771. playerPosition.x = ownX;
  772. playerPosition.y = ownY;
  773.  
  774. if (client?.ws?.readyState === 1 && modSettings.settings.tag) {
  775. client.send({
  776. type: 'position',
  777. content: {
  778. x: playerPosition.x,
  779. y: playerPosition.y,
  780. },
  781. });
  782. }
  783.  
  784. this.lastHadCells = true;
  785. } else if (hadCells) {
  786. if (client?.ws?.readyState === 1 && modSettings.settings.tag) {
  787. client.send({
  788. type: 'position',
  789. content: {
  790. x: null,
  791. y: null,
  792. },
  793. });
  794. }
  795. this.lastHadCells = false;
  796. }
  797. }
  798.  
  799. init() {
  800. const checkSigFix = () => {
  801. if (window.sigfix) {
  802. this.updatePosInterval = setInterval(this.updatePlayerPos, 300);
  803. }
  804. if (window.sigfix?.net) {
  805. this.overrideMoveFunction();
  806. clearInterval(this.checkInterval);
  807.  
  808. setTimeout(() => {
  809. if (window.sigfix?.net) {
  810. this.checkInterval = null;
  811. }
  812. }, 1000);
  813. }
  814. };
  815.  
  816. this.checkInterval = setInterval(checkSigFix, 100);
  817. }
  818. }
  819.  
  820. new SigFixHandler();
  821.  
  822. // --------- Mod Client --------- //
  823. class modClient {
  824. constructor() {
  825. this.ws = null;
  826. this.wsUrl = isDev
  827. ? `ws://localhost:${port}/ws`
  828. : 'wss://mod.czrsd.com/ws';
  829.  
  830. this.retries = 0;
  831. this.maxRetries = 4;
  832. this.updateAvailable = false;
  833.  
  834. this.id = null;
  835.  
  836. this.connect();
  837. }
  838.  
  839. connect() {
  840. this.ws = new WebSocket(this.wsUrl);
  841. this.ws.binaryType = 'arraybuffer';
  842.  
  843. this.ws.addEventListener('open', this.onOpen.bind(this));
  844. this.ws.addEventListener('close', this.onClose.bind(this));
  845. this.ws.addEventListener('message', this.onMessage.bind(this));
  846. this.ws.addEventListener('error', this.onError.bind(this));
  847. }
  848.  
  849. async onOpen() {
  850. await this.waitForDOMLoad();
  851.  
  852. this.updateClientInfo();
  853. this.updateTagInfo();
  854. }
  855.  
  856. waitForDOMLoad() {
  857. return new Promise((resolve) => setTimeout(resolve, 500));
  858. }
  859.  
  860. updateClientInfo() {
  861. this.send({
  862. type: 'server-changed',
  863. content: getGameMode(),
  864. });
  865. this.send({
  866. type: 'version',
  867. content: serverVersion,
  868. });
  869. }
  870.  
  871. updateTagInfo() {
  872. const tagElement = document.querySelector('#tag');
  873. const tagText = document.querySelector('.tagText');
  874. const tagValue = this.getTagFromUrl();
  875.  
  876. if (tagValue) {
  877. modSettings.settings.tag = tagValue;
  878. updateStorage();
  879. tagElement.value = tagValue;
  880. tagText.innerText = `Tag: ${tagValue}`;
  881. this.send({
  882. type: 'update-tag',
  883. content: modSettings.settings.tag,
  884. });
  885. } else if (modSettings.settings.tag) {
  886. tagElement.value = modSettings.settings.tag;
  887. tagText.innerText = `Tag: ${modSettings.settings.tag}`;
  888. this.send({
  889. type: 'update-tag',
  890. content: modSettings.settings.tag,
  891. });
  892. }
  893. }
  894.  
  895. getTagFromUrl() {
  896. const urlParams = new URLSearchParams(window.location.search);
  897. const tagValue = urlParams.get('tag');
  898. return tagValue ? tagValue.replace(/\/$/, '') : null;
  899. }
  900.  
  901. onClose() {
  902. if (this.updateAvailable) return;
  903.  
  904. this.retries++;
  905. if (this.retries > this.maxRetries)
  906. throw new Error('SigMod server down.');
  907.  
  908. setTimeout(() => this.connect(), 2000); // auto reconnect with delay
  909. }
  910.  
  911. onMessage(event) {
  912. const message = this.parseMessage(event.data);
  913. if (!message || !message.type) return;
  914.  
  915. switch (message.type) {
  916. case 'sid':
  917. this.handleSidMessage(message.content);
  918. break;
  919. case 'ping':
  920. this.handlePingMessage();
  921. break;
  922. case 'minimap-data':
  923. mods.updData(message.content);
  924. break;
  925. case 'chat-message':
  926. this.handleChatMessage(message.content);
  927. break;
  928. case 'private-message':
  929. mods.updatePrivateChat(message.content);
  930. break;
  931. case 'update-available':
  932. this.handleUpdateAvailable(message.content);
  933. break;
  934. case 'alert':
  935. mods.handleAlert(message.content);
  936. break;
  937. case 'tournament-preview':
  938. mods.tData = message.content;
  939. mods.showTournament(message.content);
  940. break;
  941. case 'tournament-message':
  942. mods.updateChat({
  943. name: '[TOURNAMENT]',
  944. message: message.content,
  945. time: modSettings.chat.showTime ? Date.now() : null,
  946. });
  947. break;
  948. case 'tournament-session':
  949. mods.tournamentSession(message.content);
  950. break;
  951. case 'get-score':
  952. mods.getScore(message.content);
  953. break;
  954. case 'round-end':
  955. mods.roundEnd(message.content);
  956. break;
  957. case 'round-ready':
  958. mods.tournamentReady(message.content);
  959. break;
  960. case 'tournament-data':
  961. mods.handleTournamentData(message.content);
  962. break;
  963. case 'error':
  964. mods.modAlert(message.content.message, 'danger');
  965. break;
  966. default:
  967. console.error('Unknown message type:', message.type);
  968. }
  969. }
  970.  
  971. onError(event) {
  972. console.error('WebSocket error:', event);
  973. }
  974.  
  975. send(data) {
  976. if (!data || this.ws.readyState !== 1) return;
  977. const binaryData = new TextEncoder().encode(JSON.stringify(data));
  978. this.ws.send(binaryData);
  979. }
  980.  
  981. parseMessage(data) {
  982. try {
  983. const stringData = new TextDecoder().decode(
  984. new Uint8Array(data)
  985. );
  986. return JSON.parse(stringData);
  987. } catch (error) {
  988. console.error('Failed to parse message:', error);
  989. return null;
  990. }
  991. }
  992.  
  993. handleSidMessage(content) {
  994. this.id = content;
  995. if (!modSettings.modAccount.authorized) return;
  996.  
  997. setTimeout(() => {
  998. mods.auth(content);
  999. }, 1000);
  1000. }
  1001.  
  1002. handlePingMessage() {
  1003. mods.ping.latency = Date.now() - mods.ping.start;
  1004. mods.ping.end = Date.now();
  1005. byId('clientPing').innerHTML = `Client Ping: ${mods.ping.latency}ms`;
  1006. }
  1007.  
  1008. handleChatMessage(content) {
  1009. if (!content) return;
  1010. let { admin, mod, vip, name, message, color } = content;
  1011.  
  1012. name = this.formatChatName(admin, mod, vip, name);
  1013.  
  1014. mods.updateChat({
  1015. admin,
  1016. mod,
  1017. color,
  1018. name,
  1019. message,
  1020. time: modSettings.chat.showTime ? Date.now() : null,
  1021. });
  1022. }
  1023.  
  1024. formatChatName(admin, mod, vip, name) {
  1025. if (admin) name = '[Owner] ' + name;
  1026. if (mod) name = '[Mod] ' + name;
  1027. if (vip) name = '[VIP] ' + name;
  1028. if (!name) name = 'Unnamed';
  1029. return name;
  1030. }
  1031.  
  1032. handleUpdateAvailable(content) {
  1033. byId('play-btn').setAttribute('disabled', 'disabled');
  1034. byId('spectate-btn').setAttribute('disabled', 'disabled');
  1035. this.updateAvailable = true;
  1036. this.createModAlert(content);
  1037. }
  1038.  
  1039. createModAlert(content) {
  1040. const modAlert = document.createElement('div');
  1041. modAlert.classList.add('modAlert');
  1042. modAlert.innerHTML = `
  1043. <span>You are using an old mod version. Please update.</span>
  1044. <div class="flex centerXY g-5">
  1045. <button
  1046. class="modButton"
  1047. style="width: 100%"
  1048. onclick="window.open('${content}')"
  1049. >Update</button>
  1050. </div>
  1051. `;
  1052. document.body.append(modAlert);
  1053. }
  1054. }
  1055.  
  1056. function randomPos() {
  1057. let eventOptions = {
  1058. clientX: Math.floor(Math.random() * window.innerWidth),
  1059. clientY: Math.floor(Math.random() * window.innerHeight),
  1060. bubbles: true,
  1061. cancelable: true,
  1062. };
  1063.  
  1064. let event = new MouseEvent('mousemove', eventOptions);
  1065.  
  1066. document.dispatchEvent(event);
  1067. }
  1068.  
  1069. let moveInterval = setInterval(randomPos);
  1070. setTimeout(() => clearInterval(moveInterval), 600);
  1071.  
  1072. // Disable chat before game settings actually load
  1073. localStorage.setItem('settings', JSON.stringify({ ...JSON.parse(localStorage.getItem('settings')), showChat: false }));
  1074.  
  1075. function addSettings() {
  1076. const gameSettings = document.querySelector('.checkbox-grid');
  1077. if (!gameSettings) return;
  1078.  
  1079. const div = document.createElement('div');
  1080. div.innerHTML = `
  1081. <input type="checkbox" id="showNames">
  1082. <label>Names</label>
  1083. <input type="checkbox" id="showSkins">
  1084. <label>Skins</label>
  1085. <input type="checkbox" id="autoRespawn">
  1086. <label>Auto Respawn</label>
  1087. <input type="checkbox" id="autoClaimCoins">
  1088. <label>Auto claim coins</label>
  1089. <input type="checkbox" id="showPosition">
  1090. <label>Position</label>
  1091. `;
  1092. while (div.children.length > 0) gameSettings.append(div.children[0]);
  1093. }
  1094. addSettings();
  1095.  
  1096. async function checkDiscordLogin() {
  1097. // popup window from discord login
  1098. const urlParams = new URLSearchParams(window.location.search);
  1099. let accessToken = urlParams.get('access_token');
  1100. let refreshToken = urlParams.get('refresh_token');
  1101.  
  1102. if (!accessToken || !refreshToken) return;
  1103.  
  1104. const url = isDev
  1105. ? `http://localhost:${port}/discord/login/`
  1106. : 'https://mod.czrsd.com/discord/login/';
  1107.  
  1108. const overlay = document.createElement('div');
  1109. overlay.style = `position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: #050505; display: flex; justify-content: center; align-items: center; z-index: 999999`;
  1110. overlay.innerHTML = `
  1111. <span style="font-size: 5rem; color: #fafafa;">Login...</span>
  1112. `;
  1113. document.body.append(overlay);
  1114.  
  1115. setTimeout(async () => {
  1116. if (refreshToken.endsWith('/')) {
  1117. refreshToken = refreshToken.substring(
  1118. 0,
  1119. refreshToken.length - 1
  1120. );
  1121. } else {
  1122. return;
  1123. }
  1124.  
  1125. await fetch(
  1126. `${url}?accessToken=${accessToken}&refreshToken=${refreshToken}`,
  1127. {
  1128. method: 'GET',
  1129. credentials: 'include',
  1130. }
  1131. );
  1132.  
  1133. modSettings.modAccount.authorized = true;
  1134. updateStorage();
  1135. window.close();
  1136. }, 500);
  1137. }
  1138. checkDiscordLogin();
  1139.  
  1140. let mods = {};
  1141.  
  1142. let playerPosition = { x: null, y: null };
  1143. let lastGetScore = 0;
  1144. let lastPosTime = 0;
  1145. let dead = false;
  1146. let dead2 = false;
  1147.  
  1148. function Mod() {
  1149. this.nick = null;
  1150. this.profile = {};
  1151. this.friends_settings = window.sigmod.friends_settings = {};
  1152. this.friend_names = window.sigmod.friend_names = new Set();
  1153.  
  1154. this.splitKey = {
  1155. keyCode: 32,
  1156. code: 'Space',
  1157. cancelable: true,
  1158. composed: true,
  1159. isTrusted: true,
  1160. which: 32,
  1161. };
  1162.  
  1163. this.ping = {
  1164. latency: NaN,
  1165. intervalId: null,
  1166. start: null,
  1167. end: null,
  1168. };
  1169.  
  1170. this.dayTimer = null;
  1171. this.challenges = [];
  1172.  
  1173. this.scrolling = false;
  1174. this.onContext = false;
  1175. this.mouseDown = false;
  1176.  
  1177. this.mouseX = 0;
  1178. this.mouseY = 0;
  1179.  
  1180. this.renderedMessages = 0;
  1181. this.maxChatMessages = 200;
  1182. this.mutedUsers = [];
  1183. this.blockedChatData = {
  1184. names: [],
  1185. messages: []
  1186. };
  1187.  
  1188. this.respawnCommand = '/leaveworld';
  1189. this.aboveRespawnLimit = false;
  1190. this.cellSize = 0;
  1191. this.miniMapData = [];
  1192. this.border = {};
  1193.  
  1194. this.dbCache = null;
  1195.  
  1196. this.tourneyPassword = '';
  1197. this.lastOneStanding = false;
  1198.  
  1199. this.skins = [];
  1200.  
  1201. this.virusImageLoaded = false;
  1202. this.skinImageLoaded = false;
  1203.  
  1204. this.routes = {
  1205. discord: {
  1206. auth: isDev
  1207. ? 'https://discord.com/oauth2/authorize?client_id=1067097357780516874&response_type=code&redirect_uri=http%3A%2F%2Flocalhost%3A3001%2Fdiscord%2Fcallback&scope=identify'
  1208. : 'https://discord.com/oauth2/authorize?client_id=1067097357780516874&response_type=code&redirect_uri=https%3A%2F%2Fmod.czrsd.com%2Fdiscord%2Fcallback&scope=identify',
  1209. },
  1210. };
  1211.  
  1212. // for SigMod specific
  1213. this.appRoutes = {
  1214. badge: isDev
  1215. ? `http://localhost:${port}/badge`
  1216. : 'https://mod.czrsd.com/badge',
  1217. signIn: (path) =>
  1218. isDev
  1219. ? `http://localhost:${port}/${path}`
  1220. : `https://mod.czrsd.com/${path}`,
  1221. auth: isDev
  1222. ? `http://localhost:${port}/auth`
  1223. : `https://mod.czrsd.com/auth`,
  1224. users: isDev
  1225. ? `http://localhost:${port}/users`
  1226. : `https://mod.czrsd.com/users`,
  1227. search: isDev
  1228. ? `http://localhost:${port}/search`
  1229. : `https://mod.czrsd.com/search`,
  1230. request: isDev
  1231. ? `http://localhost:${port}/request`
  1232. : `https://mod.czrsd.com/request`,
  1233. friends: isDev
  1234. ? `http://localhost:${port}/me/friends`
  1235. : `https://mod.czrsd.com/me/friends`,
  1236. profile: (id) =>
  1237. isDev
  1238. ? `http://localhost:${port}/profile/${id}`
  1239. : `https://mod.czrsd.com/profile/${id}`,
  1240. myRequests: isDev
  1241. ? `http://localhost:${port}/me/requests`
  1242. : `https://mod.czrsd.com/me/requests`,
  1243. handleRequest: isDev
  1244. ? `http://localhost:${port}/me/handle`
  1245. : `https://mod.czrsd.com/me/handle`,
  1246. logout: isDev
  1247. ? `http://localhost:${port}/logout`
  1248. : `https://mod.czrsd.com/logout`,
  1249. imgUpload: isDev
  1250. ? `http://localhost:${port}/me/upload`
  1251. : `https://mod.czrsd.com/me/upload`,
  1252. removeAvatar: isDev
  1253. ? `http://localhost:${port}/me/handle`
  1254. : `https://mod.czrsd.com/me/handle`,
  1255. editProfile: isDev
  1256. ? `http://localhost:${port}/me/edit`
  1257. : `https://mod.czrsd.com/me/edit`,
  1258. delProfile: isDev
  1259. ? `http://localhost:${port}/me/remove`
  1260. : `https://mod.czrsd.com/me/remove`,
  1261. updateSettings: isDev
  1262. ? `http://localhost:${port}/me/update-settings`
  1263. : `https://mod.czrsd.com/me/update-settings`,
  1264. chatHistory: (id) =>
  1265. isDev
  1266. ? `http://localhost:${port}/me/chat/${id}`
  1267. : `https://mod.czrsd.com/me/chat/${id}`,
  1268. onlineUsers: isDev
  1269. ? `http://localhost:${port}/onlineUsers`
  1270. : `https://mod.czrsd.com/onlineUsers`,
  1271. announcements: isDev
  1272. ? `http://localhost:${port}/announcements`
  1273. : `https://mod.czrsd.com/announcements`,
  1274. announcement: (id) =>
  1275. isDev
  1276. ? `http://localhost:${port}/announcement/${id}`
  1277. : `https://mod.czrsd.com/announcement/${id}`,
  1278. fonts: isDev
  1279. ? `http://localhost:${port}/fonts`
  1280. : 'https://mod.czrsd.com/fonts',
  1281. blockedChatData: 'https://mod.czrsd.com/spam.json',
  1282. };
  1283.  
  1284. this.init();
  1285. }
  1286.  
  1287. Mod.prototype = {
  1288. get style() {
  1289. return `
  1290. @import url('https://fonts.googleapis.com/css2?family=Titillium+Web:wght@400;600;700&display=swap');
  1291.  
  1292. .mod_menu {
  1293. position: absolute;
  1294. top: 0;
  1295. left: 0;
  1296. width: 100%;
  1297. height: 100vh;
  1298. background: rgba(0, 0, 0, .6);
  1299. z-index: 999999;
  1300. display: flex;
  1301. justify-content: center;
  1302. align-items: center;
  1303. color: #fff;
  1304. transition: all .3s ease;
  1305. }
  1306.  
  1307. .mod_menu * {
  1308. margin: 0;
  1309. padding: 0;
  1310. font-family: 'Ubuntu';
  1311. box-sizing: border-box;
  1312. }
  1313.  
  1314. .mod_menu_wrapper {
  1315. position: relative;
  1316. display: flex;
  1317. flex-direction: column;
  1318. width: 700px;
  1319. height: 500px;
  1320. background: #111;
  1321. border-radius: 12px;
  1322. overflow: hidden;
  1323. box-shadow: 0 5px 10px #000;
  1324. }
  1325.  
  1326. .mod_menu_header {
  1327. display: flex;
  1328. width: 100%;
  1329. position: relative;
  1330. height: 60px;
  1331. }
  1332.  
  1333. .mod_menu_header .header_img {
  1334. width: 100%;
  1335. height: 60px;
  1336. object-fit: cover;
  1337. object-position: center;
  1338. position: absolute;
  1339. }
  1340.  
  1341. .mod_menu_header button {
  1342. display: flex;
  1343. justify-content: center;
  1344. align-items: center;
  1345. position: absolute;
  1346. right: 10px;
  1347. top: 30px;
  1348. background: rgba(11, 11, 11, .7);
  1349. width: 42px;
  1350. height: 42px;
  1351. font-size: 16px;
  1352. transform: translateY(-50%);
  1353. }
  1354.  
  1355. .mod_menu_header button:hover {
  1356. background: rgba(11, 11, 11, .5);
  1357. }
  1358.  
  1359. .mod_menu_inner {
  1360. display: flex;
  1361. }
  1362.  
  1363. .mod_menu_navbar {
  1364. display: flex;
  1365. flex-direction: column;
  1366. gap: 10px;
  1367. min-width: 132px;
  1368. padding: 10px;
  1369. background: #181818;
  1370. height: 440px;
  1371. }
  1372.  
  1373. .mod_nav_btn, .modButton-black {
  1374. display: flex;
  1375. justify-content: space-evenly;
  1376. align-items: center;
  1377. padding: 5px;
  1378. background: #050505;
  1379. border-radius: 8px;
  1380. font-size: 16px;
  1381. border: 1px solid transparent;
  1382. outline: none;
  1383. width: 100%;
  1384. transition: all .3s ease;
  1385. }
  1386. label.modButton-black {
  1387. font-weight: 400;
  1388. cursor: pointer;
  1389. }
  1390.  
  1391. .modButton-black[disabled] {
  1392. background: #333;
  1393. cursor: default;
  1394. }
  1395.  
  1396. .mod_selected {
  1397. border: 1px solid rgba(89, 89, 89, .9);
  1398. }
  1399.  
  1400. .mod_nav_btn img {
  1401. width: 22px;
  1402. }
  1403.  
  1404. .mod_menu_content {
  1405. width: 100%;
  1406. padding: 10px;
  1407. position: relative;
  1408. max-width: 568px;
  1409. }
  1410.  
  1411. .mod_tab {
  1412. width: 100%;
  1413. height: 100%;
  1414. display: flex;
  1415. flex-direction: column;
  1416. gap: 5px;
  1417. overflow-y: auto;
  1418. overflow-x: hidden;
  1419. max-height: 420px;
  1420. opacity: 1;
  1421. transition: all .2s ease;
  1422. }
  1423. .modColItems {
  1424. display: flex;
  1425. flex-direction: column;
  1426. align-items: center;
  1427. gap: 15px;
  1428. width: 100%;
  1429. }
  1430.  
  1431. .modColItems_2 {
  1432. display: flex;
  1433. flex-direction: column;
  1434. align-items: start;
  1435. justify-content: start;
  1436. background: #050505;
  1437. gap: 8px;
  1438. border-radius: 0.5rem;
  1439. padding: 10px;
  1440. width: 100%;
  1441. }
  1442.  
  1443. .modRowItems {
  1444. display: flex;
  1445. justify-content: center;
  1446. align-items: center;
  1447. background: #050505;
  1448. gap: 58px;
  1449. border-radius: 0.5rem;
  1450. padding: 10px;
  1451. width: 100%;
  1452. }
  1453.  
  1454. .form-control {
  1455. border-width: 1px;
  1456. }
  1457. .form-control.error-border {
  1458. border-color: #AC3D3D;
  1459. }
  1460.  
  1461. .modSlider {
  1462. --thumb-color: #d9d9d9;
  1463. -webkit-appearance: none;
  1464. appearance: none;
  1465. width: 100%;
  1466. height: 8px;
  1467. background: #333;
  1468. border-radius: 5px;
  1469. outline: none;
  1470. transition: all 0.3s ease;
  1471. }
  1472.  
  1473. .modSlider::-webkit-slider-thumb {
  1474. -webkit-appearance: none;
  1475. appearance: none;
  1476. width: 20px;
  1477. height: 20px;
  1478. border-radius: 50%;
  1479. background: var(--thumb-color);
  1480. }
  1481.  
  1482. .modSlider::-moz-range-thumb {
  1483. width: 20px;
  1484. height: 20px;
  1485. border-radius: 50%;
  1486. background: var(--thumb-color);
  1487. }
  1488.  
  1489. .modSlider::-ms-thumb {
  1490. width: 20px;
  1491. height: 20px;
  1492. border-radius: 50%;
  1493. background: var(--thumb-color);
  1494. }
  1495.  
  1496. input:focus, select:focus, button:focus{
  1497. outline: none;
  1498. }
  1499. .macros_wrapper {
  1500. display: flex;
  1501. width: 100%;
  1502. justify-content: center;
  1503. flex-direction: column;
  1504. gap: 10px;
  1505. background: #050505;
  1506. padding: 10px;
  1507. border-radius: 0.75rem;
  1508. }
  1509. .macrosContainer {
  1510. display: flex;
  1511. width: 100%;
  1512. justify-content: center;
  1513. align-items: center;
  1514. gap: 20px;
  1515. }
  1516. .macroRow {
  1517. background: #121212;
  1518. border-radius: 5px;
  1519. padding: 7px;
  1520. display: flex;
  1521. justify-content: space-between;
  1522. align-items: center;
  1523. gap: 10px;
  1524. }
  1525. .keybinding {
  1526. border-radius: 5px;
  1527. background: #242424;
  1528. border: none;
  1529. color: #fff;
  1530. padding: 2px 5px;
  1531. max-width: 50px;
  1532. font-weight: 500;
  1533. text-align: center;
  1534. }
  1535. .closeBtn{
  1536. width: 46px;
  1537. background-color: transparent;
  1538. display: flex;
  1539. justify-content: center;
  1540. align-items: center;
  1541. }
  1542. .select-btn {
  1543. padding: 15px 20px;
  1544. background: #222;
  1545. border-radius: 2px;
  1546. position: relative;
  1547. }
  1548.  
  1549. .select-btn:active {
  1550. scale: 0.95
  1551. }
  1552.  
  1553. .select-btn::before {
  1554. content: "...";
  1555. font-size: 20px;
  1556. color: #fff;
  1557. position: absolute;
  1558. top: 50%;
  1559. left: 50%;
  1560. transform: translate(-50%, -50%);
  1561. }
  1562. .text {
  1563. user-select: none;
  1564. font-weight: 500;
  1565. text-align: left;
  1566. }
  1567. .modButton {
  1568. background-color: #252525;
  1569. border-radius: 4px;
  1570. color: #fff;
  1571. transition: all .3s;
  1572. outline: none;
  1573. padding: 7px;
  1574. font-size: 13px;
  1575. border: none;
  1576. }
  1577. .modButton:hover {
  1578. background-color: #222
  1579. }
  1580. .modInput {
  1581. background-color: #111;
  1582. border: none;
  1583. border-radius: 5px;
  1584. position: relative;
  1585. border-top-right-radius: 4px;
  1586. border-top-left-radius: 4px;
  1587. font-weight: 500;
  1588. padding: 5px;
  1589. color: #fff;
  1590. }
  1591. .modNumberInput:disabled {
  1592. color: #777;
  1593. }
  1594.  
  1595. .modCheckbox input[type="checkbox"] {
  1596. display: none;
  1597. visibility: hidden;
  1598. }
  1599. .modCheckbox label {
  1600. display: inline-block;
  1601. }
  1602.  
  1603. .modCheckbox .cbx {
  1604. position: relative;
  1605. top: 1px;
  1606. width: 17px;
  1607. height: 17px;
  1608. margin: 2px;
  1609. border: 1px solid #c8ccd4;
  1610. border-radius: 3px;
  1611. vertical-align: middle;
  1612. transition: background 0.1s ease;
  1613. cursor: pointer;
  1614. }
  1615.  
  1616. .modCheckbox .cbx:after {
  1617. content: '';
  1618. position: absolute;
  1619. top: 1px;
  1620. left: 5px;
  1621. width: 5px;
  1622. height: 11px;
  1623. opacity: 0;
  1624. transform: rotate(45deg) scale(0);
  1625. border-right: 2px solid #fff;
  1626. border-bottom: 2px solid #fff;
  1627. transition: all 0.3s ease;
  1628. transition-delay: 0.15s;
  1629. }
  1630.  
  1631. .modCheckbox input[type="checkbox"]:checked ~ .cbx {
  1632. border-color: transparent;
  1633. background: #6871f1;
  1634. box-shadow: 0 0 10px #2E2D80;
  1635. }
  1636.  
  1637. .modCheckbox input[type="checkbox"]:checked ~ .cbx:after {
  1638. opacity: 1;
  1639. transform: rotate(45deg) scale(1);
  1640. }
  1641.  
  1642. .SettingsButton{
  1643. border: none;
  1644. outline: none;
  1645. margin-right: 10px;
  1646. transition: all .3s ease;
  1647. }
  1648. .SettingsButton:hover {
  1649. scale: 1.1;
  1650. }
  1651. .colorInput{
  1652. background-color: transparent;
  1653. width: 31px;
  1654. height: 35px;
  1655. border-radius: 50%;
  1656. border: none;
  1657. }
  1658. .colorInput::-webkit-color-swatch {
  1659. border-radius: 50%;
  1660. border: 2px solid #fff;
  1661. }
  1662. .whiteBorder_colorInput::-webkit-color-swatch {
  1663. border-color: #fff;
  1664. }
  1665. .menu-center>div>.menu-center-content>div>div>.menu__form-group {
  1666. margin-bottom: 14px !important;
  1667. }
  1668. #dclinkdiv {
  1669. display: flex;
  1670. flex-direction: row;
  1671. margin-top: 10px;
  1672. }
  1673. .dclinks {
  1674. width: calc(50% - 5px);
  1675. height: 36px;
  1676. display: flex;
  1677. justify-content: center;
  1678. align-items: center;
  1679. background-color: rgba(88, 101, 242, 1);
  1680. border-radius: 6px;
  1681. margin: 0 auto;
  1682. color: #fff;
  1683. }
  1684. #cm_close__settings {
  1685. width: 50px;
  1686. transition: all .3s ease;
  1687. }
  1688. #cm_close__settings svg:hover {
  1689. scale: 1.1;
  1690. }
  1691. #cm_close__settings svg {
  1692. transition: all .3s ease;
  1693. }
  1694. .modTitleText {
  1695. text-align: center;
  1696. font-size: 16px;
  1697. }
  1698. .modItem {
  1699. display: flex;
  1700. justify-content: center;
  1701. align-items: center;
  1702. flex-direction: column;
  1703. }
  1704. .accent_row {
  1705. background: #111111;
  1706. }
  1707. .mod_tab-content {
  1708. width: 100%;
  1709. margin: 10px;
  1710. overflow: auto;
  1711. display: flex;
  1712. flex-direction: column;
  1713. }
  1714.  
  1715. #Tab6 .mod_tab-content {
  1716. overflow-y: auto;
  1717. max-height: 230px;
  1718. display: flex;
  1719. flex-wrap: nowrap;
  1720. flex-direction: column;
  1721. gap: 10px;
  1722. }
  1723.  
  1724. .tab-content, #coins-tab, #chests-tab {
  1725. overflow-x: hidden;
  1726. justify-content: center;
  1727. }
  1728.  
  1729. #shop-skins-buttons::after {
  1730. background: #050505;
  1731. }
  1732.  
  1733. #sigma-status {
  1734. background: rgba(0, 0, 0, .6) !important;
  1735. }
  1736.  
  1737. .w-100 {
  1738. width: 100%
  1739. }
  1740. .btn:hover {
  1741. color: unset;
  1742. }
  1743.  
  1744. #savedNames {
  1745. background-color: #000;
  1746. padding: 5px;
  1747. border-radius: 5px;
  1748. overflow-y: auto;
  1749. height: 155px;
  1750. background-image: url("https://raw.githubusercontent.com/Sigmally/SigMod/main/images/purple_gradient.png");
  1751. background-size: cover;
  1752. background-position: center;
  1753. background-repeat: no-repeat;
  1754. box-shadow: 0 0 10px #000;
  1755. }
  1756.  
  1757. .scroll {
  1758. scroll-behavior: smooth;
  1759. }
  1760.  
  1761. /* Chrome, Safari */
  1762. .scroll::-webkit-scrollbar {
  1763. width: 7px;
  1764. }
  1765.  
  1766. .scroll::-webkit-scrollbar-track {
  1767. background: #222;
  1768. border-radius: 5px;
  1769. }
  1770.  
  1771. .scroll::-webkit-scrollbar-thumb {
  1772. background-color: #333;
  1773. border-radius: 5px;
  1774. }
  1775.  
  1776. .scroll::-webkit-scrollbar-thumb:hover {
  1777. background: #353535;
  1778. }
  1779.  
  1780. /* Firefox */
  1781. .scroll {
  1782. scrollbar-width: thin;
  1783. scrollbar-color: #333 #222;
  1784. }
  1785.  
  1786. .scroll:hover {
  1787. scrollbar-color: #353535 #222;
  1788. }
  1789.  
  1790. .themes {
  1791. display: flex;
  1792. flex-direction: row;
  1793. flex: 1;
  1794. flex-wrap: wrap;
  1795. justify-content: center;
  1796. width: 100%;
  1797. min-height: 254px;
  1798. max-height: 420px;
  1799. background: #000;
  1800. border-radius: 5px;
  1801. overflow-y: scroll;
  1802. gap: 10px;
  1803. padding: 5px;
  1804. }
  1805.  
  1806. .themeContent {
  1807. width: 50px;
  1808. height: 50px;
  1809. border: 2px solid #222;
  1810. border-radius: 50%;
  1811. background-position: center;
  1812. }
  1813.  
  1814. .theme {
  1815. height: 75px;
  1816. display: flex;
  1817. align-items: center;
  1818. justify-content: center;
  1819. flex-direction: column;
  1820. cursor: pointer;
  1821. }
  1822. .delName {
  1823. font-weight: 500;
  1824. background: #e17e7e;
  1825. height: 20px;
  1826. border: none;
  1827. border-radius: 5px;
  1828. font-size: 10px;
  1829. margin-left: 5px;
  1830. color: #fff;
  1831. display: flex;
  1832. justify-content: center;
  1833. align-items: center;
  1834. width: 20px;
  1835. }
  1836. .NameDiv {
  1837. display: flex;
  1838. background: #111;
  1839. border-radius: 5px;
  1840. margin: 5px;
  1841. padding: 3px 8px;
  1842. height: 34px;
  1843. align-items: center;
  1844. justify-content: space-between;
  1845. cursor: pointer;
  1846. box-shadow: 0 5px 10px -2px #000;
  1847. }
  1848. .NameLabel {
  1849. cursor: pointer;
  1850. font-weight: 500;
  1851. text-align: center;
  1852. color: #fff;
  1853. }
  1854. .alwan {
  1855. border-radius: 8px;
  1856. }
  1857. .colorpicker-additional {
  1858. display: flex;
  1859. justify-content: space-between;
  1860. width: 100%;
  1861. color: #fafafa;
  1862. padding: 10px;
  1863. }
  1864. .resetButton {
  1865. width: 25px;
  1866. height: 25px;
  1867. background-image: url("https://raw.githubusercontent.com/Sigmally/SigMod/main/images/reset.svg");
  1868. background-color: transparent;
  1869. background-repeat: no-repeat;
  1870. border: none;
  1871. }
  1872.  
  1873. .modAlert {
  1874. position: fixed;
  1875. top: 8%;
  1876. left: 50%;
  1877. transform: translate(-50%, -50%);
  1878. z-index: 99995;
  1879. background: #3F3F3F;
  1880. border-radius: 10px;
  1881. display: flex;
  1882. flex-direction: column;
  1883. gap: 5px;
  1884. padding: 10px;
  1885. color: #fff;
  1886. max-width: 320px;
  1887. }
  1888.  
  1889. .alert_overlay {
  1890. position: absolute;
  1891. top: 0;
  1892. left: 0;
  1893. z-index: 999999999;
  1894. pointer-events: none;
  1895. width: 100%;
  1896. height: 100vh;
  1897. display: flex;
  1898. flex-direction: column;
  1899. justify-content: start;
  1900. align-items: center;
  1901. }
  1902.  
  1903. .infoAlert {
  1904. padding: 5px;
  1905. border-radius: 5px;
  1906. margin-top: 5px;
  1907. color: #fff;
  1908. }
  1909.  
  1910. .modAlert-success {
  1911. background: #5BA55C;
  1912. }
  1913. .modAlert-success .modAlert-loader {
  1914. background: #6BD56D;
  1915. }
  1916. .modAlert-default {
  1917. background: #151515;
  1918. }
  1919. .modAlert-default .modAlert-loader {
  1920. background: #222;
  1921. }
  1922. .modAlert-danger {
  1923. background: #D44121;
  1924. }
  1925. .modAlert-danger .modAlert-loader {
  1926. background: #A5361E;
  1927. }
  1928. #free-coins .modAlert-danger {
  1929. background: #fff !important;
  1930. }
  1931.  
  1932. .modAlert-loader {
  1933. width: 100%;
  1934. height: 2px;
  1935. margin-top: 5px;
  1936. transition: all .3s ease-in-out;
  1937. animation: loadAlert 2s forwards;
  1938. }
  1939.  
  1940. @keyframes loadAlert {
  1941. 0% {
  1942. width: 100%;
  1943. }
  1944. 100% {
  1945. width: 0%;
  1946. }
  1947. }
  1948.  
  1949. .themeEditor {
  1950. z-index: 999999999999;
  1951. position: absolute;
  1952. top: 50%;
  1953. left: 50%;
  1954. transform: translate(-50%, -50%);
  1955. background: rgba(0, 0, 0, .85);
  1956. color: #fff;
  1957. padding: 10px;
  1958. border-radius: 10px;
  1959. box-shadow: 0 0 10px #000;
  1960. width: 400px;
  1961. }
  1962.  
  1963. .theme_editor_header {
  1964. display: flex;
  1965. justify-content: space-between;
  1966. align-items: center;
  1967. gap: 10px;
  1968. }
  1969.  
  1970. .theme-editor-tab {
  1971. display: flex;
  1972. justify-content: center;
  1973. align-items: start;
  1974. flex-direction: column;
  1975. margin-top: 10px
  1976. }
  1977.  
  1978. .themes_preview {
  1979. width: 50px;
  1980. height: 50px;
  1981. border: 2px solid #fff;
  1982. border-radius: 2px;
  1983. display: flex;
  1984. justify-content: center;
  1985. align-items: center;
  1986. }
  1987.  
  1988. .sigmod-title {
  1989. display: flex;
  1990. flex-direction: column;
  1991. align-items: center;
  1992. gap: 2px;
  1993. }
  1994. .sigmod-title #title {
  1995. width: fit-content;
  1996. }
  1997. #bycursed {
  1998. font-family: "Titillium Web", sans-serif;
  1999. font-weight: 400;
  2000. font-size: 16px;
  2001. }
  2002. #bycursed a {
  2003. color: #71aee3;
  2004. }
  2005. .stats__item>span, #title, .stats-btn__text {
  2006. color: #fff;
  2007. }
  2008.  
  2009. .top-users__inner::-webkit-scrollbar-thumb {
  2010. border: none;
  2011. }
  2012. #signInBtn, #nick, #gamemode, .form-control, .profile-header, .coins-num, #clan-members, .member-index, .member-level, #clan-requests {
  2013. background: rgba(0, 0, 0, 0.4) !important;
  2014. color: #fff !important;
  2015. }
  2016. .profile-name, #progress-next, .member-desc > p:first-child, #clan-leave > div, .clans-item > div > b, #clans-input input, #shop-nav button {
  2017. color: #fff !important;
  2018. }
  2019. .head-desc, #shop-nav button {
  2020. border: 1px solid #000;
  2021. }
  2022. #shop-nav button {
  2023. transition: background .1s ease;
  2024. }
  2025. #shop-nav button:hover {
  2026. background: #121212 !important;
  2027. }
  2028. #clan-handler, #request-handler, #clans-list, #clans-input, .clans-item button, #shop-content, .card-particles-bar-bg {
  2029. background: #111 !important;
  2030. color: #fff !important;
  2031. }
  2032. #clans_and_settings {
  2033. height: auto !important;
  2034. }
  2035. .card-body {
  2036. background: linear-gradient(180deg, #000 0%, #1b354c 100%);
  2037. }
  2038. .free-card:hover .card-body {
  2039. background: linear-gradient(180deg, #111 0%, #1b354c 100%);
  2040. }
  2041. #shop-tab-body, #shop-nav, #shop-skins-buttons {
  2042. background: #050505 !important;
  2043. }
  2044. #clan-leave {
  2045. background: #111;
  2046. bottom: -1px;
  2047. }
  2048. .sent {
  2049. position: relative;
  2050. width: 100px;
  2051. }
  2052.  
  2053. .sent::before {
  2054. content: "Sent request";
  2055. width: 100%;
  2056. height: 10px;
  2057. word-spacing: normal;
  2058. white-space: nowrap;
  2059. position: absolute;
  2060. background: #4f79f9;
  2061. display: flex;
  2062. justify-content: center;
  2063. align-items: center;
  2064. }
  2065.  
  2066. .btn, .sign-in-out-btn {
  2067. transition: all .2s ease;
  2068. }
  2069. .free-coins-body > div, .goldmodal-contain {
  2070. background: rgba(0, 0, 0, .5);
  2071. }
  2072. #clan .connecting__content, #clans .connecting__content {
  2073. background: #151515;
  2074. color: #fff;
  2075. box-shadow: 0 0 10px rgba(0, 0, 0, .5);
  2076. }
  2077.  
  2078. .skin-select__icon-text {
  2079. color: #fff;
  2080. }
  2081.  
  2082. .justify-sb {
  2083. display: flex;
  2084. align-items: center;
  2085. justify-content: space-between;
  2086. }
  2087.  
  2088. .macro-extanded_input {
  2089. width: 75px;
  2090. text-align: center;
  2091. }
  2092. .form-control option {
  2093. background: #111;
  2094. }
  2095.  
  2096. .stats-line {
  2097. width: 100%;
  2098. user-select: none;
  2099. margin-bottom: 5px;
  2100. padding: 5px;
  2101. background: #050505;
  2102. border: 1px solid var(--default-mod);
  2103. border-radius: 5px;
  2104. }
  2105.  
  2106. .stats-info-text {
  2107. color: #7d7d7d;
  2108. }
  2109.  
  2110. .setting-card-wrapper {
  2111. margin-right: 10px;
  2112. padding: 10px;
  2113. background: #161616;
  2114. border-radius: 5px;
  2115. display: flex;
  2116. flex-direction: column;
  2117. width: 100%;
  2118. }
  2119.  
  2120. .setting-card {
  2121. display: flex;
  2122. align-items: center;
  2123. justify-content: space-between;
  2124. }
  2125.  
  2126. .setting-card-action {
  2127. display: flex;
  2128. align-items: center;
  2129. gap: 5px;
  2130. cursor: pointer;
  2131. }
  2132.  
  2133. .setting-card-action {
  2134. width: 100%;
  2135. }
  2136.  
  2137. .setting-card-name {
  2138. font-size: 16px;
  2139. user-select: none;
  2140. width: 100%;
  2141. }
  2142.  
  2143. .mod-small-modal {
  2144. display: flex;
  2145. flex-direction: column;
  2146. gap: 10px;
  2147. position: absolute;
  2148. z-index: 99999;
  2149. top: 50%;
  2150. left: 50%;
  2151. transform: translate(-50%, -50%);
  2152. background: #191919;
  2153. box-shadow: 0 5px 15px -2px #000;
  2154. padding: 10px;
  2155. border-radius: 5px;
  2156. }
  2157.  
  2158. .mod-small-modal-header {
  2159. display: flex;
  2160. justify-content: space-between;
  2161. align-items: center;
  2162. }
  2163.  
  2164. .mod-small-modal-header h1 {
  2165. font-size: 20px;
  2166. font-weight: 500;
  2167. margin: 0;
  2168. }
  2169.  
  2170. .mod-small-modal-content {
  2171. display: flex;
  2172. flex-direction: column;
  2173. width: 100%;
  2174. align-items: center;
  2175. }
  2176.  
  2177. .mod-small-modal-content_selectImage {
  2178. display: flex;
  2179. flex-direction: column;
  2180. gap: 10px;
  2181. }
  2182.  
  2183. .imagePreview {
  2184. min-width: 34px;
  2185. width: 34px;
  2186. height: 34px;
  2187. border: 2px solid #353535;
  2188. border-radius: 5px;
  2189. background-size: contain;
  2190. background-repeat: no-repeat;
  2191. background-position: center;
  2192.  
  2193. /* for preview text */
  2194. display: flex;
  2195. justify-content: center;
  2196. align-items: center;
  2197. font-size: 7px;
  2198. overflow: hidden;
  2199. text-align: center;
  2200. }
  2201.  
  2202. .modChat {
  2203. min-width: 450px;
  2204. max-width: 450px;
  2205. min-height: 285px;
  2206. max-height: 285px;
  2207. color: #fafafa;
  2208. padding: 10px;
  2209. position: absolute;
  2210. bottom: 10px;
  2211. left: 10px;
  2212. z-index: 999;
  2213. border-radius: .5rem;
  2214. overflow: hidden;
  2215. opacity: 1;
  2216. transition: all .3s ease;
  2217. }
  2218.  
  2219. .modChat__inner {
  2220. min-width: 430px;
  2221. max-width: 430px;
  2222. min-height: 265px;
  2223. max-height: 265px;
  2224. height: 100%;
  2225. display: flex;
  2226. flex-direction: column;
  2227. gap: 5px;
  2228. justify-content: flex-end;
  2229. opacity: 1;
  2230. transition: all .3s ease;
  2231. }
  2232.  
  2233. .mod-compact {
  2234. transform: scale(0.78);
  2235. }
  2236. .mod-compact.modChat {
  2237. left: -40px;
  2238. bottom: -20px;
  2239. }
  2240. .mod-compact.chatAddedContainer {
  2241. left: 350px;
  2242. bottom: -17px;
  2243. }
  2244.  
  2245. #scroll-down-btn {
  2246. position: absolute;
  2247. bottom: 60px;
  2248. left: 50%;
  2249. transform: translateX(-50%);
  2250. width: 80px;
  2251. display:none;
  2252. box-shadow:0 0 5px #000;
  2253. z-index: 5;
  2254. }
  2255.  
  2256. .modchat-chatbuttons {
  2257. margin-bottom: auto;
  2258. display: flex;
  2259. gap: 5px;
  2260. }
  2261.  
  2262. .chat-context {
  2263. position: absolute;
  2264. z-index: 999999;
  2265. width: 100px;
  2266. display: flex;
  2267. flex-direction: column;
  2268. justify-content: center;
  2269. align-items: center;
  2270. gap: 5px;
  2271. background: #181818;
  2272. border-radius: 5px;
  2273. }
  2274.  
  2275. .chat-context span {
  2276. color: #fff;
  2277. user-select: none;
  2278. padding: 5px;
  2279. white-space: nowrap;
  2280. }
  2281.  
  2282. .chat-context button {
  2283. width: 100%;
  2284. background-color: transparent;
  2285. border: none;
  2286. border-top: 2px solid #747474;
  2287. outline: none;
  2288. color: #fff;
  2289. transition: all .3s ease;
  2290. }
  2291.  
  2292. .chat-context button:hover {
  2293. backgrokund-color: #222;
  2294. }
  2295.  
  2296. .tagText {
  2297. margin-left: auto;
  2298. font-size: 14px;
  2299. }
  2300.  
  2301. #mod-messages {
  2302. position: relative;
  2303. display: flex;
  2304. flex-direction: column;
  2305. max-height: 185px;
  2306. overflow-y: auto;
  2307. direction: rtl;
  2308. scroll-behavior: smooth;
  2309. }
  2310. .message {
  2311. direction: ltr;
  2312. margin: 2px 0 0 5px;
  2313. text-overflow: ellipsis;
  2314. white-space: nowrap;
  2315. max-width: 100%;
  2316. display: flex;
  2317. justify-content: space-between;
  2318. align-items: center;
  2319. }
  2320.  
  2321. .message_name {
  2322. user-select: none;
  2323. }
  2324.  
  2325. .message .time {
  2326. color: rgba(255, 255, 255, 0.7);
  2327. font-size: 12px;
  2328. }
  2329.  
  2330. #chatInputContainer {
  2331. display: flex;
  2332. gap: 5px;
  2333. align-items: center;
  2334. padding: 5px;
  2335. background: rgba(25,25,25, .6);
  2336. border-radius: .5rem;
  2337. overflow: hidden;
  2338. }
  2339.  
  2340. .chatInput {
  2341. flex-grow: 1;
  2342. border: none;
  2343. background: transparent;
  2344. color: #fff;
  2345. padding: 5px;
  2346. outline: none;
  2347. max-width: 100%;
  2348. }
  2349.  
  2350. .chatButton {
  2351. background: #8a25e5;
  2352. border: none;
  2353. border-radius: 5px;
  2354. padding: 5px 10px;
  2355. height: 100%;
  2356. color: #fff;
  2357. transition: all 0.3s;
  2358. cursor: pointer;
  2359. display: flex;
  2360. align-items: center;
  2361. height: 28px;
  2362. justify-content: center;
  2363. gap: 5px;
  2364. }
  2365. .chatButton:hover {
  2366. background: #7a25e5;
  2367. }
  2368. .chatCloseBtn {
  2369. position: absolute;
  2370. top: 50%;
  2371. left: 50%;
  2372. transform: translate(-50%, -50%);
  2373. }
  2374.  
  2375. .emojisContainer {
  2376. display: flex;
  2377. flex-direction: column;
  2378. gap: 5px;
  2379. }
  2380. .chatAddedContainer {
  2381. position: absolute;
  2382. bottom: 10px;
  2383. left: 465px;
  2384. z-index: 9999;
  2385. padding: 10px;
  2386. background: #151515;
  2387. border-radius: .5rem;
  2388. min-width: 172px;
  2389. max-width: 172px;
  2390. min-height: 250px;
  2391. max-height: 250px;
  2392. }
  2393. #categories {
  2394. overflow-y: auto;
  2395. max-height: calc(250px - 50px);
  2396. gap: 2px;
  2397. }
  2398. .category {
  2399. width: 100%;
  2400. display: flex;
  2401. flex-direction: column;
  2402. gap: 2px;
  2403. }
  2404. .category span {
  2405. color: #fafafa;
  2406. font-size: 14px;
  2407. text-align: center;
  2408. }
  2409.  
  2410. .emojiContainer {
  2411. display: flex;
  2412. flex-wrap: wrap;
  2413. align-items: center;
  2414. justify-content: center;
  2415. }
  2416.  
  2417. #categories .emoji {
  2418. padding: 2px;
  2419. border-radius: 5px;
  2420. font-size: 16px;
  2421. user-select: none;
  2422. cursor: pointer;
  2423. }
  2424.  
  2425. .chatSettingsContainer {
  2426. padding: 10px 3px;
  2427. }
  2428. .chatSettingsContainer .scroll {
  2429. display: flex;
  2430. flex-direction: column;
  2431. gap: 10px;
  2432. max-height: 235px;
  2433. overflow-y: auto;
  2434. padding: 0 10px;
  2435. }
  2436.  
  2437. .csBlock {
  2438. border: 2px solid #050505;
  2439. border-radius: .5rem;
  2440. color: #fff;
  2441. display: flex;
  2442. align-items: center;
  2443. flex-direction: column;
  2444. gap: 5px;
  2445. padding-bottom: 5px;
  2446. }
  2447.  
  2448. .csBlock .csBlockTitle {
  2449. background: #080808;
  2450. width: 100%;
  2451. padding: 3px;
  2452. text-align: center;
  2453. }
  2454.  
  2455. .csRow {
  2456. display: flex;
  2457. justify-content: space-between;
  2458. align-items: center;
  2459. padding: 0 5px;
  2460. width: 100%;
  2461. }
  2462.  
  2463. .csRowName {
  2464. display: flex;
  2465. gap: 5px;
  2466. align-items: start;
  2467. }
  2468.  
  2469. .csRowName .infoIcon {
  2470. width: 14px;
  2471. cursor: pointer;
  2472. }
  2473.  
  2474. .modInfoPopup {
  2475. position: absolute;
  2476. top: 2px;
  2477. left: 58%;
  2478. text-align: center;
  2479. background: #151515;
  2480. border: 1px solid #607bff;
  2481. border-radius: 10px;
  2482. transform: translateX(-50%);
  2483. white-space: nowrap;
  2484. padding: 5px;
  2485. z-index: 99999;
  2486. }
  2487.  
  2488. .modInfoPopup::after {
  2489. content: '';
  2490. display: block;
  2491. position: absolute;
  2492. bottom: -7px;
  2493. background: #151515;
  2494. right: 50%;
  2495. transform: translateX(-50%) rotate(-45deg);
  2496. width: 12px;
  2497. height: 12px;
  2498. border-left: 1px solid #607bff;
  2499. border-bottom: 1px solid #607bff;
  2500. }
  2501.  
  2502. .modInfoPopup p {
  2503. margin: 0;
  2504. font-size: 12px;
  2505. color: #fff;
  2506. }
  2507.  
  2508. .minimapContainer {
  2509. display: flex;
  2510. flex-direction: column;
  2511. align-items: end;
  2512. pointer-events: none;
  2513. position: absolute;
  2514. bottom: 0;
  2515. right: 0;
  2516. z-index: 99999;
  2517. }
  2518. .minimap {
  2519. border-radius: 2px;
  2520. border-top: 1px solid rgba(255, 255, 255, .5);
  2521. border-left: 1px solid rgba(255, 255, 255, .5);
  2522. box-shadow: 0 0 4px rgba(255, 255, 255, .5);
  2523. }
  2524.  
  2525. #tag {
  2526. width: 50px;
  2527. }
  2528.  
  2529. .blur {
  2530. color: transparent!important;
  2531. text-shadow: 0 0 6px hsl(0deg 0% 90% / 70%);
  2532. transition: all .2s;
  2533. }
  2534.  
  2535. .blur:focus, .blur:hover {
  2536. color: #fafafa!important;
  2537. text-shadow: none;
  2538. }
  2539. .progress-row button {
  2540. background: transparent;
  2541. }
  2542.  
  2543. #mod_home .justify-sb {
  2544. z-index: 2;
  2545. }
  2546.  
  2547. .modTitleText {
  2548. font-size: 15px;
  2549. color: #fafafa;
  2550. text-align: start;
  2551. }
  2552. .modDescText {
  2553. text-align: start;
  2554. font-size: 12px;
  2555. color: #777;
  2556. }
  2557. .modButton-secondary {
  2558. background-color: #171717;
  2559. color: #fff;
  2560. border: none;
  2561. padding: 5px 15px;
  2562. border-radius: 15px;
  2563. }
  2564. .vr {
  2565. width: 2px;
  2566. height: 250px;
  2567. background-color: #fafafa;
  2568. }
  2569. .vr2 {
  2570. width: 1px;
  2571. height: 26px;
  2572. background-color: #202020;
  2573. }
  2574.  
  2575. .home-card-row {
  2576. display: flex;
  2577. flex-wrap: nowrap;
  2578. justify-content: space-between;
  2579. gap: 18px;
  2580. }
  2581. .home-card-wrapper {
  2582. display: flex;
  2583. flex: 1;
  2584. flex-direction: column;
  2585. gap: 5px;
  2586. width: 50%;
  2587. }
  2588. .home-card {
  2589. display: flex;
  2590. flex-direction: column;
  2591. justify-content: center;
  2592. gap: 7px;
  2593. border-radius: 5px;
  2594. background: #050505;
  2595. min-height: 164px;
  2596. max-height: 164px;
  2597. max-width: 256px;
  2598. padding: 5px 10px;
  2599. }
  2600. .quickAccess {
  2601. gap: 5px;
  2602. max-height: 164px;
  2603. overflow-y: auto;
  2604. justify-content: start;
  2605. }
  2606.  
  2607. .quickAccess div.modRowItems {
  2608. padding: 2px!important;
  2609. }
  2610.  
  2611. #my-profile-badges {
  2612. display: flex;
  2613. flex-wrap: wrap;
  2614. gap: 5px;
  2615. }
  2616. #my-profile-bio {
  2617. overflow-y: scroll;
  2618. max-height: 75px;
  2619. }
  2620.  
  2621. .brand_wrapper {
  2622. position: relative;
  2623. height: 72px;
  2624. width: 100%;
  2625. display: flex;
  2626. justify-content: center;
  2627. align-items: center;
  2628. }
  2629. .brand_wrapper span {
  2630. font-size: 24px;
  2631. z-index: 2;
  2632. font-family: "Titillium Web", sans-serif;
  2633. font-weight: 600;
  2634. letter-spacing: 3px;
  2635. }
  2636.  
  2637. .brand_img {
  2638. position: absolute;
  2639. top: 0;
  2640. left: 0;
  2641. width: 100%;
  2642. height: 72px;
  2643. border-radius: 10px;
  2644. object-fit: cover;
  2645. object-position: center;
  2646. z-index: 1;
  2647. box-shadow: 0 0 10px #000;
  2648. }
  2649. .brand_credits {
  2650. position: relative;
  2651. font-size: 16px;
  2652. color: #D3A7FF;
  2653. list-style: none;
  2654. width: 100%;
  2655. display: flex;
  2656. justify-content: space-between;
  2657. padding: 0 24px;
  2658. }
  2659.  
  2660. .brand_credits li {
  2661. position: relative;
  2662. display: inline-block;
  2663. text-shadow: 0px 0px 8px #D3A7FF;
  2664. }
  2665.  
  2666. .brand_credits li:not(:last-child)::after {
  2667. content: '•';
  2668. position: absolute;
  2669. right: -20px;
  2670. color: #D3A7FF;
  2671. }
  2672. .brand_yt {
  2673. display: flex;
  2674. justify-content: center;
  2675. align-items: center;
  2676. gap: 20px;
  2677. }
  2678. .yt_wrapper {
  2679. display: flex;
  2680. justify-content: center;
  2681. align-items: center;
  2682. gap: 10px;
  2683. width: 122px;
  2684. padding: 5px;
  2685. background-color: #B63333;
  2686. border-radius: 15px;
  2687. cursor: pointer;
  2688. }
  2689. .yt_wrapper span {
  2690. user-select: none;
  2691. }
  2692.  
  2693. .hidden_full {
  2694. display: none !important;
  2695. visibility: hidden;
  2696. }
  2697.  
  2698. .mod_overlay {
  2699. position: absolute;
  2700. top: 0;
  2701. left: 0;
  2702. width: 100%;
  2703. height: 100vh;
  2704. background: rgba(0, 0, 0, .7);
  2705. z-index: 9999999;
  2706. display: flex;
  2707. justify-content: center;
  2708. align-items: center;
  2709. transition: all .3s ease;
  2710. }
  2711.  
  2712. .black_overlay {
  2713. background: rgba(0, 0, 0, 0);
  2714. z-index: 99999999;
  2715. opacity: 1;
  2716. animation: 2s ease fadeInBlack forwards;
  2717. }
  2718.  
  2719. @keyframes fadeInBlack {
  2720. 0% {
  2721. background: rgba(0, 0, 0, 0);
  2722. }
  2723. 100% {
  2724. background: rgba(0, 0, 0, 1);
  2725. }
  2726. }
  2727.  
  2728. .default-modal {
  2729. position: relative;
  2730. display: flex;
  2731. flex-direction: column;
  2732. min-width: 300px;
  2733. background: #111;
  2734. color: #fafafa;
  2735. border-radius: 12px;
  2736. overflow: hidden;
  2737. box-shadow: 0 5px 10px #000;
  2738. }
  2739.  
  2740. .default-modal-header {
  2741. display: flex;
  2742. justify-content: space-between;
  2743. align-items: center;
  2744. background: #1c1c1c;
  2745. padding: 5px 10px;
  2746. }
  2747.  
  2748. .default-modal-header h2 {
  2749. margin: 0;
  2750. }
  2751.  
  2752. .default-modal-body {
  2753. display: flex;
  2754. flex-direction: column;
  2755. gap: 6px;
  2756. padding: 15px;
  2757. }
  2758.  
  2759. .tournament-overlay-info {
  2760. display: flex;
  2761. flex-direction: column;
  2762. align-items: center;
  2763. color: white;
  2764. font-size: 28px;
  2765. line-height: 1.4;
  2766. }
  2767.  
  2768. .tournament-overlay-info img {
  2769. margin-bottom: 26px;
  2770. }
  2771.  
  2772. .tournaments-wrapper {
  2773. font-family: 'Titillium Web', sans-serif;
  2774. font-weight: 400;
  2775. position: absolute;
  2776. top: 60%;
  2777. left: 50%;
  2778. transform: translate(-50%, -50%);
  2779. background: #000;
  2780. border: 2px solid #222222;
  2781. border-radius: 1.125rem;
  2782. padding: 1.5rem;
  2783. color: #fafafa;
  2784. display: flex;
  2785. flex-direction: column;
  2786. align-items: center;
  2787. gap: 10px;
  2788. min-width: 632px;
  2789. opacity: 0;
  2790. transition: all .3s ease;
  2791. animation: 0.5s ease fadeIn forwards;
  2792. }
  2793. @keyframes fadeIn {
  2794. 0% {
  2795. top: 60%;
  2796. opacity: 0;
  2797. }
  2798. 100% {
  2799. top: 50%;
  2800. opacity: 1;
  2801. }
  2802. }
  2803. .tournaments h1 {
  2804. margin: 0;
  2805. font-weight: 600;
  2806. }
  2807.  
  2808. .teamCards {
  2809. display: flex;
  2810. gap: 5px;
  2811. position: absolute;
  2812. top: 50%;
  2813. transform: translate(-50%, -50%);
  2814. }
  2815. .teamCard {
  2816. display: flex;
  2817. flex-direction: column;
  2818. align-items: center;
  2819. background: rgba(0, 0, 0, 0.4);
  2820. border-radius: 12px;
  2821. padding: 6px;
  2822. height: fit-content;
  2823. }
  2824. .teamCard.userReady {
  2825. border: 2px solid var(--green);
  2826. }
  2827. .teamCard img {
  2828. border-radius: 50%;
  2829. }
  2830. .teamCard span {
  2831. font-size: 12px;
  2832. }
  2833.  
  2834. .redTeam {
  2835. left: 81%;
  2836. }
  2837.  
  2838. .blueTeam {
  2839. left: 24%;
  2840. }
  2841.  
  2842. .lastOneStanding_list {
  2843. display: flex;
  2844. flex-wrap: wrap;
  2845. gap: 8px;
  2846. width: 100%;
  2847. height: 240px;
  2848. max-height: 240px;
  2849. background: #050505;
  2850. }
  2851.  
  2852. .tournament_timer {
  2853. position: absolute;
  2854. top: 20px;
  2855. left: 50%;
  2856. transform: translateX(-50%);
  2857. color: #fff;
  2858. font-size: 15px;
  2859. z-index: 99999;
  2860. user-select: none;
  2861. pointer-events: none;
  2862. }
  2863.  
  2864. details {
  2865. border: 1px solid #aaa;
  2866. border-radius: 4px;
  2867. padding: 0.5em 0.5em 0;
  2868. user-select: none;
  2869. text-align: start;
  2870. }
  2871.  
  2872. summary {
  2873. font-weight: bold;
  2874. margin: -0.5em -0.5em 0;
  2875. padding: 0.5em;
  2876. }
  2877.  
  2878. details[open] {
  2879. padding: 0.5em;
  2880. }
  2881.  
  2882. details[open] summary {
  2883. border-bottom: 1px solid #aaa;
  2884. margin-bottom: 0.5em;
  2885. }
  2886. button[disabled] {
  2887. filter: grayscale(1);
  2888. }
  2889.  
  2890. .tournament-text-lost,
  2891. .tournament-text-won {
  2892. font-size: 6rem;
  2893. font-weight: 600;
  2894. font-family: 'Titillium Web', sans-serif;
  2895. }
  2896.  
  2897. .tournament-text-lost {
  2898. color: var(--red);
  2899. }
  2900. .tournament-text-won {
  2901. color: var(--green);
  2902. }
  2903.  
  2904. .tournament_alert {
  2905. position: absolute;
  2906. top: 20px;
  2907. left: 50%;
  2908. transform: translateX(-50%);
  2909. background: #151515;
  2910. color: #fff;
  2911. text-align: center;
  2912. padding: 20px;
  2913. z-index: 999999;
  2914. border-radius: 10px;
  2915. box-shadow: 0 0 10px #000;
  2916. display: flex;
  2917. gap: 10px;
  2918. }
  2919. .tournament-profile {
  2920. width: 50px;
  2921. height: 50px;
  2922. border-radius: 50%;
  2923. box-shadow: 0 0 10px #000;
  2924. }
  2925.  
  2926. .tournament-text {
  2927. color: #fff;
  2928. font-size: 24px;
  2929. }
  2930.  
  2931. .claimedBadgeWrapper {
  2932. background: linear-gradient(232deg, #020405 1%, #04181E 100%);
  2933. border-radius: 10px;
  2934. width: 320px;
  2935. height: 330px;
  2936. box-shadow: 0 0 40px -20px #39bdff;
  2937. display: flex;
  2938. flex-direction: column;
  2939. gap: 10px;
  2940. align-items: center;
  2941. justify-content: center;
  2942. color: #fff;
  2943. padding: 10px;
  2944. }
  2945.  
  2946. .btn-cyan {
  2947. background: #53B6CC;
  2948. border: none;
  2949. border-radius: 5px;
  2950. font-size: 16px;
  2951. color: #fff;
  2952. font-weight: 500;
  2953. width: fit-content;
  2954. padding: 5px 10px;
  2955. }
  2956.  
  2957. .playTimer {
  2958. z-index: 2;
  2959. position: absolute;
  2960. top: 128px;
  2961. left: 4px;
  2962. color: #8d8d8d;
  2963. font-size: 14px;
  2964. font-weight: 500;
  2965. user-select: none;
  2966. pointer-events: none;
  2967. }
  2968.  
  2969. .mouseTracker {
  2970. z-index: 2;
  2971. position: absolute;
  2972. top: 144px;
  2973. left: 4px;
  2974. color: #8d8d8d;
  2975. font-size: 14px;
  2976. font-weight: 500;
  2977. user-select: none;
  2978. pointer-events: none;
  2979. }
  2980.  
  2981. .modInput-wrapper {
  2982. position: relative;
  2983. display: inline-block;
  2984. width: 100%;
  2985. }
  2986.  
  2987. .modInput-secondary {
  2988. display: inline-block;
  2989. width: 100%;
  2990. padding: 10px 0 10px 15px;
  2991. font-weight: 400;
  2992. color: #E9E9E9;
  2993. background: #050505;
  2994. border: 0;
  2995. border-radius: 3px;
  2996. outline: 0;
  2997. text-indent: 70px;
  2998. transition: all .3s ease-in-out;
  2999. }
  3000. .modInput-secondary.t-indent-120 {
  3001. text-indent: 120px;
  3002. }
  3003. .modInput-secondary::-webkit-input-placeholder {
  3004. color: #050505;
  3005. text-indent: 0;
  3006. font-weight: 300;
  3007. }
  3008. .modInput-secondary + label {
  3009. display: inline-block;
  3010. position: absolute;
  3011. top: 8px;
  3012. left: 0;
  3013. bottom: 8px;
  3014. padding: 5px 15px;
  3015. color: #E9E9E9;
  3016. font-size: 11px;
  3017. font-weight: 700;
  3018. text-transform: uppercase;
  3019. text-shadow: 0 1px 0 rgba(19, 74, 70, 0);
  3020. transition: all .3s ease-in-out;
  3021. border-radius: 3px;
  3022. background: rgba(122, 134, 184, 0);
  3023. }
  3024. .modInput-secondary + label:after {
  3025. position: absolute;
  3026. content: "";
  3027. width: 0;
  3028. height: 0;
  3029. top: 100%;
  3030. left: 50%;
  3031. margin-left: -3px;
  3032. border-left: 3px solid transparent;
  3033. border-right: 3px solid transparent;
  3034. border-top: 3px solid rgba(122, 134, 184, 0);
  3035. transition: all .3s ease-in-out;
  3036. }
  3037.  
  3038. .modInput-secondary:focus,
  3039. .modInput-secondary:active {
  3040. color: #E9E9E9;
  3041. text-indent: 0;
  3042. background: #050505;
  3043. }
  3044. .modInput-secondary:focus::-webkit-input-placeholder,
  3045. .modInput-secondary:active::-webkit-input-placeholder {
  3046. color: #aaa;
  3047. }
  3048. .modInput-secondary:focus + label,
  3049. .modInput-secondary:active + label {
  3050. color: #fff;
  3051. text-shadow: 0 1px 0 rgba(19, 74, 70, 0.4);
  3052. background: #7A86B8;
  3053. transform: translateY(-40px);
  3054. }
  3055. .modInput-secondary:focus + label:after,
  3056. .modInput-secondary:active + label:after {
  3057. border-top: 4px solid #7A86B8;
  3058. }
  3059.  
  3060. /* Friends & account */
  3061.  
  3062. .signIn-overlay {
  3063. position: absolute;
  3064. top: 0;
  3065. left: 0;
  3066. width: 100%;
  3067. height: 100vh;
  3068. background: rgba(0, 0, 0, .4);
  3069. z-index: 999999;
  3070. display: flex;
  3071. justify-content: center;
  3072. align-items: center;
  3073. color: #E3E3E3;
  3074. opacity: 0;
  3075. transition: all .3s ease;
  3076. }
  3077.  
  3078. .signIn-wrapper {
  3079. background: #111111;
  3080. width: 450px;
  3081. display: flex;
  3082. flex-direction: column;
  3083. align-items: center;
  3084. border-radius: 10px;
  3085. color: #fafafa;
  3086. }
  3087.  
  3088. .signIn-header {
  3089. background: #181818;
  3090. width: 100%;
  3091. display: flex;
  3092. justify-content: space-between;
  3093. align-items: center;
  3094. padding: 8px;
  3095. border-radius: 10px 10px 0 0;
  3096. }
  3097. .signIn-header span {
  3098. font-weight: 500;
  3099. font-size: 20px;
  3100. }
  3101.  
  3102. .signIn-body {
  3103. display: flex;
  3104. flex-direction: column;
  3105. gap: 10px;
  3106. align-items: center;
  3107. justify-content: start;
  3108. padding: 40px 40px 5px 40px;
  3109. width: 100%;
  3110. }
  3111.  
  3112. #errMessages {
  3113. color: #AC3D3D;
  3114. flex-direction: column;
  3115. gap: 5px;
  3116. }
  3117.  
  3118. .friends_header {
  3119. display: flex;
  3120. flex-direction: row;
  3121. justify-content: space-between;
  3122. align-items: center;
  3123. gap: 10px;
  3124. width: 100%;
  3125. padding: 10px;
  3126. }
  3127.  
  3128. .friends_body {
  3129. position: relative;
  3130. display: flex;
  3131. flex-direction: column;
  3132. align-items: center;
  3133. gap: 6px;
  3134. width: 100%;
  3135. height: 360px;
  3136. max-height: 360px;
  3137. overflow-y: auto;
  3138. padding-right: 10px;
  3139. }
  3140. .allusers {
  3141. padding: 0;
  3142. }
  3143.  
  3144. #users-container {
  3145. position: relative;
  3146. display: flex;
  3147. flex-direction: column;
  3148. align-items: center;
  3149. gap: 6px;
  3150. width: 100%;
  3151. height: 340px;
  3152. max-height: 340px;
  3153. overflow-y: auto;
  3154. padding-right: 10px;
  3155. }
  3156.  
  3157. .profile-img {
  3158. position: relative;
  3159. width: 52px;
  3160. height: 52px;
  3161. border-radius: 100%;
  3162. border: 1px solid #C8C9D9;
  3163. }
  3164.  
  3165. .profile-img img {
  3166. width: 100%;
  3167. height: 100%;
  3168. border-radius: 100%;
  3169. }
  3170.  
  3171. .status_icon {
  3172. position: absolute;
  3173. width: 15px;
  3174. height: 15px;
  3175. top: 0;
  3176. left: 0;
  3177. border-radius: 50%;
  3178. }
  3179.  
  3180. .online_icon {
  3181. background-color: #3DB239;
  3182. }
  3183. .offline_icon {
  3184. background-color: #B23939;
  3185. }
  3186. .Owner_role {
  3187. color: #3979B2;
  3188. }
  3189. .Moderator_role {
  3190. color: #39B298;
  3191. }
  3192. .Vip_role {
  3193. color: #E1A33E;
  3194. }
  3195.  
  3196. .friends_row {
  3197. display: flex;
  3198. flex-direction: row;
  3199. width: 100%;
  3200. justify-content: space-between;
  3201. align-items: center;
  3202. background: #090909;
  3203. border-radius: 8px;
  3204. padding: 10px;
  3205. }
  3206.  
  3207. .friends_row .val {
  3208. width: fit-content;
  3209. height: fit-content;
  3210. padding: 5px 20px;
  3211. box-sizing: content-box;
  3212. }
  3213.  
  3214. .user-profile-wrapper {
  3215. cursor: pointer;
  3216. }
  3217. .user-profile-wrapper > .centerY.g-5 {
  3218. pointer-events: none;
  3219. user-select: none;
  3220. cursor: pointer;
  3221. }
  3222.  
  3223. .textarea-container {
  3224. position: relative;
  3225. width: 100%;
  3226. }
  3227. .textarea-container textarea {
  3228. width: 100%;
  3229. height: 120px;
  3230. resize: none;
  3231. }
  3232. .char-counter {
  3233. position: absolute;
  3234. bottom: 5px;
  3235. right: 5px;
  3236. color: gray;
  3237. }
  3238.  
  3239. .mod_badges {
  3240. display: flex;
  3241. flex-wrap: wrap;
  3242. gap: 5px;
  3243. }
  3244.  
  3245. .mod_badge {
  3246. width: fit-content;
  3247. background: #222;
  3248. color: #fafafa;
  3249. padding: 2px 7px;
  3250. border-radius: 9px;
  3251. }
  3252.  
  3253. .friends-chat-wrapper {
  3254. position: absolute;
  3255. top: 0;
  3256. left: 0;
  3257. width: 100%;
  3258. height: 100%;
  3259. background: #111111;
  3260. display: flex;
  3261. flex-direction: column;
  3262. z-index: 999;
  3263. opacity: 0;
  3264. transition: all .3s ease;
  3265. }
  3266.  
  3267. .friends-chat-header {
  3268. display: flex;
  3269. justify-content: space-between;
  3270. align-items: center;
  3271. background: #050505;
  3272. width: 100%;
  3273. padding: 8px;
  3274. height: 68px;
  3275. }
  3276.  
  3277. .friends-chat-body {
  3278. height: calc(100% - 68px);
  3279. display: flex;
  3280. flex-direction: column;
  3281. }
  3282.  
  3283. .friends-chat-messages {
  3284. height: 300px;
  3285. overflow-y: auto;
  3286. display: flex;
  3287. flex-direction: column;
  3288. gap: 5px;
  3289. padding: 10px;
  3290. }
  3291. .friends-message {
  3292. background: linear-gradient(180deg, rgb(12 12 12), #000);
  3293. padding: 8px;
  3294. border-radius: 12px;
  3295. display: flex;
  3296. flex-direction: column;
  3297. min-width: 80px;
  3298. max-width: 200px;
  3299. width: fit-content;
  3300. }
  3301.  
  3302. .message-date {
  3303. color: #8a8989;
  3304. font-size: 11px;
  3305. }
  3306.  
  3307. .message-right {
  3308. align-self: flex-end;
  3309. }
  3310.  
  3311. .messenger-wrapper {
  3312. width: 100%;
  3313. height: 60px;
  3314. padding: 10px;
  3315. }
  3316. .messenger-wrapper .container {
  3317. display: flex;
  3318. flex-direction: row;
  3319. gap: 10px;
  3320. width: 100%;
  3321. background: #0a0a0a;
  3322. padding: 10px 5px;
  3323. border-radius: 10px;
  3324. }
  3325.  
  3326. .messenger-wrapper .container input {
  3327. padding: 5px;
  3328. }
  3329. .messenger-wrapper .container button {
  3330. width: 150px;
  3331. }
  3332.  
  3333. /* deathscreen challenges */
  3334.  
  3335. #menu-wrapper {
  3336. overflow-x: visible;
  3337. overflow-y: visible;
  3338. }
  3339.  
  3340. .challenges_deathscreen {
  3341. width: 450px;
  3342. background: rgb(21, 21, 21);
  3343. display: flex;
  3344. flex-direction: column;
  3345. gap: 8px;
  3346. padding: 7px;
  3347. border-radius: 10px;
  3348. margin-bottom: 15px;
  3349. }
  3350.  
  3351. .challenges-col {
  3352. display: flex;
  3353. flex-direction: column;
  3354. gap: 4px;
  3355. align-items: center;
  3356. width: 100%;
  3357. }
  3358. .challenge-row {
  3359. display: flex;
  3360. align-items: center;
  3361. background: rgba(0, 0, 0, .4);
  3362. justify-content: space-between;
  3363. padding: 5px 10px;
  3364. border-radius: 4px;
  3365. width: 100%;
  3366. }
  3367.  
  3368. .challenges-title {
  3369. font-size: 16px;
  3370. font-weight: 600;
  3371. }
  3372.  
  3373. .challenge-best-secondary {
  3374. background: #1d1d1d;
  3375. border-radius: 10px;
  3376. text-align: center;
  3377. padding: 5px 8px;
  3378. min-width: 130px;
  3379. }
  3380. .challenge-collect-secondary {
  3381. background: #4C864B;
  3382. border-radius: 10px;
  3383. text-align: center;
  3384. padding: 5px 8px;
  3385. outline: none;
  3386. border: none;
  3387. min-width: 130px;
  3388. }
  3389.  
  3390. .alwan__reference {
  3391. border-width: 2px !important;
  3392. }
  3393.  
  3394. #mod-announcements {
  3395. display: flex;
  3396. flex-direction: column;
  3397. gap: 6px;
  3398. max-height: 144px;
  3399. overflow-y: auto;
  3400. }
  3401.  
  3402. .mod-announcement {
  3403. background: #111111;
  3404. border-radius: 4px;
  3405. display: flex;
  3406. gap: 3px;
  3407. width: 100%;
  3408. cursor: pointer;
  3409. padding: 5px 8px;
  3410. }
  3411.  
  3412. .mod-announcement-icon {
  3413. border-radius: 50%;
  3414. width: 35px;
  3415. height: 35px;
  3416. align-self: center;
  3417. }
  3418.  
  3419. .mod-announcement-text {
  3420. display: flex;
  3421. flex-direction: column;
  3422. gap: 3px;
  3423. overflow: hidden;
  3424. flex-grow: 1;
  3425. }
  3426.  
  3427. .mod-announcement-text > * {
  3428. overflow: hidden;
  3429. white-space: nowrap;
  3430. text-overflow: ellipsis;
  3431. }
  3432.  
  3433. .mod-announcement-text span {
  3434. font-size: 14px;
  3435. color: #ffffff;
  3436. flex-shrink: 0;
  3437. }
  3438.  
  3439. .mod-announcement-text p {
  3440. font-size: 10px;
  3441. color: #898989;
  3442. flex-shrink: 0;
  3443. margin: 0;
  3444. }
  3445.  
  3446. .mod-announcements-wrapper {
  3447. display: flex;
  3448. flex-direction: column;
  3449. gap: 10px;
  3450. }
  3451.  
  3452. .mod-announcement-content {
  3453. display: flex;
  3454. justify-content: space-between;
  3455. gap: 10px;
  3456. background-color: #050505;
  3457. padding: 10px;
  3458. border-radius: 10px;
  3459. background-image: url('https://czrsd.com/static/general/bg_blur.png');
  3460. background-repeat: no-repeat;
  3461. background-position: 300px 40%;
  3462. background-size: cover;
  3463. }
  3464.  
  3465. .mod-announcement-content p {
  3466. text-align: justify;
  3467. max-height: 330px;
  3468. overflow-y: auto;
  3469. padding-right: 10px;
  3470. }
  3471.  
  3472. .mod-announcement-images {
  3473. display: flex;
  3474. flex-direction: column;
  3475. gap: 20px;
  3476. min-width: 30%;
  3477. width: 30%;
  3478. max-height: 330px;
  3479. padding-right: 10px;
  3480. overflow-y: auto;
  3481. }
  3482.  
  3483. .mod-announcement-images img {
  3484. border-radius: 5px;
  3485. cursor: pointer;
  3486. }
  3487.  
  3488. #image-gallery {
  3489. display: flex;
  3490. flex-wrap: wrap;
  3491. gap: 5px;
  3492. }
  3493.  
  3494. .image-container {
  3495. display: flex;
  3496. flex-direction: column;
  3497. }
  3498.  
  3499. .image-container img {
  3500. width: 172px;
  3501. height: auto;
  3502. aspect-ratio: 16 / 9;
  3503. border-radius: 5px;
  3504. cursor: pointer;
  3505. }
  3506.  
  3507. .download_btn {
  3508. background: url('https://czrsd.com/static/sigmod/icons/download.svg');
  3509.  
  3510. }
  3511.  
  3512. .delete_btn {
  3513. background: url('https://czrsd.com/static/sigmod/icons/trash-bin.svg');
  3514. }
  3515.  
  3516. .operation_btn {
  3517. background-size: contain;
  3518. background-repeat: no-repeat;
  3519. border: none;
  3520. width: 22px;
  3521. height: 22px;
  3522. }
  3523.  
  3524. .sigmod-community {
  3525. display: flex;
  3526. flex-direction: column;
  3527. margin: auto;
  3528. border-radius: 10px;
  3529. width: 50%;
  3530. align-self: center;
  3531. font-size: 19px;
  3532. overflow: hidden;
  3533. }
  3534.  
  3535. .community-header {
  3536. background: linear-gradient(179deg, #000000, #0c0c0c);
  3537. text-align: center;
  3538. font-family: "Titillium Web", sans-serif;
  3539. padding: 6px;
  3540. }
  3541.  
  3542. .community-discord-logo {
  3543. background: rgb(88, 101, 242);
  3544. padding: 5px 12px;
  3545. }
  3546. .community-discord {
  3547. text-align: center;
  3548. padding: 10px;
  3549. background: #0c0c0c;
  3550. width: 100%;
  3551. }
  3552. .community-discord a {
  3553. font-family: "Titillium Web", sans-serif;
  3554. }
  3555.  
  3556. /* common */
  3557. .flex {
  3558. display: flex;
  3559. }
  3560. .centerX {
  3561. display: flex;
  3562. justify-content: center;
  3563. }
  3564. .centerY {
  3565. display: flex;
  3566. align-items: center;
  3567. }
  3568. .centerXY {
  3569. display: flex;
  3570. align-items: center;
  3571. justify-content: center
  3572. }
  3573. .f-column {
  3574. display: flex;
  3575. flex-direction: column;
  3576. }
  3577. mx-5 {
  3578. margin: 0 5px;
  3579. }
  3580. .my-5 {
  3581. margin: 5px 0;
  3582. }
  3583. .mt-auto {
  3584. margin-top: auto !important;
  3585. }
  3586. .g-2 {
  3587. gap: 2px;
  3588. }
  3589. .g-5 {
  3590. gap: 5px;
  3591. }
  3592. .g-10 {
  3593. gap: 10px;
  3594. }
  3595. .p-2 {
  3596. padding: 2px;
  3597. }
  3598. .p-5 {
  3599. padding: 5px;
  3600. }
  3601. .p-10 {
  3602. padding: 10px;
  3603. }
  3604. .rounded {
  3605. border-radius: 6px;
  3606. }
  3607. .text-center {
  3608. text-align: center;
  3609. }
  3610. .f-big {
  3611. font-size: 18px;
  3612. }
  3613. .hidden {
  3614. display: none;
  3615. }
  3616. `;
  3617. },
  3618. respawnTime: Date.now(),
  3619. respawnCooldown: 1000,
  3620. get friends_settings() {
  3621. return this._friends_settings;
  3622. },
  3623. set friends_settings(value) {
  3624. this._friends_settings = value;
  3625. window.sigmod.friends_settings = value;
  3626. },
  3627. get friend_names() {
  3628. return this._friend_names;
  3629. },
  3630.  
  3631. set friend_names(value) {
  3632. this._friend_names = value;
  3633. window.sigmod.friend_names = value;
  3634. },
  3635.  
  3636. async game() {
  3637. const { fillRect, fillText, strokeText, arc, drawImage } =
  3638. CanvasRenderingContext2D.prototype;
  3639.  
  3640. const showPosition = byId('showPosition');
  3641. if (showPosition && !showPosition.checked) showPosition.click();
  3642.  
  3643. const loadStorage = () => {
  3644. if (modSettings.virusImage) {
  3645. loadVirusImage(modSettings.virusImage);
  3646. }
  3647.  
  3648. if (modSettings.game.skins.original !== null) {
  3649. loadSkinImage(
  3650. modSettings.game.skins.original,
  3651. modSettings.game.skins.replacement
  3652. );
  3653. }
  3654. };
  3655.  
  3656. loadStorage();
  3657.  
  3658. let cachedPattern = null;
  3659. let patternCanvas = null;
  3660. let isUpdatingPattern = false;
  3661.  
  3662. function updatePattern(ctx) {
  3663. isUpdatingPattern = true;
  3664. loadPattern(ctx)
  3665. .then((pattern) => {
  3666. if (mods.mapImageLoaded) {
  3667. cachedPattern = pattern;
  3668. ctx.fillStyle = cachedPattern;
  3669. ctx.fillRect(
  3670. 0,
  3671. 0,
  3672. ctx.canvas.width,
  3673. ctx.canvas.height
  3674. );
  3675. } else {
  3676. clearPattern(ctx);
  3677. }
  3678. isUpdatingPattern = false;
  3679. })
  3680. .catch((e) => {
  3681. console.error('Error loading map image:', e);
  3682. clearPattern(ctx);
  3683. isUpdatingPattern = false;
  3684. });
  3685. }
  3686.  
  3687. function loadPattern(ctx) {
  3688. return new Promise((resolve, reject) => {
  3689. const img = new Image();
  3690. img.src = modSettings.game.map.image;
  3691. img.crossOrigin = 'Anonymous';
  3692.  
  3693. img.onload = () => {
  3694. if (!patternCanvas) {
  3695. patternCanvas = document.createElement('canvas');
  3696. }
  3697. patternCanvas.width = img.width;
  3698. patternCanvas.height = img.height;
  3699. const patternCtx = patternCanvas.getContext('2d');
  3700. patternCtx.drawImage(img, 0, 0);
  3701.  
  3702. const imageData = patternCtx.getImageData(
  3703. 0,
  3704. 0,
  3705. patternCanvas.width,
  3706. patternCanvas.height
  3707. );
  3708. const data = imageData.data;
  3709. mods.mapImageLoaded = !Array.from(data).some(
  3710. (_, i) => i % 4 === 3 && data[i] < 255
  3711. );
  3712.  
  3713. if (mods.mapImageLoaded) {
  3714. resolve(
  3715. ctx.createPattern(patternCanvas, 'no-repeat')
  3716. );
  3717. } else {
  3718. resolve(null);
  3719. }
  3720. };
  3721.  
  3722. img.onerror = () =>
  3723. reject(new Error('Failed to load image.'));
  3724. });
  3725. }
  3726.  
  3727. function clearPattern(ctx) {
  3728. isUpdatingPattern = true;
  3729. ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
  3730. ctx.fillStyle = modSettings.game.map.color || '#111111';
  3731. ctx.fillRect(0, 0, ctx.canvas.width, ctx.canvas.height);
  3732. isUpdatingPattern = false;
  3733. }
  3734.  
  3735. window.addEventListener('resize', () => {
  3736. const canvas = document.getElementById('canvas');
  3737. if (canvas && modSettings.game.map.image) {
  3738. updatePattern(canvas.getContext('2d'));
  3739. }
  3740. });
  3741.  
  3742. /* CanvasRenderingContext2D.prototype */
  3743.  
  3744. CanvasRenderingContext2D.prototype.fillRect = function (
  3745. x,
  3746. y,
  3747. width,
  3748. height
  3749. ) {
  3750. if (this.canvas.id !== 'canvas')
  3751. return fillRect.apply(this, arguments);
  3752.  
  3753. const isCanvasSize =
  3754. (width + height) / 2 ===
  3755. (window.innerWidth + window.innerHeight) / 2;
  3756.  
  3757. if (isCanvasSize) {
  3758. if (modSettings.game.map.image && !mods.mapImageLoaded) {
  3759. mods.mapImageLoaded = true;
  3760. updatePattern(this);
  3761. } else if (
  3762. !modSettings.game.map.image ||
  3763. !mods.mapImageLoaded
  3764. ) {
  3765. if (!isUpdatingPattern) {
  3766. clearPattern(this);
  3767. }
  3768. } else {
  3769. this.fillStyle =
  3770. cachedPattern ||
  3771. modSettings.game.map.color ||
  3772. '#111111';
  3773. }
  3774. }
  3775.  
  3776. fillRect.apply(this, arguments);
  3777. };
  3778.  
  3779. CanvasRenderingContext2D.prototype.arc = function (
  3780. x,
  3781. y,
  3782. radius,
  3783. startAngle,
  3784. endAngle,
  3785. anticlockwise
  3786. ) {
  3787. if (this.canvas.id !== 'canvas') return arc.apply(this, arguments);
  3788.  
  3789. if (radius >= 86 && modSettings.game.cellColor) {
  3790. this.fillStyle = modSettings.game.cellColor;
  3791. } else if (
  3792. radius <= 20 &&
  3793. modSettings.game.foodColor !== null
  3794. ) {
  3795. this.fillStyle = modSettings.game.foodColor;
  3796. this.strokeStyle = modSettings.game.foodColor;
  3797. }
  3798.  
  3799. arc.apply(this, arguments);
  3800. };
  3801.  
  3802. CanvasRenderingContext2D.prototype.fillText = function (
  3803. text,
  3804. x,
  3805. y
  3806. ) {
  3807. if (this.canvas.id !== 'canvas') return fillText.apply(this, arguments);
  3808.  
  3809. const currentFontSizeMatch = this.font.match(/^(\d+)px/);
  3810. const fontSize = currentFontSizeMatch
  3811. ? currentFontSizeMatch[0]
  3812. : '';
  3813.  
  3814. this.font = `${fontSize} ${modSettings.game.font || 'Ubuntu'}`;
  3815.  
  3816. if (
  3817. text === mods.nick &&
  3818. !modSettings.game.name.gradient.enabled &&
  3819. modSettings.game.name.color !== null
  3820. ) {
  3821. this.fillStyle = modSettings.game.name.color;
  3822. }
  3823.  
  3824. if (
  3825. text === mods.nick &&
  3826. modSettings.game.name.gradient.enabled
  3827. ) {
  3828. const width = this.measureText(text).width;
  3829. const fontSize = 8;
  3830. const gradient = this.createLinearGradient(
  3831. x - width / 2 + fontSize / 2,
  3832. y,
  3833. x + width / 2 - fontSize / 2,
  3834. y + fontSize
  3835. );
  3836.  
  3837. const color1 =
  3838. modSettings.game.name.gradient.left ?? '#ffffff';
  3839. const color2 =
  3840. modSettings.game.name.gradient.right ?? '#ffffff';
  3841.  
  3842. gradient.addColorStop(0, color1);
  3843. gradient.addColorStop(1, color2);
  3844.  
  3845. this.fillStyle = gradient;
  3846. }
  3847.  
  3848. if (!window.sigifx && text.startsWith('Score')) {
  3849. if (Date.now() - lastGetScore >= 250) {
  3850. const score = parseInt(text.split(': ')[1]);
  3851.  
  3852. mods.cellSize = score;
  3853.  
  3854. mods.aboveRespawnLimit = score >= 5500;
  3855.  
  3856. lastGetScore = Date.now();
  3857. }
  3858. }
  3859.  
  3860. if (!window.sigfix && text.startsWith('X:')) {
  3861. this.fillStyle = 'transparent';
  3862.  
  3863. const [, xValue, yValue] =
  3864. /X: (.*), Y: (.*)/.exec(text) || [];
  3865. if (!xValue) return;
  3866.  
  3867. const position = {
  3868. x: parseFloat(xValue),
  3869. y: parseFloat(yValue),
  3870. };
  3871.  
  3872. if (menuClosed() && !isDead()) {
  3873. if (position.x === 0 && position.y === 0) return;
  3874.  
  3875. playerPosition.x = position.x;
  3876. playerPosition.y = position.y;
  3877.  
  3878. // send position every 300 milliseconds
  3879. if (Date.now() - lastPosTime >= 300) {
  3880. if (modSettings.settings.tag && client?.ws?.readyState === 1) {
  3881. client.send({
  3882. type: 'position',
  3883. content: {
  3884. x: playerPosition.x,
  3885. y: playerPosition.y,
  3886. },
  3887. });
  3888. }
  3889. lastPosTime = Date.now();
  3890. }
  3891. } else if (isDead() && !dead2) {
  3892. dead2 = true;
  3893. playerPosition.x = null;
  3894. playerPosition.y = null;
  3895. if (modSettings.settings.tag && client?.ws?.readyState === 1) {
  3896. client.send({
  3897. type: 'position',
  3898. content: { x: null, y: null },
  3899. });
  3900. }
  3901. }
  3902. }
  3903.  
  3904. if (modSettings.game.removeOutlines) {
  3905. this.shadowBlur = 0;
  3906. this.shadowColor = 'transparent';
  3907. }
  3908.  
  3909. if (text.length > 18 && modSettings.game.shortenNames) {
  3910. arguments[0] = text.slice(0, 18) + '...';
  3911. }
  3912.  
  3913. // only for leaderboard
  3914. const name = text.match(/\d+\.\s*(.+)/)?.[1];
  3915.  
  3916. if (
  3917. name &&
  3918. mods.friend_names.has(name) &&
  3919. mods.friends_settings.highlight_friends
  3920. ) {
  3921. this.fillStyle = mods.friends_settings.highlight_color;
  3922. }
  3923.  
  3924. fillText.apply(this, arguments);
  3925. };
  3926.  
  3927. CanvasRenderingContext2D.prototype.strokeText = function (
  3928. text,
  3929. x,
  3930. y
  3931. ) {
  3932. if (this.canvas.id !== 'canvas') return strokeText.apply(this, arguments);
  3933.  
  3934. const currentFontSizeMatch = this.font.match(/^(\d+)px/);
  3935. const fontSize = currentFontSizeMatch
  3936. ? currentFontSizeMatch[0]
  3937. : '';
  3938.  
  3939. this.font = `${fontSize} ${modSettings.game.font || 'Ubuntu'}`;
  3940.  
  3941. if (text.length > 18 && modSettings.game.shortenNames) {
  3942. arguments[0] = text.slice(0, 18) + '...';
  3943. }
  3944.  
  3945. if (modSettings.game.removeOutlines) {
  3946. this.shadowBlur = 0;
  3947. this.shadowColor = 'transparent';
  3948. } else {
  3949. this.shadowBlur = 7;
  3950. this.shadowColor = '#000';
  3951. }
  3952.  
  3953. strokeText.apply(this, arguments);
  3954. };
  3955.  
  3956. CanvasRenderingContext2D.prototype.drawImage = function (
  3957. image,
  3958. ...args
  3959. ) {
  3960. if (this.canvas.id !== 'canvas')
  3961. return drawImage.call(this, image, ...args);
  3962.  
  3963. if (
  3964. image.src &&
  3965. (image.src.endsWith('2.png') ||
  3966. image.src.endsWith('2-min.png')) &&
  3967. modSettings.game.virusImage
  3968. ) {
  3969. if (mods.virusImageLoaded) {
  3970. return drawImage.call(this, mods.virusImage, ...args);
  3971. } else {
  3972. loadVirusImage(modSettings.game.virusImage).then(() => {
  3973. drawImage.call(this, mods.virusImage, ...args);
  3974. });
  3975. return;
  3976. }
  3977. }
  3978.  
  3979. if (
  3980. image instanceof HTMLImageElement &&
  3981. modSettings.game.skins.original &&
  3982. image.src.includes(`${modSettings.game.skins.original}.png`)
  3983. ) {
  3984. if (mods.skinImageLoaded) {
  3985. return drawImage.call(this, mods.skinImage, ...args);
  3986. } else {
  3987. loadSkinImage(
  3988. modSettings.game.skins.original,
  3989. modSettings.game.skins.replacement
  3990. ).then(() => {
  3991. drawImage.call(this, mods.skinImage, ...args);
  3992. });
  3993. return;
  3994. }
  3995. }
  3996.  
  3997. drawImage.call(this, image, ...args);
  3998. };
  3999.  
  4000. function loadVirusImage(imgSrc) {
  4001. return new Promise((resolve, reject) => {
  4002. const replacementVirus = new Image();
  4003. replacementVirus.src = imgSrc;
  4004. replacementVirus.crossOrigin = 'Anonymous';
  4005.  
  4006. replacementVirus.onload = () => {
  4007. mods.virusImage = replacementVirus;
  4008. mods.virusImageLoaded = true;
  4009. resolve();
  4010. };
  4011.  
  4012. replacementVirus.onerror = () => {
  4013. console.error('Failed to load virus image.');
  4014. reject(new Error('Failed to load virus image.'));
  4015. };
  4016. });
  4017. }
  4018.  
  4019. function loadSkinImage(originalSkinName, replacementImgSrc) {
  4020. return new Promise((resolve, reject) => {
  4021. const replacementSkin = new Image();
  4022. replacementSkin.src = replacementImgSrc;
  4023. replacementSkin.crossOrigin = 'Anonymous';
  4024.  
  4025. replacementSkin.onload = () => {
  4026. mods.skinImage = replacementSkin;
  4027. mods.skinImageLoaded = true;
  4028. resolve();
  4029. };
  4030.  
  4031. replacementSkin.onerror = () =>
  4032. reject(new Error('Failed to load skin image.'));
  4033. });
  4034. }
  4035.  
  4036. const modals = {
  4037. map: {
  4038. title: 'Map Image',
  4039. applyId: 'apply-map-image',
  4040. resetId: 'reset-map-image',
  4041. previewId: 'preview-mapImage',
  4042. modalId: 'map-modal',
  4043. storagePath: 'game.map.image',
  4044. },
  4045. virus: {
  4046. title: 'Virus Image',
  4047. applyId: 'apply-virus-image',
  4048. resetId: 'reset-virus-image',
  4049. previewId: 'preview-virusImage',
  4050. modalId: 'virus-modal',
  4051. storagePath: 'game.virusImage',
  4052. },
  4053. skin: {
  4054. title: 'Skin Replacement',
  4055. applyId: 'apply-skin-image',
  4056. resetId: 'reset-skin-image',
  4057. previewId: 'preview-skinImage',
  4058. modalId: 'skin-modal',
  4059. storagePath: [
  4060. 'game.skins.original',
  4061. 'game.skins.replacement',
  4062. ],
  4063. additional: true,
  4064. },
  4065. };
  4066.  
  4067. function createModal({
  4068. title,
  4069. applyId,
  4070. resetId,
  4071. previewId,
  4072. modalId,
  4073. additional,
  4074. }) {
  4075. const additionalContent = additional
  4076. ? `
  4077. <span>Select a skin that should be replaced:</span>
  4078. <select class="form-control" id="skin-list"></select>
  4079. <span style="font-size: 12px;">Replacement image - Enter an image URL:</span>
  4080. `
  4081. : `
  4082. <span>Enter an image URL:</span>
  4083. `;
  4084.  
  4085. return `
  4086. <div class="default-modal">
  4087. <div class="default-modal-header">
  4088. <h2>${title}</h2>
  4089. <button class="btn closeBtn" id="closeCustomModal">
  4090. <svg width="22" height="20" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
  4091. <path d="M1.6001 14.4L14.4001 1.59998M14.4001 14.4L1.6001 1.59998" stroke="#fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path>
  4092. </svg>
  4093. </button>
  4094. </div>
  4095. <div class="default-modal-body">
  4096. ${additionalContent}
  4097. <div class="centerXY g-10">
  4098. <input type="text" placeholder="https://i.imgur/..." class="form-control" id="image-url" />
  4099. <div class="imagePreview" id="${previewId}" title="Image Preview">
  4100. <span class="no-preview">No Preview Available</span>
  4101. </div>
  4102. </div>
  4103. <div class="centerXY g-10">
  4104. <button type="button" class="modButton-black" id="${applyId}">Apply Image</button>
  4105. <button type="button" class="resetButton" title="Reset ${title.toLowerCase()}" id="${resetId}"></button>
  4106. </div>
  4107. </div>
  4108. </div>
  4109. `;
  4110. }
  4111.  
  4112. function setupModalEvents(id, type) {
  4113. byId(id).addEventListener('click', async () => {
  4114. mods.customModal(
  4115. createModal(modals[type]),
  4116. modals[type].modalId
  4117. );
  4118. document
  4119. .querySelector('#closeCustomModal')
  4120. .addEventListener('click', () => closeModal(type));
  4121.  
  4122. const modal = modals[type];
  4123. const imageUrlInput = byId('image-url');
  4124.  
  4125. let initialUrl = '';
  4126. if (modal.additional && type === 'skin') {
  4127. const [originalPath, replacementPath] =
  4128. modal.storagePath;
  4129. initialUrl =
  4130. getNestedValue(modSettings, replacementPath) || '';
  4131. byId('skin-list').value =
  4132. getNestedValue(modSettings, originalPath) || '';
  4133. } else {
  4134. initialUrl =
  4135. getNestedValue(modSettings, modal.storagePath) ||
  4136. '';
  4137. }
  4138. imageUrlInput.value = initialUrl;
  4139. updatePreview(initialUrl);
  4140.  
  4141. imageUrlInput.addEventListener('input', (e) => {
  4142. updatePreview(e.target.value);
  4143. });
  4144.  
  4145. byId(modal.applyId).addEventListener('click', () =>
  4146. applyChanges(type)
  4147. );
  4148. byId(modal.resetId).addEventListener('click', () =>
  4149. resetChanges(type)
  4150. );
  4151.  
  4152. if (type === 'skin') {
  4153. const skinList = byId('skin-list');
  4154. const skins =
  4155. mods.skins.length > 0
  4156. ? mods.skins
  4157. : await fetch(
  4158. 'https://one.sigmally.com/api/skins'
  4159. )
  4160. .then((response) => response.json())
  4161. .then((data) => {
  4162. const skinNames = data.data.map(
  4163. (item) =>
  4164. item.name.replace('.png', '')
  4165. );
  4166. mods.skins = skinNames;
  4167. return skinNames;
  4168. });
  4169.  
  4170. skinList.innerHTML = skins
  4171. .map(
  4172. (skin) =>
  4173. `<option value="${skin}" ${
  4174. skin === modSettings.game.skins.original
  4175. ? 'selected'
  4176. : ''
  4177. }>${skin}</option>`
  4178. )
  4179. .join('');
  4180. }
  4181. });
  4182. }
  4183.  
  4184. function getNestedValue(obj, path) {
  4185. return path
  4186. .split('.')
  4187. .reduce((acc, part) => acc && acc[part], obj);
  4188. }
  4189.  
  4190. function setNestedValue(obj, path, value) {
  4191. const parts = path.split('.');
  4192. const last = parts.pop();
  4193. const target = parts.reduce(
  4194. (acc, part) => (acc[part] = acc[part] || {}),
  4195. obj
  4196. );
  4197. target[last] = value;
  4198. }
  4199.  
  4200. function updatePreview(url) {
  4201. const preview = document.querySelector('.imagePreview');
  4202. const noPreviewSpan = document.querySelector('.no-preview');
  4203.  
  4204. const updateVisibility = (showPreview) => {
  4205. preview.style.backgroundImage = showPreview
  4206. ? `url(${url})`
  4207. : 'none';
  4208. noPreviewSpan.style.display = showPreview
  4209. ? 'none'
  4210. : 'block';
  4211. };
  4212.  
  4213. if (url) {
  4214. const img = new Image();
  4215. img.src = url;
  4216. img.onload = () => updateVisibility(true);
  4217. img.onerror = () => updateVisibility(false);
  4218. } else {
  4219. updateVisibility(false);
  4220. }
  4221. }
  4222.  
  4223. function applyChanges(type) {
  4224. let { title, storagePath, additional } = modals[type];
  4225. const url = byId('image-url').value;
  4226.  
  4227. mods[`${type}ImageLoaded`] = false;
  4228.  
  4229. if (additional && type === 'skin') {
  4230. const selectedSkin = byId('skin-list').value;
  4231. setNestedValue(modSettings, storagePath[0], selectedSkin);
  4232. setNestedValue(modSettings, storagePath[1], url);
  4233. } else {
  4234. setNestedValue(modSettings, storagePath, url);
  4235. }
  4236.  
  4237. updateStorage();
  4238.  
  4239. mods.modAlert(`Successfully applied ${title}.`, 'success');
  4240. }
  4241.  
  4242. function resetChanges(type) {
  4243. const { title, storagePath, additional } = modals[type];
  4244.  
  4245. if (additional && type === 'skin') {
  4246. setNestedValue(modSettings, storagePath[0], null);
  4247. setNestedValue(modSettings, storagePath[1], null);
  4248. } else {
  4249. setNestedValue(modSettings, storagePath, null);
  4250. }
  4251.  
  4252. mods[`${type}ImageLoaded`] = false;
  4253.  
  4254. updateStorage();
  4255.  
  4256. mods.modAlert(
  4257. `The ${title} has been successfully reset.`,
  4258. 'success'
  4259. );
  4260. }
  4261.  
  4262. function closeModal(type) {
  4263. const overlay = byId(`${type}-modal`);
  4264. overlay.style.opacity = 0;
  4265. setTimeout(() => overlay.remove(), 300);
  4266. }
  4267.  
  4268. setupModalEvents('mapImageSelect', 'map');
  4269. setupModalEvents('virusImageSelect', 'virus');
  4270. setupModalEvents('skinReplaceSelect', 'skin');
  4271.  
  4272. const shortenNames = byId('shortenNames');
  4273. const removeOutlines = byId('removeOutlines');
  4274.  
  4275. shortenNames.addEventListener('change', () => {
  4276. modSettings.game.shortenNames = shortenNames.checked;
  4277. updateStorage();
  4278. });
  4279. removeOutlines.addEventListener('change', () => {
  4280. modSettings.game.removeOutlines = removeOutlines.checked;
  4281. updateStorage();
  4282. });
  4283.  
  4284. const showNames = byId('mod-showNames');
  4285. const showSkins = byId('mod-showSkins');
  4286.  
  4287. const originalShowNames = byId('showNames');
  4288. const originalShowSkins = byId('showSkins');
  4289.  
  4290. function syncCheckboxes() {
  4291. if (showNames.checked !== originalShowNames.checked) {
  4292. originalShowNames.click();
  4293. }
  4294. if (showSkins.checked !== originalShowSkins.checked) {
  4295. originalShowSkins.click();
  4296. }
  4297. }
  4298.  
  4299. showNames.addEventListener('change', syncCheckboxes);
  4300. showSkins.addEventListener('change', syncCheckboxes);
  4301. syncCheckboxes();
  4302.  
  4303. const deathScreenPos = byId('deathScreenPos');
  4304. const deathScreen = byId('__line2');
  4305.  
  4306. const applyMargin = (position) => {
  4307. switch (position) {
  4308. case 'left':
  4309. deathScreen.style.marginLeft = '0';
  4310. break;
  4311. case 'right':
  4312. deathScreen.style.marginRight = '0';
  4313. break;
  4314. case 'top':
  4315. deathScreen.style.marginTop = '20px';
  4316. break;
  4317. case 'bottom':
  4318. deathScreen.style.marginBottom = '20px';
  4319. break;
  4320. default:
  4321. deathScreen.style.margin = 'auto';
  4322. }
  4323. };
  4324.  
  4325. deathScreenPos.addEventListener('change', () => {
  4326. const selected = deathScreenPos.value;
  4327. applyMargin(selected);
  4328. modSettings.deathScreenPos = selected;
  4329. updateStorage();
  4330. });
  4331.  
  4332. const defaultPosition = modSettings.deathScreenPos || 'center';
  4333.  
  4334. applyMargin(defaultPosition);
  4335. deathScreenPos.value = defaultPosition;
  4336. },
  4337.  
  4338. customModal(children, id, zindex = '999999') {
  4339. const overlay = document.createElement('div');
  4340. overlay.classList.add('mod_overlay');
  4341. id && overlay.setAttribute('id', id);
  4342. overlay.innerHTML = children;
  4343. overlay.style.zIndex = zindex;
  4344. overlay.style.opacity = 0;
  4345.  
  4346. document.body.append(overlay);
  4347.  
  4348. setTimeout(() => {
  4349. overlay.style.opacity = '1';
  4350. });
  4351.  
  4352. const handleClickOutside = (e) => {
  4353. if (e.target === overlay) {
  4354. overlay.style.opacity = 0;
  4355. setTimeout(() => {
  4356. overlay.remove();
  4357. document.removeEventListener(
  4358. 'click',
  4359. handleClickOutside
  4360. );
  4361. }, 300);
  4362. }
  4363. };
  4364.  
  4365. document.addEventListener('click', handleClickOutside);
  4366. },
  4367.  
  4368. handleGoogleAuth(user) {
  4369. fetchedUser++;
  4370. window.gameSettings.user = user;
  4371.  
  4372. const chatSendInput = document.querySelector('#chatSendInput');
  4373. if (chatSendInput) {
  4374. chatSendInput.placeholder = 'message...';
  4375. chatSendInput.disabled = false;
  4376. }
  4377.  
  4378. if (!client) client = new modClient();
  4379.  
  4380. const waitForInit = () =>
  4381. new Promise((res) => {
  4382. if (client.ws?.readyState === 1 && mods.nick)
  4383. return res(null);
  4384. const i = setInterval(
  4385. () =>
  4386. client.ws?.readyState === 1 &&
  4387. mods.nick &&
  4388. (clearInterval(i), res(null)),
  4389. 50
  4390. );
  4391. });
  4392.  
  4393. waitForInit().then(() => {
  4394. client.send({
  4395. type: 'user',
  4396. content: { ...user, nick: mods.nick },
  4397. })
  4398. });
  4399.  
  4400. const claim = document.getElementById('free-chest-button');
  4401. if (
  4402. fetchedUser === 1 &&
  4403. modSettings.settings.autoClaimCoins &&
  4404. claim?.style.display !== 'none'
  4405. ) {
  4406. setTimeout(() => claim.click(), 500);
  4407. }
  4408. },
  4409.  
  4410. async menu() {
  4411. const mod_menu = document.createElement('div');
  4412. mod_menu.classList.add('mod_menu');
  4413. mod_menu.style.display = 'none';
  4414. mod_menu.style.opacity = '0';
  4415. mod_menu.innerHTML = `
  4416. <div class="mod_menu_wrapper">
  4417. <div class="mod_menu_header">
  4418. <img alt="Header image" src="${headerAnim}" draggable="false" class="header_img" />
  4419. <button type="button" class="modButton" id="closeBtn">
  4420. <svg width="18" height="20" viewBox="0 0 16 16" fill="#ffffff" xmlns="http://www.w3.org/2000/svg">
  4421. <path d="M1.6001 14.4L14.4001 1.59998M14.4001 14.4L1.6001 1.59998" stroke="#fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path>
  4422. </svg>
  4423. </button>
  4424. </div>
  4425. <div class="mod_menu_inner">
  4426. <div class="mod_menu_navbar">
  4427. <button class="mod_nav_btn mod_selected" id="tab_home_btn">
  4428. <img src="https://raw.githubusercontent.com/Sigmally/SigMod/main/images/icons/home%20(1).png" alt="Home Icon" />
  4429. Home
  4430. </button>
  4431. <button class="mod_nav_btn" id="tab_macros_btn">
  4432. <img src="https://raw.githubusercontent.com/Sigmally/SigMod/main/images/icons/keyboard%20(1).png" alt="Keyboard Icon" />
  4433. Macros
  4434. </button>
  4435. <button class="mod_nav_btn" id="tab_game_btn">
  4436. <img src="https://raw.githubusercontent.com/Sigmally/SigMod/main/images/icons/games.png" alt="Game Icon" />
  4437. Game
  4438. </button>
  4439. <button class="mod_nav_btn" id="tab_name_btn">
  4440. <img src="https://raw.githubusercontent.com/Sigmally/SigMod/836ca0f4c25fc6de2e429ee3583be5f860884a0c/images/icons/name.svg" alt="Name Icon" />
  4441. Name
  4442. </button>
  4443. <button class="mod_nav_btn" id="tab_themes_btn">
  4444. <img src="https://raw.githubusercontent.com/Sigmally/SigMod/main/images/icons/theme.png" alt="Themes Icon" />
  4445. Themes
  4446. </button>
  4447. <button class="mod_nav_btn" id="tab_gallery_btn">
  4448. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="22"><path fill="#ffffff" d="M0 96C0 60.7 28.7 32 64 32l384 0c35.3 0 64 28.7 64 64l0 320c0 35.3-28.7 64-64 64L64 480c-35.3 0-64-28.7-64-64L0 96zM323.8 202.5c-4.5-6.6-11.9-10.5-19.8-10.5s-15.4 3.9-19.8 10.5l-87 127.6L170.7 297c-4.6-5.7-11.5-9-18.7-9s-14.2 3.3-18.7 9l-64 80c-5.8 7.2-6.9 17.1-2.9 25.4s12.4 13.6 21.6 13.6l96 0 32 0 208 0c8.9 0 17.1-4.9 21.2-12.8s3.6-17.4-1.4-24.7l-120-176zM112 192a48 48 0 1 0 0-96 48 48 0 1 0 0 96z"/></svg>
  4449. Gallery
  4450. </button>
  4451.  
  4452. <button class="mod_nav_btn" id="tab_friends_btn">
  4453. <img src="https://raw.githubusercontent.com/Sigmally/SigMod/main/images/icons/friends%20(1).png" alt="Friends Icon" />
  4454. Friends
  4455. </button>
  4456. <button class="mod_nav_btn mt-auto" id="tab_info_btn">
  4457. <img src="https://raw.githubusercontent.com/Sigmally/SigMod/main/images/icons/info.png" alt="Info Icon" />
  4458. Info
  4459. </button>
  4460. </div>
  4461. <div class="mod_menu_content">
  4462. <div class="mod_tab" id="mod_home">
  4463. <span class="text-center f-big" id="welcomeUser">Welcome ${
  4464. this.nick || 'Guest'
  4465. }, to the SigMod Client!</span>
  4466. <div class="home-card-row">
  4467. <!-- CARD.1 -->
  4468. <div class="home-card-wrapper">
  4469. <span>Your stats</span>
  4470. <div class="home-card">
  4471. <canvas id="sigmod-stats" width="200" height="100"></canvas>
  4472. </div>
  4473. </div>
  4474. <!-- CARD.2 -->
  4475. <div class="home-card-wrapper">
  4476. <span>Announcements</span>
  4477. <div class="home-card" style="justify-content: start;">
  4478. <div id="mod-announcements">No announcements yet...</div>
  4479. </div>
  4480. </div>
  4481. </div>
  4482. <div class="home-card-row">
  4483. <!-- CARD.3 -->
  4484. <div class="home-card-wrapper">
  4485. <span>Quick access</span>
  4486. <div class="home-card quickAccess scroll" id="mod_qaccess"></div>
  4487. </div>
  4488. <!-- CARD.4 -->
  4489. <div class="home-card-wrapper">
  4490. <span>Mod profile</span>
  4491. <div class="home-card">
  4492. <div class="justify-sb">
  4493. <div class="flex" style="align-items: center; gap: 5px;">
  4494. <img src="https://sigmally.com/assets/images/agario-profile.png" alt="Agar-io profile" width="50" height="50" id="my-profile-img" style="border-radius: 50%;" draggable="false" />
  4495. <span id="my-profile-name">Guest</span>
  4496. </div>
  4497. <span id="my-profile-role">Guest</span>
  4498. </div>
  4499. <div id="my-profile-badges"></div>
  4500. <hr />
  4501. <span id="my-profile-bio" class="scroll">No Bio.</span>
  4502. </div>
  4503. </div>
  4504. </div>
  4505. </div>
  4506. <div class="mod_tab scroll" id="mod_macros" style="display: none">
  4507. <div class="modColItems">
  4508. <div class="macros_wrapper">
  4509. <span class="text-center f-big">Keybindings</span>
  4510. <hr style="border-color: #3F3F3F">
  4511. <div style="justify-content: center;">
  4512. <div class="f-column g-10" style="align-items: center; justify-content: center;">
  4513. <div class="macrosContainer">
  4514. <div class="f-column g-10">
  4515. <label class="macroRow">
  4516. <span class="text">Rapid Feed</span>
  4517. <input type="text" name="rapidFeed" id="modinput1" class="keybinding" value="${
  4518. modSettings.macros
  4519. .keys
  4520. .rapidFeed ||
  4521. ''
  4522. }" maxlength="1" onfocus="this.select()" placeholder="..." />
  4523. </label>
  4524. <label class="macroRow">
  4525. <span class="text">Double Split</span>
  4526. <input type="text" name="splits.double" id="modinput2" class="keybinding" value="${
  4527. modSettings.macros
  4528. .keys.splits
  4529. .double || ''
  4530. }" maxlength="1" onfocus="this.select()" placeholder="..." />
  4531. </label>
  4532. <label class="macroRow">
  4533. <span class="text">Triple Split</span>
  4534. <input type="text" name="splits.triple" id="modinput3" class="keybinding" value="${
  4535. modSettings.macros
  4536. .keys.splits
  4537. .triple || ''
  4538. }" maxlength="1" onfocus="this.select()" placeholder="..." />
  4539. </label>
  4540. <label class="macroRow">
  4541. <span class="text">Respawn</span>
  4542. <input type="text" name="respawn" id="modinput16" class="keybinding" value="${
  4543. modSettings.macros
  4544. .keys
  4545. .respawn || ''
  4546. }" maxlength="1" onfocus="this.select()" placeholder="..." />
  4547. </label>
  4548. </div>
  4549. <div class="f-column g-10">
  4550. <label class="macroRow">
  4551. <span class="text">Quad Split</span>
  4552. <input type="text" name="splits.quad" id="modinput4" class="keybinding" value="${
  4553. modSettings.macros
  4554. .keys.splits
  4555. .quad || ''
  4556. }" maxlength="1" onfocus="this.select()" placeholder="..." />
  4557. </label>
  4558. <label class="macroRow">
  4559. <span class="text">Horizontal Line</span>
  4560. <input type="text" name="line.horizontal" id="modinput5" class="keybinding" value="${
  4561. modSettings.macros
  4562. .keys.line
  4563. .horizontal ||
  4564. ''
  4565. }" maxlength="1" onfocus="this.select()" placeholder="..." />
  4566. </label>
  4567. <label class="macroRow">
  4568. <span class="text">Vertical Line</span>
  4569. <input type="text" name="line.vertical" id="modinput8" class="keybinding" value="${
  4570. modSettings.macros
  4571. .keys.line
  4572. .vertical ||
  4573. ''
  4574. }" maxlength="1" onfocus="this.select()" placeholder="..." />
  4575. </label>
  4576. <label class="macroRow">
  4577. <span class="text">Fixed Line</span>
  4578. <input type="text" name="line.fixed" id="modinput18" class="keybinding" value="${
  4579. modSettings.macros
  4580. .keys.line
  4581. .fixed || ''
  4582. }" maxlength="1" onfocus="this.select()" placeholder="..." />
  4583. </label>
  4584. </div>
  4585. </div>
  4586. </div>
  4587. </div>
  4588. </div>
  4589. <div class="macros_wrapper">
  4590. <span class="text-center f-big">Advanced Keybinding options</span>
  4591. <div class="setting-card-wrapper">
  4592. <div class="setting-card">
  4593. <div class="setting-card-action">
  4594. <span class="setting-card-name">Mouse macros</span>
  4595. </div>
  4596. </div>
  4597. <div class="setting-parameters" style="display: none;">
  4598. <div class="my-5">
  4599. <span class="stats-info-text">Feed or Split with mouse buttons</span>
  4600. </div>
  4601. <div class="stats-line justify-sb">
  4602. <span class="centerXY g-5">
  4603. Mouse Button 1
  4604. <svg xmlns="http://www.w3.org/2000/svg" fill="#ffffff" width="24px" height="24px" viewBox="0 0 356.57 356.57"><path d="M181.563,0C120.762,0,59.215,30.525,59.215,88.873V237.5c0,65.658,53.412,119.071,119.071,119.071 c65.658,0,119.07-53.413,119.07-119.071V88.873C297.356,27.809,237.336,0,181.563,0z M274.945,237.5 c0,53.303-43.362,96.657-96.659,96.657c-53.299,0-96.657-43.354-96.657-96.657v-69.513c20.014,6.055,57.685,15.215,102.221,15.215 c28.515,0,59.831-3.809,91.095-14.567V237.5z M274.945,144.794c-81.683,31.233-168.353,7.716-193.316-0.364V88.873 c0-43.168,51.489-66.46,99.934-66.46c46.481,0,93.382,20.547,93.382,66.46V144.794z M190.893,48.389v81.248 c0,6.187-5.023,11.208-11.206,11.208c-6.185,0-11.207-5.021-11.207-11.208V48.389c0-6.186,5.021-11.207,11.207-11.207 C185.869,37.182,190.893,42.203,190.893,48.389z M154.938,40.068V143.73c-15.879,2.802-62.566-10.271-62.566-10.271 C80.233,41.004,154.938,40.068,154.938,40.068z"></path></svg>
  4605. </span>
  4606. <select class="form-control macro-extanded_input" style="padding: 2px; text-align: left; width: 100px" id="m1_macroSelect">
  4607. <option value="none">None</option>
  4608. <option value="fastfeed">Fast Feed</option>
  4609. <option value="split">Split (1)</option>
  4610. <option value="split2">Double Split</option>
  4611. <option value="split3">Triple Split</option>
  4612. <option value="split4">Quad Split</option>
  4613. <option value="freeze">Horizontal Line</option>
  4614. <option value="dTrick">Double Trick</option>
  4615. <option value="sTrick">Self Trick</option>
  4616. </select>
  4617. </div>
  4618. <div class="stats-line justify-sb">
  4619. <span class="centerXY g-5">
  4620. Mouse Button 2
  4621. <svg xmlns="http://www.w3.org/2000/svg" fill="#ffffff" width="24px" height="24px" viewBox="0 0 356.57 356.57"><path d="M181.563,0C120.762,0,59.215,30.525,59.215,88.873V237.5c0,65.658,53.412,119.071,119.071,119.071 c65.658,0,119.07-53.413,119.07-119.071V88.873C297.356,27.809,237.336,0,181.563,0z M274.945,237.5 c0,53.303-43.362,96.657-96.659,96.657c-53.299,0-96.657-43.354-96.657-96.657v-69.513c20.014,6.055,57.685,15.215,102.221,15.215 c28.515,0,59.831-3.809,91.095-14.567V237.5z M274.945,144.794c-81.683,31.233-168.353,7.716-193.316-0.364V88.873 c0-43.168,51.489-66.46,99.934-66.46c46.481,0,93.382,20.547,93.382,66.46V144.794z M190.893,48.389v81.248 c0,6.187-5.023,11.208-11.206,11.208c-6.185,0-11.207-5.021-11.207-11.208V48.389c0-6.186,5.021-11.207,11.207-11.207 C185.869,37.182,190.893,42.203,190.893,48.389z M154.938,40.068V143.73c-15.879,2.802-62.566-10.271-62.566-10.271 C80.233,41.004,154.938,40.068,154.938,40.068z"></path></svg>
  4622. </span>
  4623. <select class="form-control" style="padding: 2px; text-align: left; width: 100px" id="m2_macroSelect">
  4624. <option value="none">None</option>
  4625. <option value="fastfeed">Fast Feed</option>
  4626. <option value="split">Split (1)</option>
  4627. <option value="split2">Double Split</option>
  4628. <option value="split3">Triple Split</option>
  4629. <option value="split4">Quad Split</option>
  4630. <option value="freeze">Horizontal Line</option>
  4631. <option value="dTrick">Double Trick</option>
  4632. <option value="sTrick">Self Trick</option>
  4633. </select>
  4634. </div>
  4635. </div>
  4636. </div>
  4637. <div class="setting-card-wrapper">
  4638. <div class="setting-card">
  4639. <div class="setting-card-action">
  4640. <span class="setting-card-name">Rapid feed</span>
  4641. </div>
  4642. </div>
  4643.  
  4644. <div class="setting-parameters" style="display: none;">
  4645. <div class="my-5">
  4646. <span class="stats-info-text">Customize feeding</span>
  4647. </div>
  4648. <div class="stats-line justify-sb">
  4649. <span>Speed</span>
  4650. <div class="justify-sb g-5" style="width: 200px;">
  4651. <span class="mod_badge" id="macroSpeedText">${
  4652. modSettings.macros
  4653. .feedSpeed ||
  4654. '50'
  4655. }ms</span>
  4656. <input
  4657. type="range"
  4658. class="modSlider"
  4659. id="macroSpeed"
  4660. min="5"
  4661. max="100"
  4662. value="${modSettings.macros.feedSpeed || 50}"
  4663. step="5"
  4664. style="width: 134px;"
  4665. />
  4666. </div>
  4667. </div>
  4668. </div>
  4669. </div>
  4670. <div class="setting-card-wrapper">
  4671. <div class="setting-card">
  4672. <div class="setting-card-action">
  4673. <span class="setting-card-name">Linesplits</span>
  4674. </div>
  4675. </div>
  4676.  
  4677. <div class="setting-parameters" style="display: none;">
  4678. <div class="my-5">
  4679. <span class="stats-info-text">Customize linesplits</span>
  4680. </div>
  4681.  
  4682. <div class="stats-line justify-sb">
  4683. <span>Instant split</span>
  4684. <div class="centerXY g-5">
  4685. <span class="modDescText">Splits - </span>
  4686. <input type="text" class="modInput modNumberInput text-center" placeholder="0" title="Splits" style="width: 30px;" id="instant-split-amount" onclick="this.select()" />
  4687. <div class="modCheckbox">
  4688. <input id="toggle-instant-split" type="checkbox" checked />
  4689. <label class="cbx" for="toggle-instant-split"></label>
  4690. </div>
  4691. </div>
  4692. </div>
  4693. </div>
  4694. </div>
  4695. <div class="setting-card-wrapper">
  4696. <div class="setting-card">
  4697. <div class="setting-card-action">
  4698. <span class="setting-card-name">Toggle Settings</span>
  4699. </div>
  4700. </div>
  4701.  
  4702. <div class="setting-parameters" style="display: none;">
  4703. <div class="my-5">
  4704. <span class="stats-info-text">Toggle settings with a keybind.</span>
  4705. </div>
  4706.  
  4707. <div class="stats-line justify-sb">
  4708. <span>Toggle Menu</span>
  4709. <input type="text" name="toggle.menu" id="modinput6" class="keybinding" value="${
  4710. modSettings.macros.keys
  4711. .toggle.menu || ''
  4712. }" maxlength="1" onfocus="this.select()" placeholder="..." />
  4713. </div>
  4714.  
  4715. <div class="stats-line justify-sb">
  4716. <span>Toggle Names</span>
  4717. <input value="${
  4718. modSettings.macros.keys
  4719. .toggle.names || ''
  4720. }" placeholder="..." readonly id="modinput11" name="toggle.names" class="keybinding" onfocus="this.select();">
  4721. </div>
  4722.  
  4723. <div class="stats-line justify-sb">
  4724. <span>Toggle Skins</span>
  4725. <input value="${
  4726. modSettings.macros.keys
  4727. .toggle.skins || ''
  4728. }" placeholder="..." readonly id="modinput12" name="toggle.skins" class="keybinding" onfocus="this.select();">
  4729. </div>
  4730.  
  4731. <div class="stats-line justify-sb">
  4732. <span>Toggle Autorespawn</span>
  4733. <input value="${
  4734. modSettings.macros.keys
  4735. .toggle
  4736. .autoRespawn || ''
  4737. }" placeholder="..." readonly id="modinput13" name="toggle.autoRespawn" class="keybinding" onfocus="this.select();">
  4738. </div>
  4739. </div>
  4740. </div>
  4741. <div class="setting-card-wrapper">
  4742. <div class="setting-card">
  4743. <div class="setting-card-action">
  4744. <span class="setting-card-name">Tricksplits</span>
  4745. </div>
  4746. </div>
  4747. <div class="setting-parameters" style="display: none;">
  4748. <div class="my-5">
  4749. <span class="stats-info-text">Other split options - splits with delay</span>
  4750. </div>
  4751. <div class="stats-line justify-sb">
  4752. <span>Double Trick</span>
  4753. <input value="${
  4754. modSettings.macros.keys
  4755. .splits
  4756. .doubleTrick || ''
  4757. }" placeholder="..." readonly id="modinput14" name="splits.doubleTrick" class="keybinding" onfocus="this.select();">
  4758. </div>
  4759. <div class="stats-line justify-sb">
  4760. <span>Self Trick</span>
  4761. <input value="${
  4762. modSettings.macros.keys
  4763. .splits.selfTrick ||
  4764. ''
  4765. }" placeholder="..." readonly id="modinput15" name="splits.selfTrick" class="keybinding" onfocus="this.select();">
  4766. </div>
  4767. </div>
  4768. </div>
  4769. </div>
  4770. </div>
  4771. </div>
  4772. <div class="mod_tab scroll" id="mod_game" style="display: none">
  4773. <div class="modColItems">
  4774. <div class="modRowItems" style="align-items: start;">
  4775. <div class="modColItems_2">
  4776. <span style="font-style: italic;">~ Game Colors</span>
  4777. <div class="justify-sb w-100 p-5 rounded">
  4778. <span class="text">Map</span>
  4779. <div id="mapColor"></div>
  4780. </div>
  4781. <div class="justify-sb w-100 accent_row p-5 rounded">
  4782. <span class="text">Border</span>
  4783. <div id="borderColor"></div>
  4784. </div>
  4785. <div class="justify-sb w-100 p-5 rounded">
  4786. <span class="text" title="Does not work with jelly physics">Food</span>
  4787. <div id="foodColor"></div>
  4788. </div>
  4789. <div class="justify-sb w-100 accent_row p-5 rounded">
  4790. <span class="text" title="Does not work with jelly physics">Cells</span>
  4791. <div id="cellColor"></div>
  4792. </div>
  4793. </div>
  4794. <div class="modColItems_2">
  4795. <span style="font-style: italic;">~ Game Images</span>
  4796. <div class="justify-sb w-100 p-5 rounded">
  4797. <span class="text">Map Image</span>
  4798. <button class="btn select-btn" id="mapImageSelect"></button>
  4799. </div>
  4800. <div class="justify-sb w-100 accent_row p-5 rounded">
  4801. <span class="text">Virus Image</span>
  4802. <button class="btn select-btn" id="virusImageSelect"></button>
  4803. </div>
  4804. <div class="justify-sb w-100 p-5 rounded">
  4805. <span class="text">Replace Skins</span>
  4806. <button class="btn select-btn" id="skinReplaceSelect"></button>
  4807. </div>
  4808. </div>
  4809. </div>
  4810. <div class="modColItems_2">
  4811. <span style="font-style: italic;">~ Game Settings</span>
  4812. <div class="justify-sb w-100 accent_row p-10 rounded">
  4813. <span class="text">Font</span>
  4814. <div id="font-select-container"></div>
  4815. </div>
  4816. <div class="justify-sb w-100 p-10">
  4817. <span class="text">Names</span>
  4818. <div class="modCheckbox">
  4819. <input id="mod-showNames" type="checkbox" ${
  4820. JSON.parse(
  4821. localStorage.getItem(
  4822. 'settings'
  4823. )
  4824. )?.showNames
  4825. ? 'checked'
  4826. : ''
  4827. } />
  4828. <label class="cbx" for="mod-showNames"></label>
  4829. </div>
  4830. </div>
  4831. <div class="justify-sb w-100 accent_row p-10 rounded">
  4832. <span class="text">Skins</span>
  4833. <div class="modCheckbox">
  4834. <input id="mod-showSkins" type="checkbox" ${
  4835. JSON.parse(
  4836. localStorage.getItem(
  4837. 'settings'
  4838. )
  4839. )?.showSkins
  4840. ? 'checked'
  4841. : ''
  4842. } />
  4843. <label class="cbx" for="mod-showSkins"></label>
  4844. </div>
  4845. </div>
  4846. <div class="justify-sb w-100 p-10 rounded">
  4847. <span title="Long nicknames will be shorten on the leaderboard & ingame">Shorten names</span>
  4848. <div class="modCheckbox">
  4849. <input id="shortenNames" type="checkbox" ${
  4850. modSettings.game
  4851. .shortenNames && 'checked'
  4852. } />
  4853. <label class="cbx" for="shortenNames"></label>
  4854. </div>
  4855. </div>
  4856. <div class="justify-sb w-100 accent_row p-10">
  4857. <span>Text outlines & shadows</span>
  4858. <div class="modCheckbox">
  4859. <input id="removeOutlines" type="checkbox" ${
  4860. modSettings.gameShortenNames &&
  4861. 'checked'
  4862. } />
  4863. <label class="cbx" for="removeOutlines"></label>
  4864. </div>
  4865. </div>
  4866. <div class="justify-sb w-100 rounded" style="padding: 5px 10px;">
  4867. <span class="text">Death screen Position</span>
  4868. <select id="deathScreenPos" class="form-control" style="width: 30%">
  4869. <option value="center" selected>Center</option>
  4870. <option value="left">Left</option>
  4871. <option value="right">Right</option>
  4872. <option value="top">Top</option>
  4873. <option value="bottom">Bottom</option>
  4874. </select>
  4875. </div>
  4876. <div class="justify-sb w-100 accent_row p-10 rounded">
  4877. <span class="text">Play timer</span>
  4878. <div class="modCheckbox">
  4879. <input type="checkbox" id="playTimerToggle" ${
  4880. modSettings.settings
  4881. .playTimer && 'checked'
  4882. } />
  4883. <label class="cbx" for="playTimerToggle"></label>
  4884. </div>
  4885. </div>
  4886. <div class="justify-sb w-100 p-10 rounded">
  4887. <span class="text">Mouse tracker</span>
  4888. <div class="modCheckbox">
  4889. <input type="checkbox" id="mouseTrackerToggle" ${
  4890. modSettings.settings
  4891. .mouseTracker && 'checked'
  4892. } />
  4893. <label class="cbx" for="mouseTrackerToggle"></label>
  4894. </div>
  4895. </div>
  4896. </div>
  4897. <div class="modRowItems justify-sb">
  4898. <span class="text">Reset settings: </span>
  4899. <button class="modButton-secondary" id="resetModSettings" type="button">Reset mod settings</button>
  4900. <button class="modButton-secondary" id="resetGameSettings" type="button">Reset game settings</button>
  4901. </div>
  4902. </div>
  4903. </div>
  4904.  
  4905. <div class="mod_tab scroll" id="mod_name" style="display: none">
  4906. <div class="modColItems">
  4907. <div class="modRowItems justify-sb" style="align-items: start;">
  4908. <div class="f-column g-5" style="align-items: start; justify-content: start;">
  4909. <span class="modTitleText">Name fonts & special characters</span>
  4910. <span class="modDescText">Customize your name with special characters or fonts</span>
  4911. </div>
  4912. <div class="f-column g-5">
  4913. <button class="modButton-secondary" onclick="window.open('https://nickfinder.com', '_blank')">Nickfinder</button>
  4914. <button class="modButton-secondary" onclick="window.open('https://www.stylishnamemaker.com', '_blank')">Stylish Name</button>
  4915. <button class="modButton-secondary" onclick="window.open('https://www.tell.wtf', '_blank')">Tell.wtf</button>
  4916. </div>
  4917. </div>
  4918. <div class="modRowItems justify-sb">
  4919. <div class="f-column g-5">
  4920. <span class="modTitleText">Save names</span>
  4921. <span class="modDescText">Save your names locally</span>
  4922. <div class="flex g-5">
  4923. <input class="modInput" placeholder="Enter a name..." id="saveNameValue" />
  4924. <button id="saveName" class="modButton-secondary f-big" style="border-radius: 5px; background: url('https://sigmally.com/assets/images/icon/plus.svg'); background-color: #111; background-size: 50% auto; background-repeat: no-repeat; background-position: center;"></button>
  4925. </div>
  4926. <div id="savedNames" class="f-column scroll"></div>
  4927. </div>
  4928. <div class="vr"></div>
  4929. <div class="f-column g-5">
  4930. <span class="modTitleText">Name Color</span>
  4931. <span class="modDescText">Customize your name color</span>
  4932. <div class="justify-sb">
  4933. <input type="color" value="#ffffff" id="nameColor" class="colorInput">
  4934. </div>
  4935. <span class="modTitleText">Gradient Name</span>
  4936. <span class="modDescText">Customize your name with a gradient color</span>
  4937. <div class="justify-sb">
  4938. <div class="flex g-2" style="align-items: center">
  4939. <input type="color" value="#ffffff" id="gradientNameColor1" class="colorInput">
  4940. <span>➜ First color</span>
  4941. </div>
  4942. </div>
  4943. <div class="justify-sb">
  4944. <div class="flex g-2" style="align-items: center">
  4945. <input type="color" value="#ffffff" id="gradientNameColor2" class="colorInput">
  4946. <span>➜ Second color</span>
  4947. </div>
  4948. </div>
  4949. </div>
  4950. </div>
  4951. </div>
  4952. </div>
  4953. <div class="mod_tab scroll" id="mod_themes" style="display: none">
  4954. <span>Background presets</span>
  4955. <div class="themes scroll" id="themes">
  4956. <div class="theme" id="createTheme">
  4957. <div class="themeContent" style="background: url('https://sigmally.com/assets/images/icon/plus.svg'); background-size: 50% auto; background-repeat: no-repeat; background-position: center;"></div>
  4958. <div class="themeName text" style="color: #fff">Create</div>
  4959. </div>
  4960. </div>
  4961.  
  4962. <div class="modColItems_2" style="margin-top: 5px;">
  4963. <div class="justify-sb w-100 p-10">
  4964. <span>Input border radius</span>
  4965. <div class="centerXY g-10" style="width: 40%">
  4966. <button id="reset_input_radius" class="resetButton"></button>
  4967. <input type="range" class="modSlider" id="theme-inputBorderRadius" max="20" step="2" />
  4968. </div>
  4969. </div>
  4970. <div class="justify-sb w-100 p-10 accent_row rounded">
  4971. <span>Menu border radius</span>
  4972. <div class="centerXY g-10" style="width: 40%">
  4973. <button id="reset_menu_radius" class="resetButton"></button>
  4974. <input type="range" class="modSlider"id="theme-menuBorderRadius" max="50" step="2" />
  4975. </div>
  4976. </div>
  4977. <div class="justify-sb w-100 p-10">
  4978. <span>Input border</span>
  4979. <div class="modCheckbox">
  4980. <input id="theme-inputBorder" type="checkbox" />
  4981. <label class="cbx" for="theme-inputBorder"></label>
  4982. </div>
  4983. </div>
  4984. <div class="justify-sb w-100 p-10 accent_row rounded">
  4985. <span>Challenges on deathscreen</span>
  4986. <div class="modCheckbox">
  4987. <input id="showChallenges" type="checkbox" />
  4988. <label class="cbx" for="showChallenges"></label>
  4989. </div>
  4990. </div>
  4991. <div class="justify-sb w-100 p-10">
  4992. <span>Remove shop popup</span>
  4993. <div class="modCheckbox">
  4994. <input id="removeShopPopup" type="checkbox" />
  4995. <label class="cbx" for="removeShopPopup"></label>
  4996. </div>
  4997. </div>
  4998. <div class="justify-sb w-100 p-10 accent_row rounded">
  4999. <span>Hide Discord Buttons</span>
  5000. <div class="modCheckbox">
  5001. <input id="hideDiscordBtns" type="checkbox" />
  5002. <label class="cbx" for="hideDiscordBtns"></label>
  5003. </div>
  5004. </div>
  5005. <div class="justify-sb w-100 p-10">
  5006. <span>Hide Language Buttons</span>
  5007. <div class="modCheckbox">
  5008. <input id="hideLangs" type="checkbox" />
  5009. <label class="cbx" for="hideLangs"></label>
  5010. </div>
  5011. </div>
  5012. </div>
  5013. </div>
  5014. <div class="mod_tab scroll" id="mod_gallery" style="display: none">
  5015. <div class="modColItems_2">
  5016. <label class="macroRow w-100">
  5017. <span class="text">Keybind to save image</span>
  5018. <input type="text" name="saveImage" id="modinput17" class="keybinding" value="${
  5019. modSettings.macros.keys.saveImage ||
  5020. ''
  5021. }" maxlength="1" onfocus="this.select()" placeholder="..." />
  5022. </label>
  5023. </div>
  5024. <div class="modColItems_2">
  5025. <span>Image gallery</span>
  5026. <div class="flex g-5">
  5027. <button class="modButton" id="gallery-download">Download all</button>
  5028. <button class="modButton" id="gallery-delete">Delete all</button>
  5029. </div>
  5030. <div id="image-gallery"></div>
  5031. </div>
  5032. </div>
  5033. <div class="mod_tab scroll centerXY" id="mod_friends" style="display: none">
  5034. <div class="centerXY f-big" style="margin-top: 10px;">Connect and discover new friends with SigMod.</div>
  5035. <div class="centerXY">Do you have problems with your account? Create a support ticket in our <a href="https://discord.gg/RjxeZ2eRGg" target="_blank">Discord server</a>.</div>
  5036.  
  5037. <div class="centerXY f-column g-5" style="height: 300px; width: 165px;">
  5038. <button class="modButton-black" id="createAccount">
  5039. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="16"><path fill="#ffffff" d="M471.6 21.7c-21.9-21.9-57.3-21.9-79.2 0L362.3 51.7l97.9 97.9 30.1-30.1c21.9-21.9 21.9-57.3 0-79.2L471.6 21.7zm-299.2 220c-6.1 6.1-10.8 13.6-13.5 21.9l-29.6 88.8c-2.9 8.6-.6 18.1 5.8 24.6s15.9 8.7 24.6 5.8l88.8-29.6c8.2-2.7 15.7-7.4 21.9-13.5L437.7 172.3 339.7 74.3 172.4 241.7zM96 64C43 64 0 107 0 160V416c0 53 43 96 96 96H352c53 0 96-43 96-96V320c0-17.7-14.3-32-32-32s-32 14.3-32 32v96c0 17.7-14.3 32-32 32H96c-17.7 0-32-14.3-32-32V160c0-17.7 14.3-32 32-32h96c17.7 0 32-14.3 32-32s-14.3-32-32-32H96z"/></svg>
  5040. Create account
  5041. </button>
  5042. <button class="modButton-black" id="login">
  5043. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="16"><path fill="#ffffff" d="M217.9 105.9L340.7 228.7c7.2 7.2 11.3 17.1 11.3 27.3s-4.1 20.1-11.3 27.3L217.9 406.1c-6.4 6.4-15 9.9-24 9.9c-18.7 0-33.9-15.2-33.9-33.9l0-62.1L32 320c-17.7 0-32-14.3-32-32l0-64c0-17.7 14.3-32 32-32l128 0 0-62.1c0-18.7 15.2-33.9 33.9-33.9c9 0 17.6 3.6 24 9.9zM352 416l64 0c17.7 0 32-14.3 32-32l0-256c0-17.7-14.3-32-32-32l-64 0c-17.7 0-32-14.3-32-32s14.3-32 32-32l64 0c53 0 96 43 96 96l0 256c0 53-43 96-96 96l-64 0c-17.7 0-32-14.3-32-32s14.3-32 32-32z"/></svg>
  5044. Login
  5045. </button>
  5046. </div>
  5047. </div>
  5048. <div class="mod_tab scroll f-column g-5 text-center" id="mod_info" style="display: none">
  5049. <div class="brand_wrapper">
  5050. <img src="https://czrsd.com/static/sigmod/info_bg_2.jpeg" alt="Info background" class="brand_img" />
  5051. <span>SigMod V${version} by Cursed</span>
  5052. </div>
  5053. <span>Thanks to</span>
  5054. <ul class="brand_credits">
  5055. <li>Jb</li>
  5056. <li>Black</li>
  5057. <li>8y8x</li>
  5058. <li>Dreamz</li>
  5059. <li>Ultra</li>
  5060. <li>Xaris</li>
  5061. <li>Benzofury</li>
  5062. </ul>
  5063. <p>for contributing to the mods evolution into what it is today.</p>
  5064.  
  5065. <div class="sigmod-community">
  5066. <div class="community-header">
  5067. Community
  5068. </div>
  5069. <div class="flex">
  5070. <div class="community-discord-logo">
  5071. <svg width="31" height="30" viewBox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" style="margin-top: 3px;">
  5072. <path d="M19.4566 5.35132C21.7154 8.83814 22.8309 12.7712 22.4139 17.299C22.4121 17.3182 22.4026 17.3358 22.3876 17.3473C20.6771 18.666 19.0199 19.4663 17.3859 19.9971C17.3732 20.0011 17.3596 20.0009 17.347 19.9964C17.3344 19.992 17.3234 19.9835 17.3156 19.9721C16.9382 19.4207 16.5952 18.8393 16.2947 18.2287C16.2774 18.1928 16.2932 18.1495 16.3287 18.1353C16.8734 17.9198 17.3914 17.6615 17.8896 17.3557C17.9289 17.3316 17.9314 17.2725 17.8951 17.2442C17.7894 17.1617 17.6846 17.0751 17.5844 16.9885C17.5656 16.9725 17.5404 16.9693 17.5191 16.9801C14.2844 18.5484 10.7409 18.5484 7.46792 16.9801C7.44667 16.9701 7.42142 16.9735 7.40317 16.9893C7.30317 17.0759 7.19817 17.1617 7.09342 17.2442C7.05717 17.2725 7.06017 17.3316 7.09967 17.3557C7.59792 17.6557 8.11592 17.9198 8.65991 18.1363C8.69517 18.1505 8.71192 18.1928 8.69442 18.2287C8.40042 18.8401 8.05742 19.4215 7.67292 19.9729C7.65617 19.9952 7.62867 20.0055 7.60267 19.9971C5.97642 19.4663 4.31917 18.666 2.60868 17.3473C2.59443 17.3358 2.58418 17.3174 2.58268 17.2982C2.23418 13.3817 2.94442 9.41613 5.53717 5.35053C5.54342 5.33977 5.55292 5.33137 5.56392 5.32638C6.83967 4.71165 8.20642 4.25939 9.63491 4.00111C9.66091 3.99691 9.68691 4.00951 9.70041 4.03365C9.87691 4.36176 10.0787 4.78252 10.2152 5.12637C11.7209 4.88489 13.2502 4.88489 14.7874 5.12637C14.9239 4.78987 15.1187 4.36176 15.2944 4.03365C15.3007 4.02167 15.3104 4.01208 15.3221 4.00623C15.3339 4.00039 15.3471 3.99859 15.3599 4.00111C16.7892 4.26018 18.1559 4.71244 19.4306 5.32638C19.4419 5.33137 19.4511 5.33977 19.4566 5.35132ZM10.9807 12.798C10.9964 11.6401 10.1924 10.6821 9.18316 10.6821C8.18217 10.6821 7.38592 11.6317 7.38592 12.798C7.38592 13.9639 8.19792 14.9136 9.18316 14.9136C10.1844 14.9136 10.9807 13.9639 10.9807 12.798ZM17.6261 12.798C17.6419 11.6401 16.8379 10.6821 15.8289 10.6821C14.8277 10.6821 14.0314 11.6317 14.0314 12.798C14.0314 13.9639 14.8434 14.9136 15.8289 14.9136C16.8379 14.9136 17.6261 13.9639 17.6261 12.798Z" fill="white"></path>
  5073. </svg>
  5074. </div>
  5075. <div class="community-discord">
  5076. <a href="https://dsc.gg/sigmodz" target="_blank">dsc.gg/sigmodz</a>
  5077. </div>
  5078. </div>
  5079. </div>
  5080. <div>
  5081. Install <a href="https://greasyfork.org/scripts/483587-sigmally-fixes-v2" target="_blank">Sigmally Fixes</a> for better performance!
  5082. </div>
  5083.  
  5084. <div class="mt-auto flex f-column g-10">
  5085. <div class="brand_yt">
  5086. <div class="yt_wrapper" onclick="window.open('https://www.youtube.com/@sigmallyCursed')">
  5087. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="26" height="26">
  5088. <path d="M12 39c-.549 0-1.095-.15-1.578-.447A3.008 3.008 0 0 1 9 36V12c0-1.041.54-2.007 1.422-2.553a3.014 3.014 0 0 1 2.919-.132l24 12a3.003 3.003 0 0 1 0 5.37l-24 12c-.42.21-.885.315-1.341.315z" fill="#ffffff"></path>
  5089. </svg>
  5090. <span style="font-size: 16px;">Cursed</span>
  5091. </div>
  5092. <div class="yt_wrapper" onclick="window.open('https://www.youtube.com/@sigmally')">
  5093. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="26" height="26">
  5094. <path d="M12 39c-.549 0-1.095-.15-1.578-.447A3.008 3.008 0 0 1 9 36V12c0-1.041.54-2.007 1.422-2.553a3.014 3.014 0 0 1 2.919-.132l24 12a3.003 3.003 0 0 1 0 5.37l-24 12c-.42.21-.885.315-1.341.315z" fill="#ffffff"></path>
  5095. </svg>
  5096. <span style="font-size: 16px;">Sigmally</span>
  5097. </div>
  5098. </div>
  5099. <div class="w-100 centerXY">
  5100. <div class="justify-sb" style="width: 50%;">
  5101. <a href="https://mod.czrsd.com/" target="_blank">Website</a>
  5102. <a href="https://mod.czrsd.com/changelog" target="_blank">Changelog</a>
  5103. <a href="https://mod.czrsd.com/tos" target="_blank">Terms of Service</a>
  5104. </div>
  5105. </div>
  5106. </div>
  5107. </div>
  5108. </div>
  5109. </div>
  5110. </div>
  5111. `;
  5112. document.body.append(mod_menu);
  5113.  
  5114. const styleTag = document.createElement('style');
  5115. styleTag.innerHTML = this.style;
  5116. document.head.append(styleTag);
  5117.  
  5118. this.getSettings();
  5119. this.smallMods();
  5120. this.setInputActions();
  5121.  
  5122. mod_menu.addEventListener('click', (event) => {
  5123. if (event.target.closest('.mod_menu_wrapper')) return;
  5124.  
  5125. mod_menu.style.opacity = 0;
  5126. setTimeout(() => {
  5127. mod_menu.style.display = 'none';
  5128. }, 300);
  5129. });
  5130.  
  5131. function openModTab(tabId) {
  5132. const allTabs = document.getElementsByClassName('mod_tab');
  5133. const allTabButtons = document.querySelectorAll('.mod_nav_btn');
  5134.  
  5135. for (const tab of allTabs) {
  5136. tab.style.opacity = 0;
  5137. setTimeout(() => {
  5138. tab.style.display = 'none';
  5139. }, 200);
  5140. }
  5141.  
  5142. allTabButtons.forEach((tabBtn) =>
  5143. tabBtn.classList.remove('mod_selected')
  5144. );
  5145.  
  5146. if (tabId === 'mod_gallery') {
  5147. mods.updateGallery();
  5148. }
  5149.  
  5150. const selectedTab = byId(tabId);
  5151. setTimeout(() => {
  5152. selectedTab.style.display = 'flex';
  5153. setTimeout(() => {
  5154. selectedTab.style.opacity = 1;
  5155. }, 10);
  5156. }, 200);
  5157. this.id && this.classList.add('mod_selected');
  5158. }
  5159.  
  5160. window.openModTab = openModTab;
  5161.  
  5162. document.querySelectorAll('.mod_nav_btn').forEach((tabBtn) => {
  5163. tabBtn.addEventListener('click', function () {
  5164. openModTab.call(
  5165. this,
  5166. this.id.replace('tab_', 'mod_').replace('_btn', '')
  5167. );
  5168. });
  5169. });
  5170.  
  5171. const openMenu = document.querySelectorAll(
  5172. '#clans_and_settings button'
  5173. )[1];
  5174. openMenu.removeAttribute('onclick');
  5175. openMenu.addEventListener('click', () => {
  5176. mod_menu.style.display = 'flex';
  5177. setTimeout(() => {
  5178. mod_menu.style.opacity = 1;
  5179. }, 10);
  5180. });
  5181.  
  5182. const closeModal = byId('closeBtn');
  5183. closeModal.addEventListener('click', () => {
  5184. mod_menu.style.opacity = 0;
  5185. setTimeout(() => {
  5186. mod_menu.style.display = 'none';
  5187. }, 300);
  5188. });
  5189.  
  5190. const fontSelectContainer = document.querySelector(
  5191. '#font-select-container'
  5192. );
  5193.  
  5194. try {
  5195. const fonts = await this.getGoogleFonts();
  5196.  
  5197. const { container: selectElement, selectButton } =
  5198. this.render_sm_select(
  5199. 'Select Font',
  5200. fonts,
  5201. { width: '200px' },
  5202. modSettings.game.font
  5203. );
  5204.  
  5205. const resetFont = document.createElement('button');
  5206. resetFont.classList.add('resetButton');
  5207.  
  5208. resetFont.addEventListener('click', () => {
  5209. if (modSettings.game.font === 'Ubuntu') return;
  5210.  
  5211. modSettings.game.font = 'Ubuntu';
  5212. updateStorage();
  5213. selectElement.value = 'Ubuntu';
  5214.  
  5215. // just change the text of the selectButton
  5216. selectButton.querySelector('span').textContent = 'Ubuntu';
  5217. });
  5218.  
  5219. const container = document.createElement('div');
  5220. container.classList.add('centerXY', 'g-5');
  5221. container.append(resetFont, selectElement);
  5222.  
  5223. selectElement.addEventListener('change', (e) => {
  5224. const font = e.detail;
  5225. const link = document.createElement('link');
  5226. link.href = `https://fonts.googleapis.com/css2?family=${font}&display=swap`;
  5227. link.rel = 'stylesheet';
  5228. document.head.appendChild(link);
  5229.  
  5230. modSettings.game.font = font;
  5231. updateStorage();
  5232. });
  5233.  
  5234. fontSelectContainer.replaceWith(container);
  5235. } catch (e) {
  5236. fontSelectContainer.replaceWith(
  5237. "Couldn't load fonts, try again later."
  5238. );
  5239. console.error(e);
  5240. }
  5241.  
  5242. if (modSettings.game.font !== 'Ubuntu') {
  5243. const link = document.createElement('link');
  5244. link.href = `https://fonts.googleapis.com/css2?family=${modSettings.game.font}&display=swap`;
  5245. link.rel = 'stylesheet';
  5246. document.head.appendChild(link);
  5247. }
  5248.  
  5249. const macroSettings = () => {
  5250. const allSettingNames =
  5251. document.querySelectorAll('.setting-card-name');
  5252.  
  5253. for (const settingName of Object.values(allSettingNames)) {
  5254. settingName.addEventListener('click', (event) => {
  5255. const settingCardWrappers = document.querySelectorAll(
  5256. '.setting-card-wrapper'
  5257. );
  5258. const currentWrapper = Object.values(
  5259. settingCardWrappers
  5260. ).filter(
  5261. (wrapper) =>
  5262. wrapper.querySelector('.setting-card-name')
  5263. .textContent === settingName.textContent
  5264. )[0];
  5265. const settingParameters = currentWrapper.querySelector(
  5266. '.setting-parameters'
  5267. );
  5268.  
  5269. settingParameters.style.display =
  5270. settingParameters.style.display === 'none'
  5271. ? 'block'
  5272. : 'none';
  5273. });
  5274. }
  5275. };
  5276. macroSettings();
  5277.  
  5278. const playTimerToggle = byId('playTimerToggle');
  5279. playTimerToggle.addEventListener('change', () => {
  5280. modSettings.playTimer = playTimerToggle.checked;
  5281. updateStorage();
  5282. });
  5283.  
  5284. const mouseTrackerToggle = byId('mouseTrackerToggle');
  5285. mouseTrackerToggle.addEventListener('change', () => {
  5286. modSettings.mouseTracker = mouseTrackerToggle.checked;
  5287. updateStorage();
  5288. });
  5289.  
  5290. const macroSpeed = byId('macroSpeed');
  5291. const macroSpeedText = byId('macroSpeedText');
  5292.  
  5293. macroSpeed.addEventListener('input', () => {
  5294. modSettings.macros.feedSpeed = macroSpeed.value;
  5295. macroSpeedText.textContent = `${modSettings.macros.feedSpeed.toString()}ms`;
  5296. updateStorage();
  5297. });
  5298.  
  5299. // Reset settings - Mod
  5300. const resetModSettings = byId('resetModSettings');
  5301. resetModSettings.addEventListener('click', () => {
  5302. if (
  5303. confirm(
  5304. 'Are you sure you want to reset the mod settings? A reload is required.'
  5305. )
  5306. ) {
  5307. this.removeStorage(storageName);
  5308. location.reload();
  5309. }
  5310. });
  5311.  
  5312. // Reset settings - Game
  5313. const resetGameSettings = byId('resetGameSettings');
  5314. resetGameSettings.addEventListener('click', () => {
  5315. if (
  5316. confirm(
  5317. 'Are you sure you want to reset the game settings? Your nick and more settings will be lost. A reload is required.'
  5318. )
  5319. ) {
  5320. window.settings.gameSettings = null;
  5321. this.removeStorage('settings');
  5322. location.reload();
  5323. }
  5324. });
  5325.  
  5326. // EventListeners for auth buttons
  5327. const createAccountBtn = byId('createAccount');
  5328. const loginBtn = byId('login');
  5329.  
  5330. createAccountBtn.addEventListener('click', () => {
  5331. this.createSignInWrapper(false);
  5332. });
  5333. loginBtn.addEventListener('click', () => {
  5334. this.createSignInWrapper(true);
  5335. });
  5336. },
  5337.  
  5338. render_sm_select(label, items, style = {}, defaultValue) {
  5339. const createElement = (tag, styles, text = '') => {
  5340. const el = document.createElement(tag);
  5341. el.textContent = text;
  5342. Object.assign(el.style, styles);
  5343. return el;
  5344. };
  5345.  
  5346. const defaultcontainerStyles = {
  5347. position: 'relative',
  5348. display: 'inline-block',
  5349. };
  5350.  
  5351. const container = createElement('div', {
  5352. ...defaultcontainerStyles,
  5353. ...style,
  5354. });
  5355.  
  5356. const selectButton = document.createElement('div');
  5357. selectButton.style.cssText =
  5358. 'background: rgba(0, 0, 0, 0.4); color: #fff; border: 1px solid #A2A2A2; border-radius: 5px; padding: 8px; cursor: pointer; display: flex; justify-content: space-between; align-items: center;';
  5359.  
  5360. selectButton.innerHTML = `
  5361. <span>${label}</span>
  5362. <svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill="#000000" width="20">
  5363. <path fill="#fafafa" d="M13.098 8H6.902c-.751 0-1.172.754-.708 1.268L9.292 12.7c.36.399 1.055.399 1.416 0l3.098-3.433C14.27 8.754 13.849 8 13.098 8Z"></path>
  5364. </svg>
  5365. `;
  5366.  
  5367. if (defaultValue && items.includes(defaultValue)) {
  5368. selectButton.innerHTML = `<span>${defaultValue}</span> ${
  5369. selectButton.innerHTML.split('</svg>')[1]
  5370. }`;
  5371. }
  5372.  
  5373. container.appendChild(selectButton);
  5374.  
  5375. const dropdown = createElement('div', {
  5376. display: 'none',
  5377. position: 'absolute',
  5378. background: '#111',
  5379. color: '#fafafa',
  5380. borderRadius: '0 0 10px 10px',
  5381. padding: '5px 0',
  5382. zIndex: '999999',
  5383. maxHeight: '200px',
  5384. overflowY: 'auto',
  5385. });
  5386.  
  5387. const searchBox = createElement('input', {
  5388. width: '100%',
  5389. padding: '5px',
  5390. marginBottom: '5px',
  5391. background: '#222',
  5392. border: 'none',
  5393. color: '#fff',
  5394. });
  5395. searchBox.placeholder = 'Search...';
  5396.  
  5397. dropdown.append(searchBox);
  5398.  
  5399. items.forEach((item) => {
  5400. const option = createElement(
  5401. 'div',
  5402. { padding: '5px', cursor: 'pointer' },
  5403. item
  5404. );
  5405. option.onclick = () => {
  5406. selectButton.innerHTML = `
  5407. <span>${item}</span>
  5408. <svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill="#000000" width="20">
  5409. <path fill="#fafafa" d="M13.098 8H6.902c-.751 0-1.172.754-.708 1.268L9.292 12.7c.36.399 1.055.399 1.416 0l3.098-3.433C14.27 8.754 13.849 8 13.098 8Z"></path>
  5410. </svg>`;
  5411. dropdown.style.display = 'none';
  5412. container.dispatchEvent(
  5413. new CustomEvent('change', { detail: item })
  5414. );
  5415. };
  5416. option.onmouseover = (e) =>
  5417. (e.target.style.background = '#555');
  5418. option.onmouseout = (e) =>
  5419. (e.target.style.background = 'transparent');
  5420. dropdown.append(option);
  5421. });
  5422.  
  5423. container.append(dropdown);
  5424.  
  5425. selectButton.onclick = () => {
  5426. dropdown.style.display =
  5427. dropdown.style.display === 'none' ? 'block' : 'none';
  5428. };
  5429.  
  5430. document.onclick = (e) => {
  5431. if (!container.contains(e.target))
  5432. dropdown.style.display = 'none';
  5433. };
  5434.  
  5435. searchBox.addEventListener('input', () => {
  5436. const filter = searchBox.value.toLowerCase();
  5437. Array.from(dropdown.children)
  5438. .slice(1)
  5439. .forEach((item) => {
  5440. item.style.display = item.textContent
  5441. .toLowerCase()
  5442. .includes(filter)
  5443. ? 'block'
  5444. : 'none';
  5445. });
  5446. });
  5447.  
  5448. return { container, selectButton };
  5449. },
  5450.  
  5451. setProfile(user) {
  5452. const img = byId('my-profile-img');
  5453. const name = byId('my-profile-name');
  5454. const role = byId('my-profile-role');
  5455. const bioText = byId('my-profile-bio');
  5456. const badges = byId('my-profile-badges');
  5457.  
  5458. const bio = user.bio ? user.bio : 'No bio.';
  5459.  
  5460. img.src = user.imageURL;
  5461. name.innerText = user.username;
  5462. role.innerText = user.role;
  5463. bioText.innerHTML = bio;
  5464. badges.innerHTML =
  5465. user.badges && user.badges.length > 0
  5466. ? user.badges
  5467. .map(
  5468. (badge) =>
  5469. `<span class="mod_badge">${badge}</span>`
  5470. )
  5471. .join('')
  5472. : '<span>User has no badges.</span>';
  5473.  
  5474. role.classList.add(`${user.role}_role`);
  5475. },
  5476.  
  5477. getSettings() {
  5478. const mod_qaccess = document.querySelector('#mod_qaccess');
  5479. const settingsGrid = document.querySelector(
  5480. '#settings > .checkbox-grid'
  5481. );
  5482. const settingsNames =
  5483. settingsGrid.querySelectorAll('label:not([class])');
  5484. const inputs = settingsGrid.querySelectorAll('input');
  5485.  
  5486. inputs.forEach((checkbox, index) => {
  5487. if (
  5488. checkbox.id === 'showMinimap' ||
  5489. checkbox.id === 'darkTheme'
  5490. )
  5491. return;
  5492. const modrow = document.createElement('div');
  5493. modrow.classList.add('justify-sb', 'p-2');
  5494.  
  5495. if (
  5496. checkbox.id === 'showChat' ||
  5497. checkbox.id === 'showPosition' ||
  5498. checkbox.id === 'showNames' ||
  5499. checkbox.id === 'showSkins'
  5500. ) {
  5501. modrow.style.display = 'none';
  5502. }
  5503.  
  5504. modrow.innerHTML = `
  5505. <span>${settingsNames[index].textContent}</span>
  5506. <div class="modCheckbox" id="${checkbox.id}_wrapper"></div>
  5507. `;
  5508. mod_qaccess.append(modrow);
  5509.  
  5510. const cbWrapper = byId(`${checkbox.id}_wrapper`);
  5511. cbWrapper.appendChild(checkbox);
  5512.  
  5513. cbWrapper.appendChild(
  5514. Object.assign(document.createElement('label'), {
  5515. classList: ['cbx'],
  5516. htmlFor: checkbox.id,
  5517. })
  5518. );
  5519. });
  5520. },
  5521.  
  5522. themes() {
  5523. const elements = [
  5524. '#menu',
  5525. '#title',
  5526. '.top-users__inner',
  5527. '#left-menu',
  5528. '.menu-links',
  5529. '.menu--stats-mode',
  5530. '#left_ad_block',
  5531. '#ad_bottom',
  5532. '.ad-block',
  5533. '#left_ad_block > .right-menu',
  5534. '#text-block > .right-menu',
  5535. '#sigma-pass .connecting__content',
  5536. '#sigma-status',
  5537. '.alert',
  5538. ];
  5539.  
  5540. const customTextElements = [
  5541. '#challenge-coins .alert-heading',
  5542. '#sigma-pass h3',
  5543. '.alert *',
  5544. ];
  5545.  
  5546. let checkInterval;
  5547. const appliedElements = new Set();
  5548.  
  5549. window.themeElements = elements;
  5550.  
  5551. const themeEditor = document.createElement('div');
  5552. themeEditor.classList.add('themeEditor');
  5553. themeEditor.style.display = 'none';
  5554.  
  5555. themeEditor.innerHTML = `
  5556. <div class="theme_editor_header">
  5557. <h3>Theme Editor</h3>
  5558. <button class="btn closeBtn" id="closeThemeEditor">
  5559. <svg width="22" height="20" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
  5560. <path d="M1.6001 14.4L14.4001 1.59998M14.4001 14.4L1.6001 1.59998" stroke="#fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path>
  5561. </svg>
  5562. </button>
  5563. </div>
  5564. <hr />
  5565. <main class="theme_editor_content">
  5566. <div class="centerXY" style="justify-content: flex-end;gap: 10px">
  5567. <span class="text">Select Theme Type: </span>
  5568. <select class="form-control" style="background: #222; color: #fff; width: 150px" id="theme-type-select">
  5569. <option>Static Color</option>
  5570. <option>Gradient</option>
  5571. <option>Image / Gif</option>
  5572. </select>
  5573. </div>
  5574.  
  5575. <div id="theme_editor_color" class="theme-editor-tab">
  5576. <div class="centerXY">
  5577. <label for="theme-editor-bgcolorinput" class="text">Background color:</label>
  5578. <input type="color" value="#000000" class="colorInput whiteBorder_colorInput" id="theme-editor-bgcolorinput"/>
  5579. </div>
  5580. <div class="centerXY">
  5581. <label for="theme-editor-colorinput" class="text">Text color:</label>
  5582. <input type="color" value="#000000" class="colorInput whiteBorder_colorInput" id="theme-editor-colorinput"/>
  5583. </div>
  5584. <div style="background-color: #000000" class="themes_preview" id="color_preview">
  5585. <span class="text" style="color: #fff; font-size: 9px;">preview</span>
  5586. </div>
  5587. <div class="centerY" style="gap: 10px; margin-top: 10px;">
  5588. <input type="text" class="form-control" style="background: #222; color: #fff;" maxlength="15" placeholder="Theme name..." id="colorThemeName"/>
  5589. <button class="btn btn-success" id="saveColorTheme">Save</button>
  5590. </div>
  5591. </div>
  5592.  
  5593.  
  5594. <div id="theme_editor_gradient" class="theme-editor-tab" style="display: none;">
  5595. <div class="centerXY">
  5596. <label for="theme-editor-gcolor1" class="text">Color 1:</label>
  5597. <input type="color" value="#000000" class="colorInput whiteBorder_colorInput" id="theme-editor-gcolor1"/>
  5598. </div>
  5599. <div class="centerXY">
  5600. <label for="theme-editor-g_color" class="text">Color 2:</label>
  5601. <input type="color" value="#ffffff" class="colorInput whiteBorder_colorInput" id="theme-editor-g_color"/>
  5602. </div>
  5603. <div class="centerXY">
  5604. <label for="theme-editor-gcolor2" class="text">Text Color:</label>
  5605. <input type="color" value="#ffffff" class="colorInput whiteBorder_colorInput" id="theme-editor-gcolor2"/>
  5606. </div>
  5607.  
  5608. <div class="centerXY" style="gap: 10px">
  5609. <label for="gradient-type" class="text">Gradient Type:</label>
  5610. <select id="gradient-type" class="form-control" style="background: #222; color: #fff; width: 120px;">
  5611. <option value="linear">Linear</option>
  5612. <option value="radial">Radial</option>
  5613. </select>
  5614. </div>
  5615.  
  5616. <div id="theme-editor-gradient_angle" class="centerY" style="gap: 10px; width: 100%">
  5617. <label for="g_angle" class="text" id="gradient_angle_text" style="width: 115px;">Angle (0deg):</label>
  5618. <input type="range" id="g_angle" value="0" min="0" max="360">
  5619. </div>
  5620.  
  5621. <div style="background: linear-gradient(0deg, #000, #fff)" class="themes_preview" id="gradient_preview">
  5622. <span class="text" style="color: #fff; font-size: 9px;">preview</span>
  5623. </div>
  5624. <div class="centerY" style="gap: 10px; margin-top: 10px;">
  5625. <input type="text" class="form-control" style="background: #222; color: #fff;" placeholder="Theme name..." id="GradientThemeName"/>
  5626. <button class="btn btn-success" id="saveGradientTheme">Save</button>
  5627. </div>
  5628. </div>
  5629.  
  5630. <div id="theme_editor_image" class="theme-editor-tab" style="display: none">
  5631. <div class="centerXY">
  5632. <input type="text" id="theme-editor-imagelink" placeholder="Image / GIF URL (https://i.ibb.co/k6hn4v0/Galaxy-Example.png)" class="form-control" style="background: #222; color: #fff"/>
  5633. </div>
  5634. <div class="centerXY" style="margin: 5px; gap: 5px;">
  5635. <label for="theme-editor-textcolorImage" class="text">Text Color: </label>
  5636. <input type="color" class="colorInput whiteBorder_colorInput" value="#ffffff" id="theme-editor-textcolorImage"/>
  5637. </div>
  5638.  
  5639. <div style="background: url('https://i.ibb.co/k6hn4v0/Galaxy-Example.png'); background-position: center; background-size: cover;" class="themes_preview" id="image_preview">
  5640. <span class="text" style="color: #fff; font-size: 9px;">preview</span>
  5641. </div>
  5642. <div class="centerY" style="gap: 10px; margin-top: 10px;">
  5643. <input type="text" class="form-control" style="background: #222; color: #fff;" placeholder="Theme name..." id="imageThemeName"/>
  5644. <button class="btn btn-success" id="saveImageTheme">Save</button>
  5645. </div>
  5646. </div>
  5647. </main>
  5648. `;
  5649.  
  5650. document.body.append(themeEditor);
  5651.  
  5652. setTimeout(() => {
  5653. document
  5654. .querySelectorAll('.stats-btn__share-btn')[1]
  5655. .querySelector('rect')
  5656. .remove();
  5657.  
  5658. const themeTypeSelect = byId('theme-type-select');
  5659. const colorTab = byId('theme_editor_color');
  5660. const gradientTab = byId('theme_editor_gradient');
  5661. const imageTab = byId('theme_editor_image');
  5662. const gradientAngleDiv = byId('theme-editor-gradient_angle');
  5663.  
  5664. themeTypeSelect.addEventListener('change', function () {
  5665. const selectedOption = themeTypeSelect.value;
  5666. switch (selectedOption) {
  5667. case 'Static Color':
  5668. colorTab.style.display = 'flex';
  5669. gradientTab.style.display = 'none';
  5670. imageTab.style.display = 'none';
  5671. break;
  5672. case 'Gradient':
  5673. colorTab.style.display = 'none';
  5674. gradientTab.style.display = 'flex';
  5675. imageTab.style.display = 'none';
  5676. break;
  5677. case 'Image / Gif':
  5678. colorTab.style.display = 'none';
  5679. gradientTab.style.display = 'none';
  5680. imageTab.style.display = 'flex';
  5681. break;
  5682. default:
  5683. colorTab.style.display = 'flex';
  5684. gradientTab.style.display = 'none';
  5685. imageTab.style.display = 'none';
  5686. }
  5687. });
  5688.  
  5689. const colorInputs = document.querySelectorAll(
  5690. '#theme_editor_color .colorInput'
  5691. );
  5692. colorInputs.forEach((input) => {
  5693. input.addEventListener('input', function () {
  5694. const bgColorInput = byId(
  5695. 'theme-editor-bgcolorinput'
  5696. ).value;
  5697. const textColorInput = byId(
  5698. 'theme-editor-colorinput'
  5699. ).value;
  5700.  
  5701. applyColorTheme(bgColorInput, textColorInput);
  5702. });
  5703. });
  5704.  
  5705. const gradientInputs = document.querySelectorAll(
  5706. '#theme_editor_gradient .colorInput'
  5707. );
  5708. gradientInputs.forEach((input) => {
  5709. input.addEventListener('input', function () {
  5710. const gColor1 = byId('theme-editor-gcolor1').value;
  5711. const gColor2 = byId('theme-editor-g_color').value;
  5712. const gTextColor = byId('theme-editor-gcolor2').value;
  5713. const gAngle = byId('g_angle').value;
  5714. const gradientType = byId('gradient-type').value;
  5715.  
  5716. applyGradientTheme(
  5717. gColor1,
  5718. gColor2,
  5719. gTextColor,
  5720. gAngle,
  5721. gradientType
  5722. );
  5723. });
  5724. });
  5725.  
  5726. const imageInputs = document.querySelectorAll(
  5727. '#theme_editor_image .colorInput'
  5728. );
  5729. imageInputs.forEach((input) => {
  5730. input.addEventListener('input', function () {
  5731. const imageLinkInput = byId(
  5732. 'theme-editor-imagelink'
  5733. ).value;
  5734. const textColorImageInput = byId(
  5735. 'theme-editor-textcolorImage'
  5736. ).value;
  5737.  
  5738. let img;
  5739. if (imageLinkInput === '') {
  5740. img = 'https://i.ibb.co/k6hn4v0/Galaxy-Example.png';
  5741. } else {
  5742. img = imageLinkInput;
  5743. }
  5744. applyImageTheme(img, textColorImageInput);
  5745. });
  5746. });
  5747. const image_preview = byId('image_preview');
  5748. const image_link = byId('theme-editor-imagelink');
  5749.  
  5750. let isWriting = false;
  5751. let timeoutId;
  5752.  
  5753. image_link.addEventListener('input', () => {
  5754. if (!isWriting) {
  5755. isWriting = true;
  5756. } else {
  5757. clearTimeout(timeoutId);
  5758. }
  5759.  
  5760. timeoutId = setTimeout(() => {
  5761. const imageLinkInput = image_link.value;
  5762. const textColorImageInput = byId(
  5763. 'theme-editor-textcolorImage'
  5764. ).value;
  5765.  
  5766. let img;
  5767. if (imageLinkInput === '') {
  5768. img = 'https://i.ibb.co/k6hn4v0/Galaxy-Example.png';
  5769. } else {
  5770. img = imageLinkInput;
  5771. }
  5772.  
  5773. applyImageTheme(img, textColorImageInput);
  5774. isWriting = false;
  5775. }, 1000);
  5776. });
  5777.  
  5778. const gradientTypeSelect = byId('gradient-type');
  5779. const angleInput = byId('g_angle');
  5780.  
  5781. gradientTypeSelect.addEventListener('change', function () {
  5782. const selectedType = gradientTypeSelect.value;
  5783. gradientAngleDiv.style.display =
  5784. selectedType === 'linear' ? 'flex' : 'none';
  5785.  
  5786. const gColor1 = byId('theme-editor-gcolor1').value;
  5787. const gColor2 = byId('theme-editor-g_color').value;
  5788. const gTextColor = byId('theme-editor-gcolor2').value;
  5789. const gAngle = byId('g_angle').value;
  5790.  
  5791. applyGradientTheme(
  5792. gColor1,
  5793. gColor2,
  5794. gTextColor,
  5795. gAngle,
  5796. selectedType
  5797. );
  5798. });
  5799.  
  5800. angleInput.addEventListener('input', function () {
  5801. const gradient_angle_text = byId('gradient_angle_text');
  5802. gradient_angle_text.innerText = `Angle (${angleInput.value}deg): `;
  5803. const gColor1 = byId('theme-editor-gcolor1').value;
  5804. const gColor2 = byId('theme-editor-g_color').value;
  5805. const gTextColor = byId('theme-editor-gcolor2').value;
  5806. const gAngle = byId('g_angle').value;
  5807. const gradientType = byId('gradient-type').value;
  5808.  
  5809. applyGradientTheme(
  5810. gColor1,
  5811. gColor2,
  5812. gTextColor,
  5813. gAngle,
  5814. gradientType
  5815. );
  5816. });
  5817.  
  5818. function applyColorTheme(bgColor, textColor) {
  5819. const previewDivs = document.querySelectorAll(
  5820. '#theme_editor_color .themes_preview'
  5821. );
  5822. previewDivs.forEach((previewDiv) => {
  5823. previewDiv.style.backgroundColor = bgColor;
  5824. const textSpan = previewDiv.querySelector('span.text');
  5825. textSpan.style.color = textColor;
  5826. });
  5827. }
  5828.  
  5829. function applyGradientTheme(
  5830. gColor1,
  5831. gColor2,
  5832. gTextColor,
  5833. gAngle,
  5834. gradientType
  5835. ) {
  5836. const previewDivs = document.querySelectorAll(
  5837. '#theme_editor_gradient .themes_preview'
  5838. );
  5839. previewDivs.forEach((previewDiv) => {
  5840. const gradient =
  5841. gradientType === 'linear'
  5842. ? `linear-gradient(${gAngle}deg, ${gColor1}, ${gColor2})`
  5843. : `radial-gradient(circle, ${gColor1}, ${gColor2})`;
  5844. previewDiv.style.background = gradient;
  5845. const textSpan = previewDiv.querySelector('span.text');
  5846. textSpan.style.color = gTextColor;
  5847. });
  5848. }
  5849.  
  5850. function applyImageTheme(imageLink, textColor) {
  5851. const previewDivs = document.querySelectorAll(
  5852. '#theme_editor_image .themes_preview'
  5853. );
  5854. previewDivs.forEach((previewDiv) => {
  5855. previewDiv.style.backgroundImage = `url('${imageLink}')`;
  5856. const textSpan = previewDiv.querySelector('span.text');
  5857. textSpan.style.color = textColor;
  5858. });
  5859. }
  5860.  
  5861. const createTheme = byId('createTheme');
  5862. createTheme.addEventListener('click', () => {
  5863. themeEditor.style.display = 'block';
  5864. });
  5865.  
  5866. const closeThemeEditor = byId('closeThemeEditor');
  5867. closeThemeEditor.addEventListener('click', () => {
  5868. themeEditor.style.display = 'none';
  5869. });
  5870.  
  5871. let themesDiv = byId('themes');
  5872.  
  5873. const saveTheme = (type) => {
  5874. const name = byId(`${type}ThemeName`).value;
  5875. if (!name) return;
  5876.  
  5877. let background, text;
  5878. if (type === 'color') {
  5879. background = byId('theme-editor-bgcolorinput').value;
  5880. text = byId('theme-editor-colorinput').value;
  5881. } else if (type === 'gradient') {
  5882. const gColor1 = byId('theme-editor-gcolor1').value;
  5883. const gColor2 = byId('theme-editor-g_color').value;
  5884. text = byId('theme-editor-gcolor2').value;
  5885. const gAngle = byId('g_angle').value;
  5886. const gradientType = byId('gradient-type').value;
  5887. background = gradientType === 'linear'
  5888. ? `linear-gradient(${gAngle}deg, ${gColor1}, ${gColor2})`
  5889. : `radial-gradient(circle, ${gColor1}, ${gColor2})`;
  5890. } else if (type === 'image') {
  5891. background = byId('theme-editor-imagelink').value;
  5892. text = byId('theme-editor-textcolorImage').value;
  5893. if (!background) return;
  5894. }
  5895.  
  5896. const theme = { name, background, text };
  5897. const themeCard = document.createElement('div');
  5898. themeCard.classList.add('theme');
  5899. themeCard.innerHTML = `
  5900. <div class="themeContent" style="background: ${background.includes('http') ? `url(${theme.preview || background})` : background}; background-size: cover; background-position: center"></div>
  5901. <div class="themeName text" style="color: #fff">${name}</div>
  5902. `;
  5903.  
  5904. themeCard.addEventListener('click', () => toggleTheme(theme));
  5905. themeCard.addEventListener('contextmenu', (ev) => {
  5906. ev.preventDefault();
  5907. if (confirm('Do you want to delete this Theme?')) {
  5908. themeCard.remove();
  5909. const index = modSettings.themes.custom.findIndex(t => t.name === name);
  5910. if (index !== -1) {
  5911. modSettings.themes.custom.splice(index, 1);
  5912. updateStorage();
  5913. }
  5914. }
  5915. });
  5916.  
  5917. themesDiv.appendChild(themeCard);
  5918. modSettings.themes.custom.push(theme);
  5919. updateStorage();
  5920. themeEditor.style.display = 'none';
  5921. themesDiv.scrollTop = themesDiv.scrollHeight;
  5922. };
  5923.  
  5924. byId('saveColorTheme').addEventListener('click', () => saveTheme('color'));
  5925. byId('saveGradientTheme').addEventListener('click', () => saveTheme('gradient'));
  5926. byId('saveImageTheme').addEventListener('click', () => saveTheme('image'));
  5927. });
  5928.  
  5929. const b_inner = document.querySelector('.body__inner');
  5930. let bodyColorElements = b_inner.querySelectorAll(
  5931. '.body__inner > :not(.body__inner), #s-skin-select-icon-text'
  5932. );
  5933.  
  5934. const toggleColor = (element, background, text) => {
  5935. let image = `url("${background}")`;
  5936. if (background.includes('http')) {
  5937. element.style.background = image;
  5938. element.style.backgroundPosition = 'center';
  5939. element.style.backgroundSize = 'cover';
  5940. element.style.backgroundRepeat = 'no-repeat';
  5941. } else {
  5942. element.style.background = background;
  5943. element.style.backgroundRepeat = 'no-repeat';
  5944. }
  5945. element.style.color = text;
  5946. };
  5947.  
  5948. const openSVG = document.querySelector(
  5949. '#clans_and_settings > Button:nth-of-type(2) > svg'
  5950. );
  5951. const openSVGPath = openSVG.querySelector('path');
  5952. openSVG.setAttribute('width', '36');
  5953. openSVG.setAttribute('height', '36');
  5954.  
  5955. const applyThemeToElement = (el, theme) => {
  5956. if (el.matches('#title')) {
  5957. el.style.color = theme.text;
  5958. } else {
  5959. toggleColor(el, theme.background, theme.text);
  5960. }
  5961. appliedElements.add(el);
  5962. };
  5963.  
  5964. const toggleTheme = (theme) => {
  5965. try {
  5966. if (checkInterval) clearInterval(checkInterval);
  5967. appliedElements.clear();
  5968.  
  5969. const applyTheme = () => {
  5970. let allApplied = true;
  5971.  
  5972. elements.forEach((selector) => {
  5973. const elements =
  5974. document.querySelectorAll(selector);
  5975. elements.forEach((el) => {
  5976. if (el && !appliedElements.has(el)) {
  5977. applyThemeToElement(el, theme);
  5978. allApplied = false;
  5979. }
  5980. });
  5981. });
  5982.  
  5983. customTextElements.forEach((qs) => {
  5984. document.querySelectorAll(qs).forEach((el) => {
  5985. if (!appliedElements.has(el)) {
  5986. el.style.setProperty(
  5987. 'color',
  5988. theme.text,
  5989. 'important'
  5990. );
  5991. appliedElements.add(el);
  5992. allApplied = false;
  5993. }
  5994. });
  5995. });
  5996.  
  5997. bodyColorElements.forEach((el) => {
  5998. if (!appliedElements.has(el)) {
  5999. el.style.color = theme.text;
  6000. appliedElements.add(el);
  6001. allApplied = false;
  6002. }
  6003. });
  6004.  
  6005. if (allApplied) {
  6006. clearInterval(checkInterval);
  6007. return;
  6008. }
  6009.  
  6010. const isBright = (color) => {
  6011. if (!color.startsWith('#') || color.length !== 7)
  6012. return false;
  6013. const r = parseInt(color.slice(1, 3), 16);
  6014. const g = parseInt(color.slice(3, 5), 16);
  6015. const b = parseInt(color.slice(5, 7), 16);
  6016. return r * 0.299 + g * 0.587 + b * 0.114 > 186;
  6017. };
  6018.  
  6019. openSVGPath.setAttribute(
  6020. 'fill',
  6021. isBright(theme.text) ? theme.text : '#222'
  6022. );
  6023.  
  6024. modSettings.themes.current = theme.name;
  6025. updateStorage();
  6026. };
  6027.  
  6028. checkInterval = setInterval(applyTheme, 100);
  6029. } catch (e) {
  6030. console.error(e);
  6031. }
  6032. };
  6033.  
  6034. const themes = (window.themes = {
  6035. defaults: [
  6036. {
  6037. name: 'Dark',
  6038. background: '#151515',
  6039. text: '#FFFFFF',
  6040. },
  6041. {
  6042. name: 'White',
  6043. background: '#ffffff',
  6044. text: '#000000',
  6045. },
  6046. {
  6047. name: 'Transparent',
  6048. background: 'rgba(0, 0, 0,0)',
  6049. text: '#FFFFFF',
  6050. },
  6051. ],
  6052. orderly: [
  6053. {
  6054. name: 'THC',
  6055. background: 'linear-gradient(160deg, #9BEC7A, #117500)',
  6056. text: '#000000',
  6057. },
  6058. {
  6059. name: '4 AM',
  6060. background: 'linear-gradient(160deg, #8B0AE1, #111)',
  6061. text: '#FFFFFF',
  6062. },
  6063. {
  6064. name: 'OTO',
  6065. background: 'linear-gradient(160deg, #A20000, #050505)',
  6066. text: '#FFFFFF',
  6067. },
  6068. {
  6069. name: 'Gaming',
  6070. background:
  6071. 'https://i.ibb.co/DwKkQfh/BG-1-lower-quality.jpg',
  6072. text: '#FFFFFF',
  6073. },
  6074. {
  6075. name: 'Shapes',
  6076. background: 'https://i.ibb.co/h8TmVyM/BG-2.png',
  6077. preview:
  6078. 'https://czrsd.com/static/sigmod/themes/BG-2.jpg',
  6079. text: '#FFFFFF',
  6080. },
  6081. {
  6082. name: 'Blue',
  6083. background: 'https://i.ibb.co/9yQBfWj/BG-3.png',
  6084. preview:
  6085. 'https://czrsd.com/static/sigmod/themes/BG-3.jpg',
  6086. text: '#FFFFFF',
  6087. },
  6088. {
  6089. name: 'Blue - 2',
  6090. background: 'https://i.ibb.co/7RJvNCX/BG-4.png',
  6091. preview:
  6092. 'https://czrsd.com/static/sigmod/themes/BG-4.jpg',
  6093. text: '#FFFFFF',
  6094. },
  6095. {
  6096. name: 'Purple',
  6097. background: 'https://i.ibb.co/vxY15Tv/BG-5.png',
  6098. preview:
  6099. 'https://czrsd.com/static/sigmod/themes/BG-5.jpg',
  6100. text: '#FFFFFF',
  6101. },
  6102. {
  6103. name: 'Orange Blue',
  6104. background: 'https://i.ibb.co/99nfFBN/BG-6.png',
  6105. preview:
  6106. 'https://czrsd.com/static/sigmod/themes/BG-6.jpg',
  6107. text: '#FFFFFF',
  6108. },
  6109. {
  6110. name: 'Gradient',
  6111. background: 'https://i.ibb.co/hWMLwLS/BG-7.png',
  6112. preview:
  6113. 'https://czrsd.com/static/sigmod/themes/BG-7.jpg',
  6114. text: '#FFFFFF',
  6115. },
  6116. {
  6117. name: 'Sky',
  6118. background: 'https://i.ibb.co/P4XqDFw/BG-9.png',
  6119. preview:
  6120. 'https://czrsd.com/static/sigmod/themes/BG-9.jpg',
  6121. text: '#000000',
  6122. },
  6123. {
  6124. name: 'Sunset',
  6125. background: 'https://i.ibb.co/0BVbYHC/BG-10.png',
  6126. preview:
  6127. 'https://czrsd.com/static/sigmod/themes/BG-10.jpg',
  6128. text: '#FFFFFF',
  6129. },
  6130. {
  6131. name: 'Galaxy',
  6132. background: 'https://i.ibb.co/MsssDKP/Galaxy.png',
  6133. preview:
  6134. 'https://czrsd.com/static/sigmod/themes/Galaxy.jpg',
  6135. text: '#FFFFFF',
  6136. },
  6137. {
  6138. name: 'Planet',
  6139. background: 'https://i.ibb.co/KLqWM32/Planet.png',
  6140. preview:
  6141. 'https://czrsd.com/static/sigmod/themes/Planet.jpg',
  6142. text: '#FFFFFF',
  6143. },
  6144. {
  6145. name: 'colorful',
  6146. background: 'https://i.ibb.co/VqtB3TX/colorful.png',
  6147. preview:
  6148. 'https://czrsd.com/static/sigmod/themes/colorful.jpg',
  6149. text: '#FFFFFF',
  6150. },
  6151. {
  6152. name: 'Sunset - 2',
  6153. background: 'https://i.ibb.co/TLp2nvv/Sunset.png',
  6154. preview:
  6155. 'https://czrsd.com/static/sigmod/themes/Sunset.jpg',
  6156. text: '#FFFFFF',
  6157. },
  6158. {
  6159. name: 'Epic',
  6160. background: 'https://i.ibb.co/kcv4tvn/Epic.png',
  6161. preview:
  6162. 'https://czrsd.com/static/sigmod/themes/Epic.jpg',
  6163. text: '#FFFFFF',
  6164. },
  6165. {
  6166. name: 'Galaxy - 2',
  6167. background: 'https://i.ibb.co/smRs6V0/galaxy.png',
  6168. preview:
  6169. 'https://czrsd.com/static/sigmod/themes/galaxy2.jpg',
  6170. text: '#FFFFFF',
  6171. },
  6172. {
  6173. name: 'Cloudy',
  6174. background: 'https://i.ibb.co/MCW7Bcd/cloudy.png',
  6175. preview:
  6176. 'https://czrsd.com/static/sigmod/themes/cloudy.jpg',
  6177. text: '#000000',
  6178. },
  6179. ],
  6180. });
  6181.  
  6182. function createThemeCard(theme) {
  6183. const themeCard = document.createElement('div');
  6184. themeCard.classList.add('theme');
  6185. let themeBG;
  6186. if (theme.background.includes('http')) {
  6187. themeBG = `background: url(${
  6188. theme.preview || theme.background
  6189. })`;
  6190. } else {
  6191. themeBG = `background: ${theme.background}`;
  6192. }
  6193. themeCard.innerHTML = `
  6194. <div class="themeContent" style="${themeBG}; background-size: cover; background-position: center"></div>
  6195. <div class="themeName text" style="color: #fff">${theme.name}</div>
  6196. `;
  6197.  
  6198. themeCard.addEventListener('click', () => {
  6199. toggleTheme(theme);
  6200. });
  6201.  
  6202. if (modSettings.themes.custom.includes(theme)) {
  6203. themeCard.addEventListener(
  6204. 'contextmenu',
  6205. (ev) => {
  6206. ev.preventDefault();
  6207. if (confirm('Do you want to delete this Theme?')) {
  6208. themeCard.remove();
  6209. const themeIndex =
  6210. modSettings.themes.custom.findIndex(
  6211. (addedTheme) =>
  6212. addedTheme.name === theme.name
  6213. );
  6214. if (themeIndex !== -1) {
  6215. modSettings.themes.custom.splice(
  6216. themeIndex,
  6217. 1
  6218. );
  6219. updateStorage();
  6220. }
  6221. }
  6222. },
  6223. false
  6224. );
  6225. }
  6226.  
  6227. return themeCard;
  6228. }
  6229.  
  6230. const themesContainer = byId('themes');
  6231.  
  6232. themes.defaults.forEach((theme) => {
  6233. const themeCard = createThemeCard(theme);
  6234. themesContainer.append(themeCard);
  6235. });
  6236.  
  6237. const orderlyThemes = [
  6238. ...themes.orderly,
  6239. ...modSettings.themes.custom,
  6240. ];
  6241. orderlyThemes.sort((a, b) => a.name.localeCompare(b.name));
  6242. orderlyThemes.forEach((theme) => {
  6243. const themeCard = createThemeCard(theme);
  6244. themesContainer.appendChild(themeCard);
  6245. });
  6246.  
  6247. const savedTheme = modSettings.themes.current;
  6248. if (savedTheme) {
  6249. let selectedTheme;
  6250. selectedTheme = themes.defaults.find(
  6251. (theme) => theme.name === savedTheme
  6252. );
  6253. if (!selectedTheme) {
  6254. selectedTheme =
  6255. themes.orderly.find(
  6256. (theme) => theme.name === savedTheme
  6257. ) ||
  6258. modSettings.themes.custom.find(
  6259. (theme) => theme.name === savedTheme
  6260. );
  6261. }
  6262.  
  6263. if (selectedTheme) {
  6264. toggleTheme(selectedTheme);
  6265. }
  6266. }
  6267.  
  6268. const inputBorderRadius = byId('theme-inputBorderRadius');
  6269. const menuBorderRadius = byId('theme-menuBorderRadius');
  6270. const inputBorder = byId('theme-inputBorder');
  6271.  
  6272. function setCSS(key, value, targets, property) {
  6273. modSettings.themes[key] = value;
  6274. targets.forEach((target) => {
  6275. document
  6276. .querySelectorAll(target)
  6277. .forEach((el) => (el.style[property] = value));
  6278. });
  6279. updateStorage();
  6280. }
  6281.  
  6282. inputBorderRadius.value = modSettings.themes.inputBorderRadius
  6283. ? modSettings.themes.inputBorderRadius.replace('px', '')
  6284. : '4';
  6285. menuBorderRadius.value = modSettings.themes.menuBorderRadius
  6286. ? modSettings.themes.menuBorderRadius.replace('px', '')
  6287. : '15';
  6288. inputBorder.checked = modSettings.themes.inputBorder
  6289. ? modSettings.themes.inputBorder === '1px'
  6290. : '1px';
  6291.  
  6292. setCSS(
  6293. 'inputBorderRadius',
  6294. `${inputBorderRadius.value}px`,
  6295. ['.form-control'],
  6296. 'borderRadius'
  6297. );
  6298. setCSS(
  6299. 'menuBorderRadius',
  6300. `${menuBorderRadius.value}px`,
  6301. [...elements, '.text-block'],
  6302. 'borderRadius'
  6303. );
  6304. setCSS(
  6305. 'inputBorder',
  6306. inputBorder.checked ? '1px' : '0px',
  6307. ['.form-control'],
  6308. 'borderWidth'
  6309. );
  6310.  
  6311. inputBorderRadius.addEventListener('input', () =>
  6312. setCSS(
  6313. 'inputBorderRadius',
  6314. `${inputBorderRadius.value}px`,
  6315. ['.form-control'],
  6316. 'borderRadius'
  6317. )
  6318. );
  6319. menuBorderRadius.addEventListener('input', () =>
  6320. setCSS(
  6321. 'menuBorderRadius',
  6322. `${menuBorderRadius.value}px`,
  6323. [...elements, '.text-block'],
  6324. 'borderRadius'
  6325. )
  6326. );
  6327. inputBorder.addEventListener('input', () =>
  6328. setCSS(
  6329. 'inputBorder',
  6330. inputBorder.checked ? '1px' : '0px',
  6331. ['.form-control'],
  6332. 'borderWidth'
  6333. )
  6334. );
  6335.  
  6336. const reset_input_radius = document.getElementById('reset_input_radius');
  6337. const reset_menu_radius = document.getElementById('reset_menu_radius');
  6338.  
  6339. reset_input_radius.addEventListener('click', () => {
  6340. const defaultBorderRadius = 4;
  6341. inputBorderRadius.value = defaultBorderRadius;
  6342. setCSS(
  6343. 'inputBorderRadius',
  6344. `${defaultBorderRadius}px`,
  6345. ['.form-control'],
  6346. 'borderRadius'
  6347. )
  6348. });
  6349.  
  6350. reset_menu_radius.addEventListener('click', () => {
  6351. const defaultBorderRadius = 15;
  6352. menuBorderRadius.value = defaultBorderRadius;
  6353. setCSS(
  6354. 'menuBorderRadius',
  6355. `${defaultBorderRadius}px`,
  6356. [...elements, '.text-block'],
  6357. 'borderRadius'
  6358. )
  6359. });
  6360.  
  6361.  
  6362. const hideDiscordBtns = document.getElementById('hideDiscordBtns');
  6363. const dclinkdiv = document.getElementById('dclinkdiv');
  6364.  
  6365. hideDiscordBtns.addEventListener('change', () => {
  6366. if (hideDiscordBtns.checked) {
  6367. dclinkdiv.classList.add('hidden_full');
  6368. modSettings.themes.hideDiscordBtns = true;
  6369. } else {
  6370. dclinkdiv.classList.remove('hidden_full');
  6371. modSettings.themes.hideDiscordBtns = false;
  6372. }
  6373. updateStorage();
  6374. });
  6375.  
  6376. if (modSettings.themes.hideDiscordBtns) {
  6377. dclinkdiv.classList.add('hidden_full');
  6378. hideDiscordBtns.checked = true;
  6379. }
  6380.  
  6381.  
  6382. const hideLangs = document.getElementById('hideLangs');
  6383. const langsDiv = document.querySelector('.ch-lang');
  6384.  
  6385. hideLangs.addEventListener('change', () => {
  6386. if (hideLangs.checked) {
  6387. langsDiv.classList.add('hidden_full');
  6388. modSettings.themes.hideLangs = true;
  6389. } else {
  6390. langsDiv.classList.remove('hidden_full');
  6391. modSettings.themes.hideLangs = false;
  6392. }
  6393. updateStorage();
  6394. });
  6395.  
  6396. if (modSettings.themes.hideLangs && langsDiv) {
  6397. langsDiv.classList.add('hidden_full');
  6398. hideLangs.checked = true;
  6399. }
  6400.  
  6401.  
  6402. const popup = byId('shop-popup');
  6403. const removeShopPopup = byId('removeShopPopup');
  6404. removeShopPopup.addEventListener('change', () => {
  6405. if (removeShopPopup.checked) {
  6406. popup.classList.add('hidden_full');
  6407. modSettings.settings.removeShopPopup = true;
  6408. } else {
  6409. popup.classList.remove('hidden_full');
  6410. modSettings.settings.removeShopPopup = false;
  6411. }
  6412. updateStorage();
  6413. });
  6414.  
  6415. if (modSettings.settings.removeShopPopup) {
  6416. popup.classList.add('hidden_full');
  6417. removeShopPopup.checked = true;
  6418. }
  6419. },
  6420.  
  6421. chat() {
  6422. const chatDiv = document.createElement('div');
  6423. chatDiv.classList.add('modChat');
  6424. chatDiv.innerHTML = `
  6425. <div class="modChat__inner">
  6426. <button id="scroll-down-btn" class="modButton">↓</button>
  6427. <div class="modchat-chatbuttons">
  6428. <button class="chatButton" id="mainchat">Main</button>
  6429. <button class="chatButton" id="partychat">Party</button>
  6430. <span class="tagText"></span>
  6431. </div>
  6432. <div id="mod-messages" class="scroll"></div>
  6433. <div id="chatInputContainer">
  6434. <input type="text" id="chatSendInput" class="chatInput" placeholder="Login to use the chat" maxlength="250" minlength="1" disabled />
  6435. <button class="chatButton" id="openChatSettings">
  6436. <svg width="15" height="15" viewBox="0 0 20 20" fill="#fff" xmlns="http://www.w3.org/2000/svg">
  6437. <path d="M17.4249 7.45169C15.7658 7.45169 15.0874 6.27836 15.9124 4.83919C16.3891 4.00503 16.1049 2.94169 15.2708 2.46503L13.6849 1.55753C12.9608 1.12669 12.0258 1.38336 11.5949 2.10753L11.4941 2.28169C10.6691 3.72086 9.31242 3.72086 8.47825 2.28169L8.37742 2.10753C7.96492 1.38336 7.02992 1.12669 6.30575 1.55753L4.71992 2.46503C3.88575 2.94169 3.60158 4.01419 4.07825 4.84836C4.91242 6.27836 4.23408 7.45169 2.57492 7.45169C1.62159 7.45169 0.833252 8.23086 0.833252 9.19336V10.8067C0.833252 11.76 1.61242 12.5484 2.57492 12.5484C4.23408 12.5484 4.91242 13.7217 4.07825 15.1609C3.60158 15.995 3.88575 17.0584 4.71992 17.535L6.30575 18.4425C7.02992 18.8734 7.96492 18.6167 8.39575 17.8925L8.49658 17.7184C9.32158 16.2792 10.6783 16.2792 11.5124 17.7184L11.6133 17.8925C12.0441 18.6167 12.9791 18.8734 13.7033 18.4425L15.2891 17.535C16.1233 17.0584 16.4074 15.9859 15.9307 15.1609C15.0966 13.7217 15.7749 12.5484 17.4341 12.5484C18.3874 12.5484 19.1758 11.7692 19.1758 10.8067V9.19336C19.1666 8.24003 18.3874 7.45169 17.4249 7.45169ZM9.99992 12.9792C8.35908 12.9792 7.02075 11.6409 7.02075 10C7.02075 8.35919 8.35908 7.02086 9.99992 7.02086C11.6408 7.02086 12.9791 8.35919 12.9791 10C12.9791 11.6409 11.6408 12.9792 9.99992 12.9792Z" fill="#fff"></path>
  6438. </svg>
  6439. </button>
  6440. <button class="chatButton" id="openEmojiMenu">😎</button>
  6441. <button id="sendButton" class="chatButton">
  6442. Send
  6443. <img src="https://raw.githubusercontent.com/Sigmally/SigMod/main/images/send.svg" width="20" height="20" draggable="false"/>
  6444. </button>
  6445. </div>
  6446. </div>
  6447. `;
  6448. document.body.append(chatDiv);
  6449.  
  6450. const chatContainer = byId('mod-messages');
  6451. const scrollDownButton = byId('scroll-down-btn');
  6452.  
  6453. chatContainer.addEventListener('scroll', () => {
  6454. if (
  6455. chatContainer.scrollHeight - chatContainer.scrollTop >
  6456. 300
  6457. ) {
  6458. scrollDownButton.style.display = 'block';
  6459. }
  6460. if (
  6461. chatContainer.scrollHeight - chatContainer.scrollTop <
  6462. 299 &&
  6463. scrollDownButton.style.display === 'block'
  6464. ) {
  6465. scrollDownButton.style.display = 'none';
  6466. }
  6467. });
  6468.  
  6469. scrollDownButton.addEventListener('click', () => {
  6470. chatContainer.scrollTop = chatContainer.scrollHeight;
  6471. });
  6472.  
  6473. const main = byId('mainchat');
  6474. const party = byId('partychat');
  6475. main.addEventListener('click', () => {
  6476. if (!window.gameSettings.user) {
  6477. const chatSendInput = document.querySelector('#chatSendInput');
  6478. if (!chatSendInput) return;
  6479.  
  6480. chatSendInput.placeholder = 'Login to use the chat';
  6481. chatSendInput.disabled = true;
  6482. }
  6483. if (modSettings.chat.showClientChat) {
  6484. byId('mod-messages').innerHTML = '';
  6485. modSettings.chat.showClientChat = false;
  6486. updateStorage();
  6487. }
  6488. });
  6489. party.addEventListener('click', () => {
  6490. const chatSendInput = document.querySelector('#chatSendInput');
  6491. if (chatSendInput) {
  6492. chatSendInput.placeholder = 'message...';
  6493. chatSendInput.disabled = false;
  6494. }
  6495.  
  6496. if (!modSettings.chat.showClientChat) {
  6497. modSettings.chat.showClientChat = true;
  6498. updateStorage();
  6499. }
  6500. const modMessages = byId('mod-messages');
  6501. if (!modSettings.settings.tag) {
  6502. modMessages.innerHTML = `
  6503. <div class="message">
  6504. <span>
  6505. <span style="color: #5a44eb" class="message_name">[SERVER]</span>: You need to be in a tag to use the SigMod party chat.
  6506. </span>
  6507. </div>
  6508. `;
  6509. } else {
  6510. modMessages.innerHTML = `
  6511. <div class="message">
  6512. <span>
  6513. <span style="color: #5a44eb" class="message_name">[SERVER]</span>: Welcome to the SigMod party chat!
  6514. </span>
  6515. </div>
  6516. `;
  6517. }
  6518. });
  6519.  
  6520. if (modSettings.chat.showClientChat) {
  6521. const chatSendInput = document.querySelector('#chatSendInput');
  6522. if (!chatSendInput) return;
  6523.  
  6524. chatSendInput.placeholder = 'message...';
  6525. chatSendInput.disabled = false;
  6526.  
  6527. setTimeout(() => {
  6528. const modMessages = byId('mod-messages');
  6529. modMessages.innerHTML = `
  6530. <div class="message">
  6531. <span>
  6532. <span style="color: #5a44eb" class="message_name">[SERVER]</span>: Welcome to the SigMod party chat!
  6533. </span>
  6534. </div>
  6535. `;
  6536. }, 1000);
  6537. }
  6538.  
  6539. const text = byId('chatSendInput');
  6540. const send = byId('sendButton');
  6541.  
  6542. send.addEventListener('click', () => {
  6543. let val = text.value;
  6544. if (val === '') return;
  6545.  
  6546. if (modSettings.chat.showClientChat) {
  6547. if (client?.ws?.readyState !== 1) return;
  6548. // party chat message
  6549. client.send({
  6550. type: 'chat-message',
  6551. content: {
  6552. message: val,
  6553. },
  6554. });
  6555. } else {
  6556. // Sigmally chat message: split text into parts if message is longer than 15 characters
  6557. if (val.length > 15) {
  6558. const parts = [];
  6559. let currentPart = '';
  6560.  
  6561. // split the input value into individual words
  6562. val.split(' ').forEach((word) => {
  6563. if (currentPart.length + word.length + 1 <= 15) {
  6564. currentPart += (currentPart ? ' ' : '') + word;
  6565. } else {
  6566. parts.push(currentPart);
  6567. currentPart = word;
  6568. }
  6569. });
  6570.  
  6571. if (currentPart) {
  6572. parts.push(currentPart);
  6573. }
  6574.  
  6575. let index = 0;
  6576. const sendPart = () => {
  6577. if (index < parts.length) {
  6578. window.sendChat(parts[index]);
  6579. index++;
  6580. setTimeout(sendPart, 1000); // 1s cooldown from sigmally
  6581. }
  6582. };
  6583.  
  6584. sendPart();
  6585. } else {
  6586. window.sendChat(val);
  6587. }
  6588. }
  6589.  
  6590. text.value = '';
  6591. text.blur();
  6592. });
  6593.  
  6594. this.chatSettings();
  6595. this.emojiMenu();
  6596. this.getBlockedChatData();
  6597.  
  6598. const chatSettingsContainer = document.querySelector(
  6599. '.chatSettingsContainer'
  6600. );
  6601. const emojisContainer = document.querySelector('.emojisContainer');
  6602.  
  6603. byId('openChatSettings').addEventListener('click', () => {
  6604. if (chatSettingsContainer.classList.contains('hidden_full')) {
  6605. chatSettingsContainer.classList.remove('hidden_full');
  6606. emojisContainer.classList.add('hidden_full');
  6607. } else {
  6608. chatSettingsContainer.classList.add('hidden_full');
  6609. }
  6610. });
  6611.  
  6612. const scrollUpButton = byId('scroll-down-btn');
  6613. let focused = false;
  6614. let typed = false;
  6615.  
  6616. document.addEventListener('keydown', (e) => {
  6617. if (e.key === 'Enter' && text.value.length > 0) {
  6618. send.click();
  6619. focused = false;
  6620. scrollUpButton.click();
  6621. } else if (e.key === 'Enter') {
  6622. if (
  6623. document.activeElement.tagName === 'INPUT' ||
  6624. document.activeElement.tagName === 'TEXTAREA'
  6625. )
  6626. return;
  6627.  
  6628. focused ? text.blur() : text.focus();
  6629. focused = !focused;
  6630. }
  6631. });
  6632.  
  6633. text.addEventListener('input', () => {
  6634. typed = text.value.length > 1;
  6635. });
  6636.  
  6637. text.addEventListener('blur', () => {
  6638. focused = false;
  6639. });
  6640.  
  6641. text.addEventListener('keydown', (e) => {
  6642. const key = e.key.toLowerCase();
  6643. if (key === 'w') {
  6644. e.stopPropagation();
  6645. }
  6646.  
  6647. if (key === ' ') {
  6648. e.stopPropagation();
  6649. }
  6650. });
  6651.  
  6652. // switch to compact chat
  6653. const chatElements = [
  6654. '.modChat',
  6655. '.emojisContainer',
  6656. '.chatSettingsContainer',
  6657. ];
  6658.  
  6659. const emojiBtn = byId('openEmojiMenu');
  6660. const compactChat = byId('compactChat');
  6661. compactChat.addEventListener('change', () => {
  6662. compactChat.checked ? compactMode() : defaultMode();
  6663. });
  6664.  
  6665. function compactMode() {
  6666. chatElements.forEach((querySelector) => {
  6667. const el = document.querySelector(querySelector);
  6668. if (el) {
  6669. el.classList.add('mod-compact');
  6670. }
  6671. });
  6672. emojiBtn.style.display = 'none';
  6673.  
  6674. modSettings.chat.compact = true;
  6675. updateStorage();
  6676. }
  6677.  
  6678. function defaultMode() {
  6679. chatElements.forEach((querySelector) => {
  6680. const el = document.querySelector(querySelector);
  6681. if (el) {
  6682. el.classList.remove('mod-compact');
  6683. }
  6684. });
  6685. emojiBtn.style.display = 'flex';
  6686.  
  6687. modSettings.chat.compact = false;
  6688. updateStorage();
  6689. }
  6690.  
  6691. if (modSettings.chat.compact) compactMode();
  6692. },
  6693.  
  6694. spamMessage(name, message) {
  6695. return (
  6696. this.blockedChatData.names.some(n => name.toLowerCase().includes(n.toLowerCase())) ||
  6697. this.blockedChatData.messages.some(m => message.toLowerCase().includes(m.toLowerCase()))
  6698. );
  6699. },
  6700.  
  6701. updateChat(data) {
  6702. const chatContainer = byId('mod-messages');
  6703. const isScrolledToBottom =
  6704. chatContainer.scrollHeight - chatContainer.scrollTop <=
  6705. chatContainer.clientHeight + 1;
  6706. const isNearBottom =
  6707. chatContainer.scrollHeight - chatContainer.scrollTop - 200 <=
  6708. chatContainer.clientHeight;
  6709.  
  6710. let { name, message, time = '' } = data;
  6711. name = noXSS(name);
  6712. time = data.time !== null ? prettyTime.am_pm(data.time) : '';
  6713.  
  6714. const color = this.friend_names.has(name)
  6715. ? this.friends_settings.highlight_color
  6716. : data.color || '#ffffff';
  6717. const glow =
  6718. this.friend_names.has(name) &&
  6719. this.friends_settings.highlight_friends
  6720. ? `text-shadow: 0 1px 3px ${color}`
  6721. : '';
  6722. const id = rdmString(12);
  6723.  
  6724. const chatMessage = document.createElement('div');
  6725. chatMessage.classList.add('message');
  6726. chatMessage.innerHTML = `
  6727. <div class="centerXY" style="gap: 3px;">
  6728. <div class="flex">
  6729. <span style="color: ${color};${glow}" class="message_name" id="${id}">${name}</span>
  6730. <span>&#58;</span>
  6731. </div>
  6732. <span class="chatMessage-text"></span>
  6733. </div>
  6734. <span class="time">${time}</span>
  6735. `;
  6736. chatMessage.querySelector('.chatMessage-text').innerHTML = message;
  6737.  
  6738. chatContainer.append(chatMessage);
  6739. if (isScrolledToBottom || isNearBottom)
  6740. chatContainer.scrollTop = chatContainer.scrollHeight;
  6741.  
  6742. if (name === this.nick) return;
  6743.  
  6744. const nameEl = byId(id);
  6745. nameEl.addEventListener('mousedown', (e) =>
  6746. this.handleContextMenu(e, name)
  6747. );
  6748. nameEl.addEventListener('contextmenu', (e) => {
  6749. e.preventDefault();
  6750. e.stopPropagation();
  6751. });
  6752.  
  6753. if (++this.renderedMessages > this.maxChatMessages) {
  6754. chatContainer.removeChild(chatContainer.firstChild);
  6755. this.renderedMessages--;
  6756. }
  6757. },
  6758.  
  6759. handleContextMenu(e, name) {
  6760. if (this.onContext || e.button !== 2) return;
  6761.  
  6762. const contextMenu = document.createElement('div');
  6763. contextMenu.classList.add('chat-context');
  6764. contextMenu.innerHTML = `
  6765. <span>${name}</span>
  6766. <button id="muteButton">Mute</button>
  6767. `;
  6768.  
  6769. Object.assign(contextMenu.style, {
  6770. top: `${e.clientY - 80}px`,
  6771. left: `${e.clientX}px`,
  6772. });
  6773.  
  6774. document.body.appendChild(contextMenu);
  6775. this.onContext = true;
  6776.  
  6777. byId('muteButton').addEventListener('click', () => {
  6778. const confirmMsg =
  6779. name === 'Spectator'
  6780. ? 'Are you sure you want to mute all spectators until you refresh the page?'
  6781. : `Are you sure you want to mute '${name}' until you refresh the page?`;
  6782.  
  6783. if (confirm(confirmMsg)) {
  6784. this.muteUser(name);
  6785. contextMenu.remove();
  6786. }
  6787. });
  6788.  
  6789. document.addEventListener('click', (event) => {
  6790. if (!contextMenu.contains(event.target)) {
  6791. this.onContext = false;
  6792. contextMenu.remove();
  6793. }
  6794. });
  6795. },
  6796.  
  6797. muteUser(name) {
  6798. this.mutedUsers.push(name);
  6799.  
  6800. const msgNames = document.querySelectorAll('.message_name');
  6801. msgNames.forEach((msgName) => {
  6802. if (msgName.innerHTML == name) {
  6803. const msgParent = msgName.closest('.message');
  6804. msgParent.remove();
  6805. }
  6806. });
  6807. },
  6808.  
  6809. async getGoogleFonts() {
  6810. const fontFamilies = await (
  6811. await fetch(this.appRoutes.fonts)
  6812. ).json();
  6813.  
  6814. return fontFamilies;
  6815. },
  6816.  
  6817. async getEmojis() {
  6818. const response = await fetch(
  6819. 'https://czrsd.com/static/sigmod/emojis.json'
  6820. );
  6821. return await response.json();
  6822. },
  6823.  
  6824. emojiMenu() {
  6825. const updateEmojis = (searchTerm = '') => {
  6826. const emojisContainer =
  6827. document.querySelector('.emojisContainer');
  6828. const categoriesContainer =
  6829. emojisContainer.querySelector('#categories');
  6830.  
  6831. categoriesContainer.innerHTML = '';
  6832. window.emojis.forEach((emojiData) => {
  6833. const { emoji, description, category, tags } = emojiData;
  6834. if (
  6835. !searchTerm ||
  6836. tags.some((tag) =>
  6837. tag.includes(searchTerm.toLowerCase())
  6838. )
  6839. ) {
  6840. let categoryId = category
  6841. .replace(/\s+/g, '-')
  6842. .replace('&', 'and')
  6843. .toLowerCase();
  6844. let categoryDiv = categoriesContainer.querySelector(
  6845. `#${categoryId}`
  6846. );
  6847. if (!categoryDiv) {
  6848. categoryDiv = document.createElement('div');
  6849. categoryDiv.id = categoryId;
  6850. categoryDiv.classList.add('category');
  6851. categoryDiv.innerHTML = `<span>${category}</span><div class="emojiContainer"></div>`;
  6852. categoriesContainer.appendChild(categoryDiv);
  6853. }
  6854. const emojiContainer =
  6855. categoryDiv.querySelector('.emojiContainer');
  6856. const emojiDiv = document.createElement('div');
  6857. emojiDiv.classList.add('emoji');
  6858. emojiDiv.innerHTML = emoji;
  6859. emojiDiv.title = `${emoji} - ${description}`;
  6860. emojiDiv.addEventListener('click', () => {
  6861. const chatInput =
  6862. document.querySelector('#chatSendInput');
  6863. chatInput.value += emoji;
  6864. });
  6865. emojiContainer.appendChild(emojiDiv);
  6866. }
  6867. });
  6868. };
  6869.  
  6870. const emojisContainer = document.createElement('div');
  6871. emojisContainer.classList.add(
  6872. 'chatAddedContainer',
  6873. 'emojisContainer',
  6874. 'hidden_full'
  6875. );
  6876. emojisContainer.innerHTML = `<input type="text" class="chatInput" id="searchEmoji" style="background-color: #050505; border-radius: .5rem; flex-grow: 0;" placeholder="Search..." /><div id="categories" class="scroll"></div>`;
  6877.  
  6878. const chatInput = emojisContainer.querySelector('#searchEmoji');
  6879. chatInput.addEventListener('input', (event) => {
  6880. const searchTerm = event.target.value.toLowerCase();
  6881. updateEmojis(searchTerm);
  6882. });
  6883.  
  6884. document.body.append(emojisContainer);
  6885.  
  6886. const chatSettingsContainer = document.querySelector(
  6887. '.chatSettingsContainer'
  6888. );
  6889.  
  6890. byId('openEmojiMenu').addEventListener('click', () => {
  6891. if (!window.emojis) {
  6892. this.getEmojis().then((emojis) => {
  6893. window.emojis = emojis;
  6894. updateEmojis();
  6895. });
  6896. }
  6897.  
  6898. if (emojisContainer.classList.contains('hidden_full')) {
  6899. emojisContainer.classList.remove('hidden_full');
  6900. chatSettingsContainer.classList.add('hidden_full');
  6901. } else {
  6902. emojisContainer.classList.add('hidden_full');
  6903. }
  6904. });
  6905. },
  6906.  
  6907. chatSettings() {
  6908. const menu = document.createElement('div');
  6909. menu.classList.add(
  6910. 'chatAddedContainer',
  6911. 'chatSettingsContainer',
  6912. 'scroll',
  6913. 'hidden_full'
  6914. );
  6915. menu.innerHTML = `
  6916. <div class="modInfoPopup" style="display: none">
  6917. <p>Send location in chat with keybind</p>
  6918. </div>
  6919. <div class="scroll">
  6920. <div class="csBlock">
  6921. <div class="csBlockTitle">
  6922. <span>Keybindings</span>
  6923. </div>
  6924. <div class="csRow">
  6925. <div class="csRowName">
  6926. <span>Location</span>
  6927. <span class="infoIcon">
  6928. <svg fill="#ffffff" id="Capa_1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 416.979 416.979" xml:space="preserve"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <g> <path d="M356.004,61.156c-81.37-81.47-213.377-81.551-294.848-0.182c-81.47,81.371-81.552,213.379-0.181,294.85 c81.369,81.47,213.378,81.551,294.849,0.181C437.293,274.636,437.375,142.626,356.004,61.156z M237.6,340.786 c0,3.217-2.607,5.822-5.822,5.822h-46.576c-3.215,0-5.822-2.605-5.822-5.822V167.885c0-3.217,2.607-5.822,5.822-5.822h46.576 c3.215,0,5.822,2.604,5.822,5.822V340.786z M208.49,137.901c-18.618,0-33.766-15.146-33.766-33.765 c0-18.617,15.147-33.766,33.766-33.766c18.619,0,33.766,15.148,33.766,33.766C242.256,122.755,227.107,137.901,208.49,137.901z"></path> </g> </g></svg>
  6929. </span>
  6930. </div>
  6931. <input type="text" name="location" id="modinput9" class="keybinding" value="${
  6932. modSettings.macros.keys.location || ''
  6933. }" placeholder="..." maxlength="1" onfocus="this.select()">
  6934. </div>
  6935. <div class="csRow">
  6936. <div class="csRowName">
  6937. <span>Show / Hide</span>
  6938. </div>
  6939. <input type="text" name="toggle.chat" id="modinput10" class="keybinding" value="${
  6940. modSettings.macros.keys.toggle.chat || ''
  6941. }" placeholder="..." maxlength="1" onfocus="this.select()">
  6942. </div>
  6943. </div>
  6944. <div class="csBlock">
  6945. <div class="csBlockTitle">
  6946. <span>General</span>
  6947. </div>
  6948. <div class="csRow">
  6949. <div class="csRowName">
  6950. <span>Time</span>
  6951. </div>
  6952. <div class="modCheckbox">
  6953. <input id="showChatTime" type="checkbox" checked />
  6954. <label class="cbx" for="showChatTime"></label>
  6955. </div>
  6956. </div>
  6957. <div class="csRow">
  6958. <div class="csRowName">
  6959. <span>Name colors</span>
  6960. </div>
  6961. <div class="modCheckbox">
  6962. <input id="showNameColors" type="checkbox" checked />
  6963. <label class="cbx" for="showNameColors"></label>
  6964. </div>
  6965. </div>
  6966. <div class="csRow">
  6967. <div class="csRowName">
  6968. <span>Party / Main</span>
  6969. </div>
  6970. <div class="modCheckbox">
  6971. <input id="showPartyMain" type="checkbox" checked />
  6972. <label class="cbx" for="showPartyMain"></label>
  6973. </div>
  6974. </div>
  6975. <div class="csRow">
  6976. <div class="csRowName">
  6977. <span>Blur Tag</span>
  6978. </div>
  6979. <div class="modCheckbox">
  6980. <input id="blurTag" type="checkbox" checked />
  6981. <label class="cbx" for="blurTag"></label>
  6982. </div>
  6983. </div>
  6984. <div class="flex f-column g-5 centerXY" style="padding: 0 5px">
  6985. <div class="csRowName">
  6986. <span>Location text</span>
  6987. </div>
  6988. <input type="text" id="locationText" placeholder="{pos}..." value="{pos}" class="form-control" />
  6989. </div>
  6990. </div>
  6991. <div class="csBlock">
  6992. <div class="csBlockTitle">
  6993. <span>Style</span>
  6994. </div>
  6995. <div class="csRow">
  6996. <div class="csRowName">
  6997. <span>Compact chat</span>
  6998. </div>
  6999. <div class="modCheckbox">
  7000. <input id="compactChat" type="checkbox" ${
  7001. modSettings.chat.compact ? 'checked' : ''
  7002. } />
  7003. <label class="cbx" for="compactChat"></label>
  7004. </div>
  7005. </div>
  7006. <div class="csRow">
  7007. <div class="csRowName">
  7008. <span>Text</span>
  7009. </div>
  7010. <div id="chatTextColor"></div>
  7011. </div>
  7012. <div class="csRow">
  7013. <div class="csRowName">
  7014. <span>Background</span>
  7015. </div>
  7016. <div id="chatBackground"></div>
  7017. </div>
  7018. <div class="csRow">
  7019. <div class="csRowName">
  7020. <span>Theme</span>
  7021. </div>
  7022. <div id="chatThemeChanger"></div>
  7023. </div>
  7024. </div>
  7025. </div>
  7026. `;
  7027. document.body.append(menu);
  7028.  
  7029. const infoIcon = document.querySelector('.infoIcon');
  7030. const modInfoPopup = document.querySelector('.modInfoPopup');
  7031. let popupOpen = false;
  7032.  
  7033. infoIcon.addEventListener('click', (event) => {
  7034. event.stopPropagation();
  7035. modInfoPopup.style.display = popupOpen ? 'none' : 'block';
  7036. popupOpen = !popupOpen;
  7037. });
  7038.  
  7039. document.addEventListener('click', (event) => {
  7040. if (popupOpen && !modInfoPopup.contains(event.target)) {
  7041. modInfoPopup.style.display = 'none';
  7042. popupOpen = false;
  7043. }
  7044. });
  7045.  
  7046. const showChatTime = document.querySelector('#showChatTime');
  7047. const showNameColors = document.querySelector('#showNameColors');
  7048.  
  7049. showChatTime.addEventListener('change', () => {
  7050. const timeElements = document.querySelectorAll('.time');
  7051. if (showChatTime.checked) {
  7052. modSettings.chat.showTime = true;
  7053. updateStorage();
  7054. } else {
  7055. modSettings.chat.showTime = false;
  7056. if (timeElements) {
  7057. timeElements.forEach((el) => (el.innerHTML = ''));
  7058. }
  7059. updateStorage();
  7060. }
  7061. });
  7062.  
  7063. showNameColors.addEventListener('change', () => {
  7064. const message_names =
  7065. document.querySelectorAll('.message_name');
  7066. if (showNameColors.checked) {
  7067. modSettings.chat.showNameColors = true;
  7068. updateStorage();
  7069. } else {
  7070. modSettings.chat.showNameColors = false;
  7071. if (message_names) {
  7072. message_names.forEach(
  7073. (el) => (el.style.color = '#fafafa')
  7074. );
  7075. }
  7076. updateStorage();
  7077. }
  7078. });
  7079.  
  7080. // remove old rgba val
  7081. if (modSettings.chat.bgColor.includes('rgba')) {
  7082. modSettings.chat.bgColor = RgbaToHex(modSettings.chat.bgColor);
  7083. }
  7084.  
  7085. const modChat = document.querySelector('.modChat');
  7086. modChat.style.background = modSettings.chat.bgColor;
  7087.  
  7088. const showPartyMain = document.querySelector('#showPartyMain');
  7089. const chatHeader = document.querySelector('.modchat-chatbuttons');
  7090.  
  7091. const changeButtonsState = (show) => {
  7092. chatHeader.style.display = show ? 'flex' : 'none';
  7093. modChat.style.maxHeight = show ? '285px' : '250px';
  7094. modChat.style.minHeight = show ? '285px' : '250px';
  7095. const modChatInner = document.querySelector('.modChat__inner');
  7096. modChatInner.style.maxHeight = show ? '265px' : '230px';
  7097. modChatInner.style.minHeight = show ? '265px' : '230px';
  7098. };
  7099.  
  7100. showPartyMain.addEventListener('change', () => {
  7101. const show = showPartyMain.checked;
  7102. modSettings.chat.showChatButtons = show;
  7103. changeButtonsState(show);
  7104. updateStorage();
  7105. });
  7106.  
  7107. showPartyMain.checked = modSettings.chat.showChatButtons;
  7108. changeButtonsState(modSettings.chat.showChatButtons);
  7109.  
  7110. setTimeout(() => {
  7111. const blurTag = byId('blurTag');
  7112. const tagText = document.querySelector('.tagText');
  7113. const tagElement = document.querySelector('#tag');
  7114. blurTag.addEventListener('change', () => {
  7115. const state = blurTag.checked;
  7116.  
  7117. state
  7118. ? (tagText.classList.add('blur'),
  7119. tagElement.classList.add('blur'))
  7120. : (tagText.classList.remove('blur'),
  7121. tagElement.classList.remove('blur'));
  7122. modSettings.chat.blurTag = state;
  7123. updateStorage();
  7124. });
  7125. blurTag.checked = modSettings.chat.blurTag;
  7126. if (modSettings.chat.blurTag) {
  7127. tagText.classList.add('blur');
  7128. tagElement.classList.add('blur');
  7129. }
  7130. });
  7131.  
  7132. const locationText = byId('locationText');
  7133. locationText.addEventListener('input', (e) => {
  7134. e.stopPropagation();
  7135. modSettings.chat.locationText = locationText.value;
  7136. });
  7137. locationText.value = modSettings.chat.locationText || '{pos}';
  7138. },
  7139.  
  7140. toggleChat() {
  7141. const modChat = document.querySelector('.modChat');
  7142. const modChatAdded = document.querySelectorAll(
  7143. '.chatAddedContainer'
  7144. );
  7145.  
  7146. const isModChatHidden =
  7147. modChat.style.display === 'none' ||
  7148. getComputedStyle(modChat).display === 'none';
  7149.  
  7150. if (isModChatHidden) {
  7151. modChat.style.opacity = 0;
  7152. modChat.style.display = 'flex';
  7153.  
  7154. setTimeout(() => {
  7155. modChat.style.opacity = 1;
  7156. }, 10);
  7157. } else {
  7158. modChat.style.opacity = 0;
  7159. modChatAdded.forEach((container) =>
  7160. container.classList.add('hidden_full')
  7161. );
  7162.  
  7163. setTimeout(() => {
  7164. modChat.style.display = 'none';
  7165. }, 300);
  7166. }
  7167. },
  7168.  
  7169. smallMods() {
  7170. const modAlert_overlay = document.createElement('div');
  7171. modAlert_overlay.classList.add('alert_overlay');
  7172. modAlert_overlay.id = 'modAlert_overlay';
  7173. document.body.append(modAlert_overlay);
  7174.  
  7175. const autoRespawn = byId('autoRespawn');
  7176. if (modSettings.settings.autoRespawn) {
  7177. autoRespawn.checked = true;
  7178. }
  7179.  
  7180. autoRespawn.addEventListener('change', () => {
  7181. modSettings.settings.autoRespawn = autoRespawn.checked;
  7182. updateStorage();
  7183. });
  7184.  
  7185. const auto = byId('autoClaimCoins');
  7186. auto.addEventListener('change', () => {
  7187. const checked = auto.checked;
  7188. modSettings.settings.autoClaimCoins = !!checked;
  7189. updateStorage();
  7190. });
  7191. if (modSettings.settings.autoClaimCoins) {
  7192. auto.checked = true;
  7193. }
  7194.  
  7195. const showChallenges = byId('showChallenges');
  7196. showChallenges.addEventListener('change', () => {
  7197. if (showChallenges.checked) {
  7198. modSettings.showChallenges = true;
  7199. } else {
  7200. modSettings.showChallenges = false;
  7201. }
  7202. updateStorage();
  7203. });
  7204. if (modSettings.showChallenges) {
  7205. auto.checked = true;
  7206. }
  7207.  
  7208. const gameTitle = byId('title');
  7209.  
  7210. const newTitle = document.createElement('div');
  7211. newTitle.classList.add('sigmod-title');
  7212. newTitle.innerHTML = `
  7213. <h1 id="title">Sigmally</h1>
  7214. <span id="bycursed">Mod by <a href="https://www.youtube.com/@sigmallyCursed/" target="_blank">Cursed</a></span>
  7215. `;
  7216. gameTitle.replaceWith(newTitle);
  7217.  
  7218. const nickName = byId('nick');
  7219. nickName.maxLength = 50;
  7220. nickName.type = 'text';
  7221.  
  7222. function updNick() {
  7223. const nick = nickName.value;
  7224. mods.nick = nick;
  7225. const welcome = byId('welcomeUser');
  7226. if (welcome) {
  7227. welcome.innerHTML = `Welcome ${
  7228. mods.nick || 'Unnamed'
  7229. }, to the SigMod Client!`;
  7230. }
  7231. }
  7232.  
  7233. nickName.addEventListener('input', () => {
  7234. updNick();
  7235. });
  7236.  
  7237. updNick();
  7238.  
  7239. // Better grammar in the descriptions of the challenges
  7240. setTimeout(() => {
  7241. window.shopLocales.challenge_tab.tasks = {
  7242. eaten: 'Eat %n food in a game.',
  7243. xp: 'Get %n XP in a game.',
  7244. alive: 'Stay alive for %n minutes in a game.',
  7245. pos: 'Reach top %n on leaderboard.',
  7246. };
  7247. }, 1000);
  7248.  
  7249. const topusersInner = document.querySelector('.top-users__inner');
  7250. topusersInner.classList.add('scroll');
  7251. topusersInner.style.border = 'none';
  7252.  
  7253. byId('signOutBtn').addEventListener('click', () => {
  7254. window.gameSettings.user = null;
  7255. });
  7256.  
  7257. const mode = byId('gamemode');
  7258. mode.addEventListener('change', () => {
  7259. client.send({
  7260. type: 'server-changed',
  7261. content: getGameMode(),
  7262. });
  7263.  
  7264. window.gameSettings.isPlaying = false;
  7265.  
  7266. const modMessages = document.querySelector('#mod-messages');
  7267. if (modMessages) {
  7268. modMessages.innerHTML = '';
  7269. }
  7270. });
  7271.  
  7272. // redirect to owned skins instead of free skins
  7273. const ot = Element.prototype.openTab;
  7274. Element.prototype.openTab = function (tab) {
  7275. if (!tab === 'skins') return;
  7276.  
  7277. setTimeout(() => {
  7278. Element.prototype.changeTab('owned');
  7279. }, 100);
  7280.  
  7281. ot.apply(this, arguments);
  7282. };
  7283.  
  7284. document.addEventListener('mousemove', (e) => {
  7285. this.mouseX = e.clientX + window.pageXOffset;
  7286. this.mouseY = e.clientY + window.pageYOffset;
  7287.  
  7288. const mouseTracker = document.querySelector('.mouseTracker');
  7289. if (!mouseTracker) return;
  7290.  
  7291. mouseTracker.innerText = `X: ${this.mouseX}; Y: ${this.mouseY}`;
  7292. });
  7293.  
  7294. if (location.search.includes('password')) {
  7295. const passwordField = byId('password');
  7296. if (passwordField) passwordField.style.display = 'none';
  7297.  
  7298. const password =
  7299. new URLSearchParams(location.search)
  7300. .get('password')
  7301. ?.split('/')[0] || '';
  7302. passwordField.value = password; // sigfixes should know the password when multiboxing
  7303.  
  7304. if (window.sigfix) return;
  7305.  
  7306. const playBtn = byId('play-btn');
  7307. playBtn.addEventListener('click', (e) => {
  7308. const waitForConnection = () =>
  7309. new Promise((res) => {
  7310. if (client?.ws?.readyState === 1) return res(null);
  7311. const i = setInterval(
  7312. () =>
  7313. client?.ws?.readyState === 1 &&
  7314. (clearInterval(i), res(null)),
  7315. 50
  7316. );
  7317. });
  7318.  
  7319. waitForConnection().then(async () => {
  7320. await wait(500);
  7321. mods.sendPlay(password);
  7322.  
  7323. const interval = setInterval(() => {
  7324. const errormodal = byId('errormodal');
  7325. if (errormodal?.style.display !== 'none')
  7326. errormodal.style.display = 'none';
  7327. });
  7328.  
  7329. setTimeout(() => clearInterval(interval), 1000);
  7330. });
  7331. });
  7332. }
  7333. },
  7334.  
  7335. removeStorage(storage) {
  7336. localStorage.removeItem(storage);
  7337. },
  7338.  
  7339. credits() {
  7340. console.log(
  7341. `%c
  7342. ‎░█▀▀▀█ ▀█▀ ░█▀▀█ ░█▀▄▀█ ░█▀▀▀█ ░█▀▀▄
  7343. ‎─▀▀▀▄▄ ░█─ ░█─▄▄ ░█░█░█ ░█──░█ ░█─░█ V${version}
  7344. ‎░█▄▄▄█ ▄█▄ ░█▄▄█ ░█──░█ ░█▄▄▄█ ░█▄▄▀
  7345. ██████╗░██╗░░░██╗  ░█████╗░██╗░░░██╗██████╗░░██████╗███████╗██████╗░
  7346. ██╔══██╗╚██╗░██╔╝  ██╔══██╗██║░░░██║██╔══██╗██╔════╝██╔════╝██╔══██╗
  7347. ██████╦╝░╚████╔╝░  ██║░░╚═╝██║░░░██║██████╔╝╚█████╗░█████╗░░██║░░██║
  7348. ██╔══██╗░░╚██╔╝░░  ██║░░██╗██║░░░██║██╔══██╗░╚═══██╗██╔══╝░░██║░░██║
  7349. ██████╦╝░░░██║░░░  ╚█████╔╝╚██████╔╝██║░░██║██████╔╝███████╗██████╔╝
  7350. ╚═════╝░░░░╚═╝░░░  ░╚════╝░░╚═════╝░╚═╝░░╚═╝╚═════╝░╚══════╝╚═════╝░
  7351. `,
  7352. 'background-color: black; color: green'
  7353. );
  7354. },
  7355.  
  7356. handleAlert(data) {
  7357. const { title, description, enabled, password } = data;
  7358.  
  7359. if (location.pathname.includes('tournament') || client.updateAvailable) return;
  7360.  
  7361. const hideAlert = localStorage.getItem('hide-alert');
  7362. if (!enabled || (Date.now() - 24 * 60 * 60 * 1000) > hideAlert) {
  7363. byId('scrim_alert')?.remove();
  7364. return;
  7365. }
  7366.  
  7367. localStorage.removeItem('hide-alert');
  7368.  
  7369. const modAlert = document.createElement('div');
  7370. modAlert.id = 'scrim_alert';
  7371. modAlert.classList.add('modAlert');
  7372. modAlert.innerHTML = `
  7373. <div class="flex justify-sb">
  7374. <strong>${title}</strong>
  7375. <button class="modButton" style="width: 35px;" id="close_scrim_alert">X</button>
  7376. </div>
  7377. <span>${description}</span>
  7378. <div class="flex" style="align-items: center; gap: 5px;">
  7379. <button id="join" class="modButton" style="width: 100%">Join</button>
  7380. </div>
  7381. `;
  7382. document.body.append(modAlert);
  7383.  
  7384. const observer = new MutationObserver(() => {
  7385. modAlert.style.display = menuClosed() ? 'none' : 'flex';
  7386. });
  7387.  
  7388. observer.observe(document.body, {
  7389. attributes: true,
  7390. childList: true,
  7391. subtree: true,
  7392. });
  7393.  
  7394. const joinButton = byId('join');
  7395. joinButton.addEventListener('click', () => {
  7396. location.href = `https://one.sigmally.com/tournament?password=${password}`;
  7397. });
  7398.  
  7399. const close = byId('close_scrim_alert');
  7400. close.addEventListener('click', () => {
  7401. modAlert.remove();
  7402. // make it not that annoying
  7403. localStorage.setItem('hide-alert', Date.now());
  7404. });
  7405. },
  7406.  
  7407. saveNames() {
  7408. let savedNames = modSettings.settings.savedNames;
  7409. let savedNamesOutput = byId('savedNames');
  7410. let saveNameBtn = byId('saveName');
  7411. let saveNameInput = byId('saveNameValue');
  7412.  
  7413. const createNameDiv = (name) => {
  7414. let nameDiv = document.createElement('div');
  7415. nameDiv.classList.add('NameDiv');
  7416.  
  7417. let nameLabel = document.createElement('label');
  7418. nameLabel.classList.add('NameLabel');
  7419. nameLabel.innerText = name;
  7420.  
  7421. let delName = document.createElement('button');
  7422. delName.innerText = 'X';
  7423. delName.classList.add('delName');
  7424.  
  7425. nameDiv.addEventListener('click', () => {
  7426. const name = nameLabel.innerText;
  7427. navigator.clipboard.writeText(name).then(() => {
  7428. this.modAlert(
  7429. `Added the name '${name}' to your clipboard!`,
  7430. 'success'
  7431. );
  7432. });
  7433. });
  7434.  
  7435. delName.addEventListener('click', () => {
  7436. if (
  7437. confirm(
  7438. "Are you sure you want to delete the name '" +
  7439. nameLabel.innerText +
  7440. "'?"
  7441. )
  7442. ) {
  7443. nameDiv.remove();
  7444. savedNames = savedNames.filter(
  7445. (n) => n !== nameLabel.innerText
  7446. );
  7447. modSettings.settings.savedNames = savedNames;
  7448. updateStorage();
  7449. }
  7450. });
  7451.  
  7452. nameDiv.appendChild(nameLabel);
  7453. nameDiv.appendChild(delName);
  7454. return nameDiv;
  7455. };
  7456.  
  7457. saveNameBtn.addEventListener('click', () => {
  7458. if (saveNameInput.value === '') return;
  7459.  
  7460. setTimeout(() => {
  7461. saveNameInput.value = '';
  7462. }, 10);
  7463.  
  7464. if (savedNames.includes(saveNameInput.value)) {
  7465. return;
  7466. }
  7467.  
  7468. let nameDiv = createNameDiv(saveNameInput.value);
  7469. savedNamesOutput.appendChild(nameDiv);
  7470.  
  7471. savedNames.push(saveNameInput.value);
  7472. modSettings.settings.savedNames = savedNames;
  7473. updateStorage();
  7474. });
  7475.  
  7476. if (savedNames.length > 0) {
  7477. savedNames.forEach((name) => {
  7478. let nameDiv = createNameDiv(name);
  7479. savedNamesOutput.appendChild(nameDiv);
  7480. });
  7481. }
  7482. },
  7483.  
  7484. initStats() {
  7485. // initialize player stats
  7486. const statElements = [
  7487. 'stat-time-played',
  7488. 'stat-highest-mass',
  7489. 'stat-total-deaths',
  7490. 'stat-total-mass',
  7491. ];
  7492. this.storage = localStorage.getItem('game-stats');
  7493.  
  7494. if (!this.storage) {
  7495. this.storage = {
  7496. 'time-played': 0, // seconds
  7497. 'highest-mass': 0,
  7498. 'total-deaths': 0,
  7499. 'total-mass': 0,
  7500. };
  7501. localStorage.setItem(
  7502. 'game-stats',
  7503. JSON.stringify(this.storage)
  7504. );
  7505. } else {
  7506. this.storage = JSON.parse(this.storage);
  7507. }
  7508.  
  7509. statElements.forEach((rawStat) => {
  7510. const stat = rawStat.replace('stat-', '');
  7511. const value = this.storage[stat];
  7512. this.updateStatElm(rawStat, value);
  7513. });
  7514.  
  7515. this.session.bind(this)();
  7516. },
  7517.  
  7518. updateStat(key, value) {
  7519. this.storage[key] = value;
  7520. localStorage.setItem('game-stats', JSON.stringify(this.storage));
  7521. this.updateStatElm(key, value);
  7522. },
  7523.  
  7524. updateStatElm(stat, value) {
  7525. const element = byId(stat);
  7526.  
  7527. if (element) {
  7528. if (stat === 'stat-time-played') {
  7529. const hours = Math.floor(value / 3600);
  7530. const minutes = Math.floor((value % 3600) / 60);
  7531. const formattedTime =
  7532. hours > 0 ? `${hours}h ${minutes}m` : `${minutes}m`;
  7533. element.innerHTML = formattedTime;
  7534. } else {
  7535. const formattedValue =
  7536. stat === 'stat-highest-mass' ||
  7537. stat === 'stat-total-mass'
  7538. ? value > 999
  7539. ? `${(value / 1000).toFixed(1)}k`
  7540. : value.toString()
  7541. : value.toString();
  7542. element.innerHTML = formattedValue;
  7543. }
  7544. }
  7545. },
  7546.  
  7547. session() {
  7548. let playingInterval;
  7549. let minPlaying = 0;
  7550. let isPlaying = window.gameSettings.isPlaying;
  7551.  
  7552. const playBtn = byId('play-btn');
  7553. let a = null;
  7554.  
  7555. playBtn.addEventListener('click', async () => {
  7556. if (isPlaying) return;
  7557.  
  7558. while (!window.gameSettings.isPlaying) {
  7559. await new Promise((resolve) => setTimeout(resolve, 200));
  7560. }
  7561.  
  7562. isPlaying = true;
  7563. let timer = null;
  7564.  
  7565. if (modSettings.playTimer) {
  7566. timer = document.createElement('span');
  7567. timer.classList.add('playTimer');
  7568. timer.innerText = '0m0s played';
  7569. document.body.append(timer);
  7570. }
  7571.  
  7572. // mouse tracker in session method so it's only visible when playing
  7573. if (modSettings.mouseTracker) {
  7574. const mouse = document.createElement('span');
  7575. mouse.classList.add('mouseTracker');
  7576. mouse.innerText = 'X: 0; Y: 0';
  7577. document.body.append(mouse);
  7578.  
  7579. if (!modSettings.playTimer) {
  7580. mouse.style.top = '128px';
  7581. }
  7582. }
  7583.  
  7584. let count = 0;
  7585. playingInterval = setInterval(() => {
  7586. count++;
  7587. this.storage['time-played']++;
  7588. if (count % 60 === 0) {
  7589. minPlaying++;
  7590. }
  7591. this.updateStat('time-played', this.storage['time-played']);
  7592.  
  7593. if (modSettings.playTimer) {
  7594. this.updateTimeStat(timer, count);
  7595. }
  7596. }, 1000);
  7597. });
  7598.  
  7599. setInterval(() => {
  7600. if (menuClosed() && byId('overlays').style.display !== 'none') {
  7601. byId('overlays').style.display = 'none';
  7602. }
  7603.  
  7604. if (isDead() && !dead) {
  7605. clearInterval(playingInterval);
  7606. dead = true;
  7607.  
  7608. const playTimer = document.querySelector('.playTimer');
  7609. if (playTimer) playTimer.remove();
  7610.  
  7611. const mouseTracker =
  7612. document.querySelector('.mouseTracker');
  7613. if (mouseTracker) mouseTracker.remove();
  7614.  
  7615. const score = parseFloat(byId('highest_mass').innerText);
  7616. const highest = this.storage['highest-mass'];
  7617.  
  7618. if (score > highest) {
  7619. this.storage['highest-mass'] = score;
  7620. this.updateStat(
  7621. 'highest-mass',
  7622. this.storage['highest-mass']
  7623. );
  7624. }
  7625.  
  7626. this.storage['total-deaths']++;
  7627. this.updateStat(
  7628. 'total-deaths',
  7629. this.storage['total-deaths']
  7630. );
  7631.  
  7632. this.storage['total-mass'] += score;
  7633. this.updateStat('total-mass', this.storage['total-mass']);
  7634. isPlaying = window.gameSettings.isPlaying = false;
  7635.  
  7636. if (this.lastOneStanding) {
  7637. client.send({
  7638. type: 'result',
  7639. content: null,
  7640. });
  7641. playBtn.disabled = true;
  7642. }
  7643.  
  7644. if (modSettings.showChallenges && window.gameSettings.user)
  7645. this.showChallenges();
  7646. } else if (!isDead()) {
  7647. dead = false;
  7648. const challengesDeathscreen = document.querySelector(
  7649. '.challenges_deathscreen'
  7650. );
  7651. if (challengesDeathscreen) challengesDeathscreen.remove();
  7652. }
  7653. });
  7654. },
  7655. updateTimeStat(el, seconds) {
  7656. const minutes = Math.floor(seconds / 60);
  7657. const remainingSeconds = seconds % 60;
  7658. const timeString = `${minutes}m${remainingSeconds}s`;
  7659.  
  7660. el.innerText = `${timeString} played`;
  7661. },
  7662.  
  7663. async showChallenges() {
  7664. const challengeData = await (
  7665. await fetch(
  7666. `https://sigmally.com/api/user/challenge/${window.gameSettings.user.email}`
  7667. )
  7668. ).json();
  7669.  
  7670. if (challengeData.status !== 'success') return;
  7671.  
  7672. const shopLocales = window.shopLocales;
  7673. let challengesCompleted = 0;
  7674.  
  7675. const allChallenges = challengeData.data;
  7676. allChallenges.forEach(({ status }) => {
  7677. if (status) challengesCompleted++;
  7678. });
  7679.  
  7680. let challenges;
  7681. if (challengesCompleted === allChallenges.length) {
  7682. challenges = `<div class="challenge-row" style="justify-content: center;">All challenges completed.</div>`;
  7683. } else {
  7684. challenges = allChallenges
  7685. .filter(({ status }) => !status)
  7686. .map(({ task, best, status, ready, goal }) => {
  7687. const desc = shopLocales.challenge_tab.tasks[
  7688. task
  7689. ].replace('%n', task === 'alive' ? goal / 60 : goal);
  7690. const btn = ready
  7691. ? `<button class="challenge-collect-secondary" onclick="this.challenge('${task}', ${status})">${shopLocales.challenge_tab.collect}</button>`
  7692. : `<div class="challenge-best-secondary">${
  7693. shopLocales.challenge_tab.result
  7694. }${Math.round(best)}${
  7695. task === 'alive' ? 's' : ''
  7696. }</div>`;
  7697. return `
  7698. <div class="challenge-row">
  7699. <div class="challenge-desc">${desc}</div>
  7700. ${btn}
  7701. </div>`;
  7702. })
  7703. .join('');
  7704. }
  7705.  
  7706. const modal = document.createElement('div');
  7707. modal.classList.add('challenges_deathscreen');
  7708. modal.innerHTML = `
  7709. <span class="challenges-title">Daily challenges</span>
  7710. <div class="challenges-col">${challenges}</div>
  7711. <span class="centerXY new-challenges">New challenges in 0h 0m 0s</span>
  7712. `;
  7713.  
  7714. const toggleColor = (element, background, text) => {
  7715. let image = `url("${background}")`;
  7716. if (background.includes('http')) {
  7717. element.style.background = image;
  7718. element.style.backgroundPosition = 'center';
  7719. element.style.backgroundSize = 'cover';
  7720. element.style.backgroundRepeat = 'no-repeat';
  7721. } else {
  7722. element.style.background = background;
  7723. element.style.backgroundRepeat = 'no-repeat';
  7724. }
  7725. element.style.color = text;
  7726. };
  7727.  
  7728. if (modSettings.themes.current !== 'Dark') {
  7729. let selectedTheme;
  7730. selectedTheme =
  7731. window.themes.defaults.find(
  7732. (theme) => theme.name === modSettings.themes.current
  7733. ) ||
  7734. modSettings.themes.custom.find(
  7735. (theme) => theme.name === modSettings.themes.current
  7736. ) ||
  7737. null;
  7738. if (!selectedTheme) {
  7739. selectedTheme =
  7740. window.themes.orderly.find(
  7741. (theme) => theme.name === modSettings.themes.current
  7742. ) ||
  7743. modSettings.themes.custom.find(
  7744. (theme) => theme.name === modSettings.themes.current
  7745. );
  7746. }
  7747.  
  7748. if (selectedTheme) {
  7749. toggleColor(
  7750. modal,
  7751. selectedTheme.background,
  7752. selectedTheme.text
  7753. );
  7754. }
  7755. }
  7756.  
  7757. document
  7758. .querySelector('.menu-wrapper--stats-mode')
  7759. .insertAdjacentElement('afterbegin', modal);
  7760.  
  7761. if (challengesCompleted < allChallenges.length) {
  7762. document
  7763. .querySelectorAll('.challenge-collect-secondary')
  7764. .forEach((btn) => {
  7765. btn.addEventListener('click', () => {
  7766. const parentChallengeRow =
  7767. btn.closest('.challenge-row');
  7768. if (parentChallengeRow) {
  7769. setTimeout(() => {
  7770. parentChallengeRow.remove();
  7771. }, 500);
  7772. }
  7773. });
  7774. });
  7775. }
  7776.  
  7777. this.createDayTimer();
  7778. },
  7779.  
  7780. timeToString(timeLeft) {
  7781. const string = new Date(timeLeft).toISOString().slice(11, 19);
  7782. const [hours, minutes, seconds] = string.split(':');
  7783.  
  7784. return `${hours}h ${minutes}m ${seconds}s`;
  7785. },
  7786. toISODate: (date) => {
  7787. const withTime = date ? new Date(date) : new Date();
  7788. const [withoutTime] = withTime.toISOString().split('T');
  7789. return withoutTime;
  7790. },
  7791. createDayTimer() {
  7792. const oneDay = 1000 * 60 * 60 * 24;
  7793. const getTime = () => {
  7794. const today = this.toISODate();
  7795. const from = new Date(today).getTime();
  7796. const to = from + oneDay;
  7797.  
  7798. const distance = to - Date.now();
  7799. const time = this.timeToString(distance);
  7800. return time;
  7801. };
  7802.  
  7803. const children = document.querySelector('.new-challenges');
  7804. if (children) {
  7805. children.innerHTML = `New challenges in ${getTime()}`;
  7806. }
  7807.  
  7808. this.dayTimer = setInterval(() => {
  7809. const today = this.toISODate();
  7810. const from = new Date(today).getTime();
  7811. const to = from + oneDay;
  7812.  
  7813. const distance = to - Date.now();
  7814. const time = this.timeToString(distance);
  7815.  
  7816. const children = document.querySelector('.new-challenges');
  7817. if (!children || distance < 1000 || !isDead()) {
  7818. clearInterval(this.dayTimer);
  7819. return;
  7820. }
  7821. children.innerHTML = `New challenges in ${getTime()}`;
  7822. }, 1000);
  7823. },
  7824.  
  7825. macros() {
  7826. let that = this;
  7827. const KEY_SPLIT = this.splitKey;
  7828. let ff = null;
  7829. let keydown = false;
  7830. let open = false;
  7831. const canvas = byId('canvas');
  7832. const mod_menu = document.querySelector('.mod_menu');
  7833.  
  7834. const freezeType = byId('freezeType');
  7835. let freezeKeyPressed = false;
  7836. let freezeMouseClicked = false;
  7837. let freezeOverlay = null;
  7838.  
  7839. let vOverlay = null;
  7840. let vLocked = false;
  7841. let activeVLine = false;
  7842.  
  7843. let fixedOverlay = null;
  7844. let fixedLocked = false;
  7845. let activeFixedLine = false;
  7846.  
  7847. /* intervals */
  7848.  
  7849. // Respawn interval
  7850. setInterval(() => {
  7851. if (
  7852. modSettings.settings.autoRespawn &&
  7853. this.respawnTime &&
  7854. Date.now() - this.respawnTime >= this.respawnCooldown
  7855. ) {
  7856. this.respawn();
  7857. }
  7858. });
  7859.  
  7860. // mouse fast feed interval
  7861. setInterval(() => {
  7862. if (dead || !menuClosed() || !this.mouseDown) return;
  7863. keypress('w', 'KeyW');
  7864. }, 50);
  7865.  
  7866. async function split(times) {
  7867. if (times > 0) {
  7868. window.dispatchEvent(
  7869. new KeyboardEvent('keydown', KEY_SPLIT)
  7870. );
  7871. window.dispatchEvent(new KeyboardEvent('keyup', KEY_SPLIT));
  7872. split(times - 1);
  7873. }
  7874. }
  7875.  
  7876. async function selfTrick() {
  7877. let i = 4;
  7878.  
  7879. while (i--) {
  7880. split(1);
  7881. await wait(20);
  7882. }
  7883. }
  7884.  
  7885. async function doubleTrick() {
  7886. let i = 2;
  7887.  
  7888. while (i--) {
  7889. split(1);
  7890. await wait(20);
  7891. }
  7892. }
  7893.  
  7894. function mouseToScreenCenter() {
  7895. const screenCenterX = canvas.width / 2;
  7896. const screenCenterY = canvas.height / 2;
  7897.  
  7898. mousemove(screenCenterX, screenCenterY);
  7899.  
  7900. return {
  7901. x: screenCenterX,
  7902. y: screenCenterY,
  7903. };
  7904. }
  7905.  
  7906. async function instantSplit() {
  7907. await wait(300);
  7908.  
  7909. if (
  7910. modSettings.macros.keys.line.instantSplit &&
  7911. modSettings.macros.keys.line.instantSplit > 0
  7912. ) {
  7913. split(modSettings.macros.keys.line.instantSplit);
  7914. }
  7915. }
  7916.  
  7917. async function vLine() {
  7918. if (!activeVLine) return;
  7919. const x = playerPosition.x;
  7920. const y = playerPosition.y;
  7921.  
  7922. const offsetUpX = playerPosition.x;
  7923. const offsetUpY = playerPosition.y - 100;
  7924. const offsetDownX = playerPosition.x;
  7925. const offsetDownY = playerPosition.y + 100;
  7926.  
  7927. freezepos = false;
  7928. window.sendMouseMove(offsetUpX, offsetUpY);
  7929. freezepos = true;
  7930.  
  7931. await wait(50);
  7932.  
  7933. freezepos = false;
  7934. window.sendMouseMove(offsetDownX, offsetDownY);
  7935. freezepos = true;
  7936. }
  7937.  
  7938. async function toggleHorizontal(mouse = false) {
  7939. if (!freezeKeyPressed) {
  7940. if (activeVLine || activeFixedLine) return;
  7941.  
  7942. window.sendMouseMove(playerPosition.x, playerPosition.y);
  7943. freezepos = true;
  7944.  
  7945. instantSplit();
  7946.  
  7947. freezeOverlay = document.createElement('div');
  7948. freezeOverlay.innerHTML = `
  7949. <span style="position: absolute; bottom: 50px; left: 50%; transform: translateX(-50%); color: #fff; font-size: 26px; user-select: none;">Movement Stopped</span>
  7950. `;
  7951. freezeOverlay.style =
  7952. 'position: absolute; top: 0; left: 0; z-index: 99; width: 100%; height: 100vh; overflow: hidden; pointer-events: none;';
  7953.  
  7954. if (
  7955. mouse &&
  7956. (modSettings.macros.mouse.left === 'freeze' ||
  7957. modSettings.macros.mouse.right === 'freeze')
  7958. ) {
  7959. freezeOverlay.addEventListener('mousedown', (e) => {
  7960. if (
  7961. e.button === 0 &&
  7962. modSettings.macros.mouse.left === 'freeze'
  7963. ) {
  7964. // Left mouse button (1)
  7965. handleFreezeEvent();
  7966. }
  7967. if (
  7968. e.button === 2 &&
  7969. modSettings.macros.mouse.right === 'freeze'
  7970. ) {
  7971. // Right mouse button (2)
  7972. handleFreezeEvent();
  7973. }
  7974. });
  7975.  
  7976. if (modSettings.macros.mouse.right === 'freeze') {
  7977. freezeOverlay.addEventListener(
  7978. 'contextmenu',
  7979. (e) => {
  7980. e.preventDefault();
  7981. }
  7982. );
  7983. }
  7984. }
  7985.  
  7986. function handleFreezeEvent() {
  7987. if (freezeOverlay != null) freezeOverlay.remove();
  7988. freezeOverlay = null;
  7989. freezeKeyPressed = false;
  7990. }
  7991.  
  7992. document
  7993. .querySelector('.body__inner')
  7994. .append(freezeOverlay);
  7995.  
  7996. freezeKeyPressed = true;
  7997. } else {
  7998. if (freezeOverlay != null) freezeOverlay.remove();
  7999. freezeOverlay = null;
  8000. freezeKeyPressed = false;
  8001.  
  8002. freezepos = false;
  8003. }
  8004. }
  8005.  
  8006. async function toggleVertical() {
  8007. if (!activeVLine) {
  8008. if (freezeKeyPressed || activeFixedLine) return;
  8009.  
  8010. window.sendMouseMove(playerPosition.x, playerPosition.y);
  8011. freezepos = true;
  8012.  
  8013. instantSplit();
  8014.  
  8015. vOverlay = document.createElement('div');
  8016. vOverlay.style = 'pointer-events: none;';
  8017. vOverlay.innerHTML = `
  8018. <span style="position: absolute; bottom: 50px; left: 50%; transform: translateX(-50%); color: #fff; font-size: 26px; user-select: none;">Vertical locked</span>
  8019. `;
  8020. vOverlay.style =
  8021. 'position: absolute; top: 0; left: 0; z-index: 99; width: 100%; height: 100vh; overflow: hidden; pointer-events: none;';
  8022.  
  8023. document.querySelector('.body__inner').append(vOverlay);
  8024.  
  8025. activeVLine = true;
  8026. } else {
  8027. activeVLine = false;
  8028. freezepos = false;
  8029. if (vOverlay) vOverlay.remove();
  8030. vOverlay = null;
  8031. }
  8032. }
  8033.  
  8034. async function toggleFixed() {
  8035. if (!activeFixedLine) {
  8036. if (freezeKeyPressed || activeVLine) return;
  8037.  
  8038. window.sendMouseMove(playerPosition.x, playerPosition.y);
  8039.  
  8040. freezepos = true;
  8041.  
  8042. instantSplit();
  8043.  
  8044. fixedOverlay = document.createElement('div');
  8045. fixedOverlay.style = 'pointer-events: none;';
  8046. fixedOverlay.innerHTML = `
  8047. <span style="position: absolute; bottom: 50px; left: 50%; transform: translateX(-50%); color: #fff; font-size: 26px; user-select: none;">Mouse locked</span>
  8048. `;
  8049. fixedOverlay.style =
  8050. 'position: absolute; top: 0; left: 0; z-index: 99; width: 100%; height: 100vh; overflow: hidden; pointer-events: none;';
  8051.  
  8052. document.querySelector('.body__inner').append(fixedOverlay);
  8053.  
  8054. activeFixedLine = true;
  8055. } else {
  8056. activeFixedLine = false;
  8057. freezepos = false;
  8058. if (fixedOverlay) fixedOverlay.remove();
  8059. fixedOverlay = null;
  8060. }
  8061. }
  8062.  
  8063. function sendLocation() {
  8064. if (!playerPosition.x || !playerPosition.y) return;
  8065.  
  8066. const gamemode = byId('gamemode');
  8067.  
  8068. let field = '';
  8069. const coordinates = getCoordinates(mods.border);
  8070.  
  8071. for (const label in coordinates) {
  8072. const { min, max } = coordinates[label];
  8073.  
  8074. if (
  8075. playerPosition.x >= min.x &&
  8076. playerPosition.x <= max.x &&
  8077. playerPosition.y >= min.y &&
  8078. playerPosition.y <= max.y
  8079. ) {
  8080. field = label;
  8081. break;
  8082. }
  8083. }
  8084.  
  8085. const locationText = modSettings.chat.locationText || field;
  8086. const message = locationText.replace('{pos}', field);
  8087. window.sendChat(message);
  8088. }
  8089.  
  8090. function toggleSettings(setting) {
  8091. const settingElement = document.querySelector(
  8092. `input#${setting}`
  8093. );
  8094. if (settingElement) {
  8095. settingElement.click();
  8096. } else {
  8097. console.error(`Setting "${setting}" not found`);
  8098. }
  8099. }
  8100.  
  8101. document.addEventListener('keyup', (e) => {
  8102. const key = e.key.toLowerCase();
  8103. if (key == modSettings.macros.keys.rapidFeed && keydown) {
  8104. clearInterval(ff);
  8105. keydown = false;
  8106. }
  8107. });
  8108. document.addEventListener('keydown', (e) => {
  8109. // prevent disconnecting & using macros on input fields
  8110. if (
  8111. document.activeElement.tagName === 'INPUT' ||
  8112. document.activeElement.tagName === 'TEXTAREA'
  8113. ) {
  8114. e.stopPropagation();
  8115. return;
  8116. }
  8117. const key = e.key.toLowerCase();
  8118.  
  8119. if (key === 'p') {
  8120. e.stopPropagation();
  8121. }
  8122. if (key === 'tab' && !window.screenTop && !window.screenY) {
  8123. e.preventDefault();
  8124. }
  8125.  
  8126. if (key === modSettings.macros.keys.rapidFeed) {
  8127. e.stopPropagation(); // block actual feeding key
  8128. if (!keydown) {
  8129. keydown = true;
  8130. ff = setInterval(
  8131. () => keypress('w', 'KeyW'),
  8132. modSettings.macros.feedSpeed
  8133. );
  8134. }
  8135. }
  8136. // vertical linesplit
  8137. if (
  8138. activeVLine &&
  8139. (key === ' ' ||
  8140. key === modSettings.macros.keys.splits.double ||
  8141. key === modSettings.macros.keys.splits.triple ||
  8142. key === modSettings.macros.keys.splits.quad)
  8143. ) {
  8144. vLine();
  8145. }
  8146.  
  8147. handleKeydown(key);
  8148. });
  8149.  
  8150. async function handleKeydown(key) {
  8151. switch (key) {
  8152. case modSettings.macros.keys.toggle.menu: {
  8153. if (!open) {
  8154. mod_menu.style.display = 'flex';
  8155. setTimeout(() => {
  8156. mod_menu.style.opacity = 1;
  8157. }, 10);
  8158. open = true;
  8159. } else {
  8160. mod_menu.style.opacity = 0;
  8161. setTimeout(() => {
  8162. mod_menu.style.display = 'none';
  8163. }, 300);
  8164. open = false;
  8165. }
  8166. break;
  8167. }
  8168.  
  8169. case modSettings.macros.keys.splits.double:
  8170. split(2);
  8171. break;
  8172.  
  8173. case modSettings.macros.keys.splits.triple:
  8174. split(3);
  8175. break;
  8176.  
  8177. case modSettings.macros.keys.splits.quad:
  8178. split(4);
  8179. break;
  8180.  
  8181. case modSettings.macros.keys.splits.selfTrick:
  8182. selfTrick();
  8183. break;
  8184.  
  8185. case modSettings.macros.keys.splits.doubleTrick:
  8186. doubleTrick();
  8187. break;
  8188.  
  8189. case modSettings.macros.keys.line.horizontal:
  8190. if (menuClosed()) toggleHorizontal();
  8191. break;
  8192.  
  8193. case modSettings.macros.keys.line.vertical:
  8194. if (menuClosed()) toggleVertical();
  8195. break;
  8196.  
  8197. case modSettings.macros.keys.line.fixed:
  8198. if (menuClosed()) toggleFixed();
  8199. break;
  8200.  
  8201. case modSettings.macros.keys.location:
  8202. sendLocation();
  8203. break;
  8204.  
  8205. case modSettings.macros.keys.toggle.chat:
  8206. mods.toggleChat();
  8207. break;
  8208.  
  8209. case modSettings.macros.keys.toggle.names:
  8210. toggleSettings('showNames');
  8211. break;
  8212.  
  8213. case modSettings.macros.keys.toggle.skins:
  8214. toggleSettings('showSkins');
  8215. break;
  8216.  
  8217. case modSettings.macros.keys.toggle.autoRespawn:
  8218. toggleSettings('autoRespawn');
  8219. break;
  8220.  
  8221. case modSettings.macros.keys.respawn:
  8222. mods.respawnGame();
  8223. break;
  8224.  
  8225. case modSettings.macros.keys.saveImage:
  8226. await mods.saveImage();
  8227. break;
  8228. }
  8229. }
  8230.  
  8231. canvas.addEventListener('mousedown', (e) => {
  8232. const {
  8233. macros: { mouse },
  8234. } = modSettings;
  8235.  
  8236. if (e.button === 0) {
  8237. // Left mouse button (0)
  8238. if (mouse.left === 'fastfeed') {
  8239. if (
  8240. document.activeElement.tagName === 'INPUT' ||
  8241. document.activeElement.tagName === 'TEXTAREA'
  8242. )
  8243. return;
  8244. this.mouseDown = true;
  8245. } else if (mouse.left === 'split') {
  8246. split(1);
  8247. } else if (mouse.left === 'split2') {
  8248. split(2);
  8249. } else if (mouse.left === 'split3') {
  8250. split(3);
  8251. } else if (mouse.left === 'split4') {
  8252. split(4);
  8253. } else if (mouse.left === 'freeze') {
  8254. toggleHorizontal(true);
  8255. } else if (mouse.left === 'dTrick') {
  8256. doubleTrick();
  8257. } else if (mouse.left === 'sTrick') {
  8258. selfTrick();
  8259. }
  8260. } else if (e.button === 2) {
  8261. // Right mouse button (2)
  8262. e.preventDefault();
  8263. if (mouse.right === 'fastfeed') {
  8264. if (
  8265. document.activeElement.tagName === 'INPUT' ||
  8266. document.activeElement.tagName === 'TEXTAREA'
  8267. )
  8268. return;
  8269. this.mouseDown = true;
  8270. } else if (mouse.right === 'split') {
  8271. split(1);
  8272. } else if (mouse.right === 'split2') {
  8273. split(2);
  8274. } else if (mouse.right === 'split3') {
  8275. split(3);
  8276. } else if (mouse.right === 'split4') {
  8277. split(4);
  8278. } else if (mouse.right === 'freeze') {
  8279. toggleHorizontal(true);
  8280. } else if (mouse.right === 'dTrick') {
  8281. doubleTrick();
  8282. } else if (mouse.right === 'sTrick') {
  8283. selfTrick();
  8284. }
  8285. }
  8286. });
  8287.  
  8288. canvas.addEventListener('contextmenu', (e) => {
  8289. e.preventDefault();
  8290. });
  8291.  
  8292. canvas.addEventListener('mouseup', () => {
  8293. if (modSettings.macros.mouse.left === 'fastfeed') {
  8294. this.mouseDown = false;
  8295. } else if (modSettings.macros.mouse.right === 'fastfeed') {
  8296. this.mouseDown = false;
  8297. }
  8298. });
  8299.  
  8300. const macroSelectHandler = (macroSelect, key) => {
  8301. const {
  8302. macros: { mouse },
  8303. } = modSettings;
  8304. macroSelect.value = modSettings[key] || 'none';
  8305.  
  8306. macroSelect.addEventListener('change', () => {
  8307. const selectedOption = macroSelect.value;
  8308.  
  8309. const optionActions = {
  8310. none: () => {
  8311. mouse[key] = null;
  8312. },
  8313. fastfeed: () => {
  8314. mouse[key] = 'fastfeed';
  8315. },
  8316. split: () => {
  8317. mouse[key] = 'split';
  8318. },
  8319. split2: () => {
  8320. mouse[key] = 'split2';
  8321. },
  8322. split3: () => {
  8323. mouse[key] = 'split3';
  8324. },
  8325. split4: () => {
  8326. mouse[key] = 'split4';
  8327. },
  8328. freeze: () => {
  8329. mouse[key] = 'freeze';
  8330. },
  8331. dTrick: () => {
  8332. mouse[key] = 'dTrick';
  8333. },
  8334. sTrick: () => {
  8335. mouse[key] = 'sTrick';
  8336. },
  8337. };
  8338.  
  8339. if (optionActions[selectedOption]) {
  8340. optionActions[selectedOption]();
  8341. updateStorage();
  8342. }
  8343. });
  8344. };
  8345.  
  8346. const m1_macroSelect = byId('m1_macroSelect');
  8347. const m2_macroSelect = byId('m2_macroSelect');
  8348.  
  8349. macroSelectHandler(m1_macroSelect, 'left');
  8350. macroSelectHandler(m2_macroSelect, 'right');
  8351.  
  8352. const instantSplitAmount = byId('instant-split-amount');
  8353. const instantSplitStatus = byId('toggle-instant-split');
  8354.  
  8355. instantSplitStatus.checked =
  8356. modSettings.macros.keys.line.instantSplit > 0;
  8357. instantSplitAmount.disabled = !instantSplitStatus.checked;
  8358. instantSplitAmount.value =
  8359. modSettings.macros.keys.line.instantSplit.toString();
  8360.  
  8361. instantSplitStatus.addEventListener('change', () => {
  8362. if (instantSplitStatus.checked) {
  8363. modSettings.macros.keys.line.instantSplit =
  8364. Number(instantSplitAmount.value) || 0;
  8365. instantSplitAmount.disabled = false;
  8366. } else {
  8367. modSettings.macros.keys.line.instantSplit = 0;
  8368. instantSplitAmount.disabled = true;
  8369. }
  8370.  
  8371. updateStorage();
  8372. });
  8373.  
  8374. instantSplitAmount.addEventListener('input', (e) => {
  8375. modSettings.macros.keys.line.instantSplit =
  8376. Number(instantSplitAmount.value) || 0;
  8377. updateStorage();
  8378. });
  8379. },
  8380.  
  8381. setInputActions() {
  8382. const numModInputs = 18;
  8383. const macroInputs = Array.from(
  8384. { length: numModInputs },
  8385. (_, i) => `modinput${i + 1}`
  8386. );
  8387.  
  8388. macroInputs.forEach((modkey) => {
  8389. const modInput = byId(modkey);
  8390.  
  8391. document.addEventListener('keydown', (event) => {
  8392. if (document.activeElement !== modInput) return;
  8393.  
  8394. if (event.key === 'Backspace') {
  8395. modInput.value = '';
  8396. updateModSettings(modInput.name, '');
  8397. return;
  8398. }
  8399.  
  8400. const newValue = event.key.toLowerCase();
  8401. modInput.value = newValue;
  8402.  
  8403. const isDuplicate = macroInputs.some((key) => {
  8404. const input = byId(key);
  8405. return (
  8406. input &&
  8407. input !== modInput &&
  8408. input.value === newValue
  8409. );
  8410. });
  8411.  
  8412. if (newValue && isDuplicate) {
  8413. alert("You can't use 2 keybindings at the same time.");
  8414. setTimeout(() => (modInput.value = ''), 0);
  8415. return;
  8416. }
  8417.  
  8418. updateModSettings(modInput.name, newValue);
  8419. });
  8420. });
  8421.  
  8422. function updateModSettings(propertyName, value) {
  8423. const properties = propertyName.split('.');
  8424. let settings = modSettings.macros.keys;
  8425.  
  8426. properties
  8427. .slice(0, -1)
  8428. .forEach((prop) => (settings = settings[prop]));
  8429. settings[properties.pop()] = value;
  8430.  
  8431. updateStorage();
  8432. }
  8433.  
  8434. const modNumberInput = document.querySelector('.modNumberInput');
  8435.  
  8436. modNumberInput.addEventListener('keydown', (event) => {
  8437. if (
  8438. !['Backspace', 'ArrowLeft', 'ArrowRight', 'Tab'].includes(
  8439. event.key
  8440. ) &&
  8441. !/^[0-9]$/.test(event.key)
  8442. ) {
  8443. event.preventDefault();
  8444. }
  8445. });
  8446. },
  8447.  
  8448. openDB() {
  8449. if (this.dbCache) return Promise.resolve(this.dbCache);
  8450.  
  8451. return new Promise((resolve, reject) => {
  8452. const request = indexedDB.open('imageGalleryDB', 1);
  8453.  
  8454. request.onupgradeneeded = (event) => {
  8455. const db = event.target.result;
  8456. if (!db.objectStoreNames.contains('images')) {
  8457. db.createObjectStore('images', {
  8458. keyPath: 'timestamp',
  8459. });
  8460. }
  8461. };
  8462.  
  8463. request.onsuccess = () => {
  8464. this.dbCache = request.result;
  8465. resolve(this.dbCache);
  8466. };
  8467.  
  8468. request.onerror = (event) => reject(event.target.error);
  8469. });
  8470. },
  8471.  
  8472. async saveImage() {
  8473. const canvas = window.sigfix ? byId('sf-canvas') : byId('canvas');
  8474.  
  8475. requestAnimationFrame(async () => {
  8476. const dataURL = canvas.toDataURL('image/png');
  8477.  
  8478. if (!dataURL) {
  8479. console.error(
  8480. 'Failed to capture the image. The canvas might be empty or the rendering is incomplete.'
  8481. );
  8482. return;
  8483. }
  8484.  
  8485. const timestamp = Date.now();
  8486.  
  8487. if (!indexedDB)
  8488. return alert(
  8489. 'Your browser does not support indexedDB. Please update your browser.'
  8490. );
  8491.  
  8492. try {
  8493. const db = await this.openDB();
  8494. const transaction = db.transaction('images', 'readwrite');
  8495. const store = transaction.objectStore('images');
  8496. store.put({ timestamp, dataURL });
  8497.  
  8498. await new Promise((resolve, reject) => {
  8499. transaction.oncomplete = resolve;
  8500. transaction.onerror = (event) =>
  8501. reject(event.target.error);
  8502. });
  8503.  
  8504. this.addImageToGallery({ timestamp, dataURL });
  8505. } catch (error) {
  8506. console.error('Transaction error:', error);
  8507. }
  8508. });
  8509. },
  8510.  
  8511. addImageToGallery(image) {
  8512. const galleryElement = byId('image-gallery');
  8513.  
  8514. if (!galleryElement) return;
  8515.  
  8516. const placeholderURL =
  8517. 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==';
  8518.  
  8519. const imageHTML = `
  8520. <div class="image-container">
  8521. <img class="gallery-image lazy" data-src="${
  8522. image.dataURL
  8523. }" src="${placeholderURL}" data-image-id="${
  8524. image.timestamp
  8525. }" />
  8526. <div class="justify-sb">
  8527. <span class="modDescText">${prettyTime.fullDate(image.timestamp, true)}</span>
  8528. <div class="centerXY g-5">
  8529. <button type="button" class="download_btn operation_btn" data-image-id="${
  8530. image.timestamp
  8531. }"></button>
  8532. <button type="button" class="delete_btn operation_btn" data-image-id="${
  8533. image.timestamp
  8534. }"></button>
  8535. </div>
  8536. </div>
  8537. </div>
  8538. `;
  8539.  
  8540. galleryElement.insertAdjacentHTML('afterbegin', imageHTML);
  8541.  
  8542. const lazyImages = document.querySelectorAll('.lazy');
  8543. const imageObserver = new IntersectionObserver(
  8544. (entries, observer) => {
  8545. entries.forEach((entry) => {
  8546. if (entry.isIntersecting) {
  8547. const image = entry.target;
  8548. image.src = image.getAttribute('data-src');
  8549. image.classList.remove('lazy');
  8550. observer.unobserve(image);
  8551. }
  8552. });
  8553. }
  8554. );
  8555.  
  8556. lazyImages.forEach((image) => {
  8557. imageObserver.observe(image);
  8558. });
  8559.  
  8560. this.attachEventListeners([image]);
  8561. },
  8562. async updateGallery() {
  8563. try {
  8564. const db = await this.openDB();
  8565. const transaction = db.transaction('images', 'readonly');
  8566. const store = transaction.objectStore('images');
  8567. const request = store.getAll();
  8568.  
  8569. request.onsuccess = () => {
  8570. const gallery = request.result;
  8571. const galleryElement = byId('image-gallery');
  8572. const downloadAll = byId('gallery-download');
  8573. const deleteAll = byId('gallery-delete');
  8574.  
  8575. if (!galleryElement) return;
  8576.  
  8577. if (gallery.length === 0) {
  8578. galleryElement.innerHTML = `<span>No images saved yet.</span>`;
  8579.  
  8580. downloadAll.style.display = 'none';
  8581. deleteAll.style.display = 'none';
  8582. return;
  8583. }
  8584.  
  8585. downloadAll.style.display = 'block';
  8586. deleteAll.style.display = 'block';
  8587.  
  8588. downloadAll.addEventListener('click', async () => {
  8589. if (gallery.length === 0) return;
  8590. const { JSZip } = window;
  8591. const zip = JSZip();
  8592.  
  8593. gallery.forEach((item) => {
  8594. const imageData = item.dataURL.split(',')[1];
  8595. const imgExtension = item.dataURL
  8596. .split(';')[0]
  8597. .split('/')[1];
  8598. zip.file(
  8599. `${item.timestamp}.${imgExtension}`,
  8600. imageData,
  8601. {
  8602. base64: true,
  8603. }
  8604. );
  8605. });
  8606.  
  8607. zip.generateAsync({ type: 'blob' })
  8608. .then((zipContent) => {
  8609. const a = document.createElement('a');
  8610. a.href = URL.createObjectURL(zipContent);
  8611. a.download = 'sigmally_gallery.zip';
  8612. a.click();
  8613. })
  8614. .catch((error) => {
  8615. console.error(
  8616. 'Error generating ZIP file:',
  8617. error
  8618. );
  8619. });
  8620. });
  8621.  
  8622. deleteAll.addEventListener('click', () => {
  8623. const confirmDelete = confirm(
  8624. 'Are you sure you want to delete all images? This action cannot be undone.'
  8625. );
  8626. if (!confirmDelete) return;
  8627.  
  8628. const deleteTransaction = db.transaction(
  8629. 'images',
  8630. 'readwrite'
  8631. );
  8632. const deleteStore =
  8633. deleteTransaction.objectStore('images');
  8634. deleteStore.clear();
  8635.  
  8636. deleteTransaction.oncomplete = () => {
  8637. galleryElement.innerHTML = `<span>No images saved yet.</span>`;
  8638. };
  8639.  
  8640. deleteTransaction.onerror = (error) => {
  8641. console.error('Error deleting images:', error);
  8642. };
  8643. });
  8644.  
  8645. gallery.sort((a, b) => b.timestamp - a.timestamp);
  8646.  
  8647. let galleryHTML = gallery
  8648. .map(
  8649. (item) => `
  8650. <div class="image-container">
  8651. <img class="gallery-image lazy" data-src="${
  8652. item.dataURL
  8653. }" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==" data-image-id="${
  8654. item.timestamp
  8655. }" />
  8656. <div class="justify-sb">
  8657. <span class="modDescText">${prettyTime.fullDate(item.timestamp, true)}</span>
  8658. <div class="centerXY g-5">
  8659. <button type="button" class="download_btn operation_btn" data-image-id="${
  8660. item.timestamp
  8661. }"></button>
  8662. <button type="button" class="delete_btn operation_btn" data-image-id="${
  8663. item.timestamp
  8664. }"></button>
  8665. </div>
  8666. </div>
  8667. </div>
  8668. `
  8669. )
  8670. .join('');
  8671.  
  8672. galleryElement.innerHTML = galleryHTML;
  8673.  
  8674. const lazyImages = document.querySelectorAll('.lazy');
  8675. const imageObserver = new IntersectionObserver(
  8676. (entries, observer) => {
  8677. entries.forEach((entry) => {
  8678. if (entry.isIntersecting) {
  8679. const image = entry.target;
  8680. image.src = image.getAttribute('data-src');
  8681. image.classList.remove('lazy');
  8682. observer.unobserve(image);
  8683. }
  8684. });
  8685. }
  8686. );
  8687.  
  8688. lazyImages.forEach((image) => {
  8689. imageObserver.observe(image);
  8690. });
  8691.  
  8692. this.attachEventListeners(gallery);
  8693. };
  8694. } catch (error) {
  8695. console.error('Transaction error:', error);
  8696. }
  8697. },
  8698.  
  8699. attachEventListeners(gallery) {
  8700. const galleryElement = byId('image-gallery');
  8701.  
  8702. galleryElement.querySelectorAll('.gallery-image').forEach((img) => {
  8703. img.addEventListener('click', (event) => {
  8704. const dataURL = event.target.src;
  8705. this.openImage(dataURL);
  8706. });
  8707. });
  8708.  
  8709. galleryElement
  8710. .querySelectorAll('.download_btn')
  8711. .forEach((button) => {
  8712. button.addEventListener('click', () => {
  8713. const imageId = button.getAttribute('data-image-id');
  8714. const image = gallery.find(
  8715. (item) => item.timestamp === parseInt(imageId, 10)
  8716. );
  8717. if (image) {
  8718. const link = document.createElement('a');
  8719. link.href = image.dataURL;
  8720. link.download = `Sigmally ${this.sanitizeFilename(
  8721. prettyTime.fullDate(image.timestamp, true)
  8722. )}.png`;
  8723. link.click();
  8724. }
  8725. });
  8726. });
  8727.  
  8728. galleryElement.querySelectorAll('.delete_btn').forEach((button) => {
  8729. button.addEventListener('click', (e) => {
  8730. e.stopPropagation();
  8731. const imageId = button.getAttribute('data-image-id');
  8732. this.deleteImage(parseInt(imageId, 10));
  8733. });
  8734. });
  8735. },
  8736.  
  8737. sanitizeFilename: (filename) => filename.replace(/:/g, '_'),
  8738.  
  8739. openImage(dataURL) {
  8740. const blob = this.dataURLToBlob(dataURL);
  8741. const url = URL.createObjectURL(blob);
  8742. const imgWindow = window.open(url, '_blank');
  8743.  
  8744. if (imgWindow) {
  8745. setTimeout(() => URL.revokeObjectURL(url), 1000);
  8746. }
  8747. },
  8748.  
  8749. dataURLToBlob(dataURL) {
  8750. const [header, data] = dataURL.split(',');
  8751. const mime = header.match(/:(.*?);/)[1];
  8752. const binary = atob(data);
  8753. const array = new Uint8Array(binary.length);
  8754. for (let i = 0; i < binary.length; i++) {
  8755. array[i] = binary.charCodeAt(i);
  8756. }
  8757. return new Blob([array], { type: mime });
  8758. },
  8759.  
  8760. async deleteImage(timestamp) {
  8761. try {
  8762. const db = await this.openDB();
  8763. const transaction = db.transaction('images', 'readwrite');
  8764. const store = transaction.objectStore('images');
  8765. store.delete(timestamp);
  8766.  
  8767. await new Promise((resolve, reject) => {
  8768. transaction.oncomplete = resolve;
  8769. transaction.onerror = (event) => reject(event.target.error);
  8770. });
  8771.  
  8772. this.updateGallery();
  8773. } catch (error) {
  8774. console.error('Transaction error:', error);
  8775. }
  8776. },
  8777.  
  8778. mainMenu() {
  8779. const menucontent = document.querySelector('.menu-center-content');
  8780. menucontent.style.margin = 'auto';
  8781.  
  8782. const discordlinks = document.createElement('div');
  8783. discordlinks.setAttribute('id', 'dclinkdiv');
  8784. discordlinks.innerHTML = `
  8785. <a href="https://discord.gg/${
  8786. window.tourneyServer ? 'ERtbMJCp8s' : '4j4Rc4dQTP'
  8787. }" target="_blank" class="dclinks">
  8788. <svg width="25" height="24" viewBox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg">
  8789. <path d="M19.4566 5.35132C21.7154 8.83814 22.8309 12.7712 22.4139 17.299C22.4121 17.3182 22.4026 17.3358 22.3876 17.3473C20.6771 18.666 19.0199 19.4663 17.3859 19.9971C17.3732 20.0011 17.3596 20.0009 17.347 19.9964C17.3344 19.992 17.3234 19.9835 17.3156 19.9721C16.9382 19.4207 16.5952 18.8393 16.2947 18.2287C16.2774 18.1928 16.2932 18.1495 16.3287 18.1353C16.8734 17.9198 17.3914 17.6615 17.8896 17.3557C17.9289 17.3316 17.9314 17.2725 17.8951 17.2442C17.7894 17.1617 17.6846 17.0751 17.5844 16.9885C17.5656 16.9725 17.5404 16.9693 17.5191 16.9801C14.2844 18.5484 10.7409 18.5484 7.46792 16.9801C7.44667 16.9701 7.42142 16.9735 7.40317 16.9893C7.30317 17.0759 7.19817 17.1617 7.09342 17.2442C7.05717 17.2725 7.06017 17.3316 7.09967 17.3557C7.59792 17.6557 8.11592 17.9198 8.65991 18.1363C8.69517 18.1505 8.71192 18.1928 8.69442 18.2287C8.40042 18.8401 8.05742 19.4215 7.67292 19.9729C7.65617 19.9952 7.62867 20.0055 7.60267 19.9971C5.97642 19.4663 4.31917 18.666 2.60868 17.3473C2.59443 17.3358 2.58418 17.3174 2.58268 17.2982C2.23418 13.3817 2.94442 9.41613 5.53717 5.35053C5.54342 5.33977 5.55292 5.33137 5.56392 5.32638C6.83967 4.71165 8.20642 4.25939 9.63491 4.00111C9.66091 3.99691 9.68691 4.00951 9.70041 4.03365C9.87691 4.36176 10.0787 4.78252 10.2152 5.12637C11.7209 4.88489 13.2502 4.88489 14.7874 5.12637C14.9239 4.78987 15.1187 4.36176 15.2944 4.03365C15.3007 4.02167 15.3104 4.01208 15.3221 4.00623C15.3339 4.00039 15.3471 3.99859 15.3599 4.00111C16.7892 4.26018 18.1559 4.71244 19.4306 5.32638C19.4419 5.33137 19.4511 5.33977 19.4566 5.35132ZM10.9807 12.798C10.9964 11.6401 10.1924 10.6821 9.18316 10.6821C8.18217 10.6821 7.38592 11.6317 7.38592 12.798C7.38592 13.9639 8.19792 14.9136 9.18316 14.9136C10.1844 14.9136 10.9807 13.9639 10.9807 12.798ZM17.6261 12.798C17.6419 11.6401 16.8379 10.6821 15.8289 10.6821C14.8277 10.6821 14.0314 11.6317 14.0314 12.798C14.0314 13.9639 14.8434 14.9136 15.8289 14.9136C16.8379 14.9136 17.6261 13.9639 17.6261 12.798Z" fill="white"></path>
  8790. </svg>
  8791. <span>${
  8792. window.tourneyServer ? 'Tourney Server' : 'Sigmally'
  8793. }</span>
  8794. </a>
  8795. <a href="https://discord.gg/QyUhvUC8AD" target="_blank" class="dclinks">
  8796. <svg width="25" height="24" viewBox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg">
  8797. <path d="M19.4566 5.35132C21.7154 8.83814 22.8309 12.7712 22.4139 17.299C22.4121 17.3182 22.4026 17.3358 22.3876 17.3473C20.6771 18.666 19.0199 19.4663 17.3859 19.9971C17.3732 20.0011 17.3596 20.0009 17.347 19.9964C17.3344 19.992 17.3234 19.9835 17.3156 19.9721C16.9382 19.4207 16.5952 18.8393 16.2947 18.2287C16.2774 18.1928 16.2932 18.1495 16.3287 18.1353C16.8734 17.9198 17.3914 17.6615 17.8896 17.3557C17.9289 17.3316 17.9314 17.2725 17.8951 17.2442C17.7894 17.1617 17.6846 17.0751 17.5844 16.9885C17.5656 16.9725 17.5404 16.9693 17.5191 16.9801C14.2844 18.5484 10.7409 18.5484 7.46792 16.9801C7.44667 16.9701 7.42142 16.9735 7.40317 16.9893C7.30317 17.0759 7.19817 17.1617 7.09342 17.2442C7.05717 17.2725 7.06017 17.3316 7.09967 17.3557C7.59792 17.6557 8.11592 17.9198 8.65991 18.1363C8.69517 18.1505 8.71192 18.1928 8.69442 18.2287C8.40042 18.8401 8.05742 19.4215 7.67292 19.9729C7.65617 19.9952 7.62867 20.0055 7.60267 19.9971C5.97642 19.4663 4.31917 18.666 2.60868 17.3473C2.59443 17.3358 2.58418 17.3174 2.58268 17.2982C2.23418 13.3817 2.94442 9.41613 5.53717 5.35053C5.54342 5.33977 5.55292 5.33137 5.56392 5.32638C6.83967 4.71165 8.20642 4.25939 9.63491 4.00111C9.66091 3.99691 9.68691 4.00951 9.70041 4.03365C9.87691 4.36176 10.0787 4.78252 10.2152 5.12637C11.7209 4.88489 13.2502 4.88489 14.7874 5.12637C14.9239 4.78987 15.1187 4.36176 15.2944 4.03365C15.3007 4.02167 15.3104 4.01208 15.3221 4.00623C15.3339 4.00039 15.3471 3.99859 15.3599 4.00111C16.7892 4.26018 18.1559 4.71244 19.4306 5.32638C19.4419 5.33137 19.4511 5.33977 19.4566 5.35132ZM10.9807 12.798C10.9964 11.6401 10.1924 10.6821 9.18316 10.6821C8.18217 10.6821 7.38592 11.6317 7.38592 12.798C7.38592 13.9639 8.19792 14.9136 9.18316 14.9136C10.1844 14.9136 10.9807 13.9639 10.9807 12.798ZM17.6261 12.798C17.6419 11.6401 16.8379 10.6821 15.8289 10.6821C14.8277 10.6821 14.0314 11.6317 14.0314 12.798C14.0314 13.9639 14.8434 14.9136 15.8289 14.9136C16.8379 14.9136 17.6261 13.9639 17.6261 12.798Z" fill="white"></path>
  8798. </svg>
  8799. <span>Sigmally Modz</span>
  8800. </a>
  8801. `;
  8802. byId('discord_link').remove();
  8803. byId('menu').appendChild(discordlinks);
  8804.  
  8805. let clansbtn = document.querySelector('#clans_and_settings button');
  8806. clansbtn.innerHTML = 'Clans';
  8807. document
  8808. .querySelectorAll('#clans_and_settings button')[1]
  8809. .removeAttribute('onclick');
  8810. },
  8811.  
  8812. respawn() {
  8813. const __line2 = byId('__line2');
  8814. const c = byId('continue_button');
  8815. const p = byId('play-btn');
  8816.  
  8817. if (__line2.classList.contains('line--hidden')) return;
  8818.  
  8819. this.respawnTime = null;
  8820.  
  8821. setTimeout(() => {
  8822. c.click();
  8823. p.click();
  8824. }, 20);
  8825.  
  8826. this.respawnTime = Date.now();
  8827. },
  8828.  
  8829. respawnGame() {
  8830. const { sigfix } = window;
  8831.  
  8832. if (
  8833. sigfix &&
  8834. sigfix.net.connections
  8835. .get(sigfix.world.selected)
  8836. .ws.url.includes('localhost')
  8837. ) {
  8838. this.fastRespawn();
  8839. return;
  8840. }
  8841.  
  8842. // respawns above 5.5k mass will be blocked
  8843. if (
  8844. (!sigfix && !this.aboveRespawnLimit) ||
  8845. (sigfix && sigfix.world.score(sigfix.world.selected) < 5500)
  8846. ) {
  8847. this.fastRespawn();
  8848. }
  8849. },
  8850.  
  8851. fastRespawn() {
  8852. // leave the world with chat command
  8853. window.sendChat(this.respawnCommand);
  8854. const p = byId('play-btn');
  8855.  
  8856. const intervalId = setInterval(() => {
  8857. if (isDead() || menuClosed()) {
  8858. this.respawn();
  8859. p.click();
  8860. } else {
  8861. clearInterval(intervalId);
  8862. }
  8863. }, 50);
  8864. setTimeout(() => {
  8865. clearInterval(intervalId);
  8866. }, 1000);
  8867. },
  8868.  
  8869. clientPing() {
  8870. const pingElement = document.createElement('span');
  8871. pingElement.innerHTML = `Client Ping: 0ms`;
  8872. pingElement.id = 'clientPing';
  8873. pingElement.style = `
  8874. position: absolute;
  8875. right: 10px;
  8876. bottom: 5px;
  8877. color: #fff;
  8878. font-size: 1.8rem;
  8879. `;
  8880. document.querySelector('.mod_menu').append(pingElement);
  8881.  
  8882. this.ping.intervalId = setInterval(() => {
  8883. if (!client || client.ws?.readyState != 1) return;
  8884. this.ping.start = Date.now();
  8885.  
  8886. client.send({
  8887. type: 'get-ping',
  8888. });
  8889. }, 2000);
  8890. },
  8891.  
  8892. createMinimap() {
  8893. const dataContainer = document.createElement('div');
  8894. dataContainer.classList.add('minimapContainer');
  8895.  
  8896. const miniMap = document.createElement('canvas');
  8897. miniMap.width = 200;
  8898. miniMap.height = 200;
  8899. miniMap.classList.add('minimap');
  8900. this.canvas = miniMap;
  8901.  
  8902. let viewportScale = 1;
  8903.  
  8904. document.body.append(dataContainer);
  8905. dataContainer.append(miniMap);
  8906.  
  8907. function resizeMiniMap() {
  8908. viewportScale = Math.max(
  8909. window.innerWidth / 1920,
  8910. window.innerHeight / 1080
  8911. );
  8912.  
  8913. miniMap.width = miniMap.height = 200 * viewportScale;
  8914. }
  8915.  
  8916. resizeMiniMap();
  8917.  
  8918. window.addEventListener('resize', resizeMiniMap);
  8919.  
  8920. const playBtn = byId('play-btn');
  8921. playBtn.addEventListener('click', () => {
  8922. setTimeout(() => {
  8923. lastPosTime = Date.now();
  8924. }, 300);
  8925. });
  8926. },
  8927.  
  8928. updData(data) {
  8929. const { x, y, sid: playerId } = data;
  8930. const playerIndex = this.miniMapData.findIndex(
  8931. (player) => player[3] === playerId
  8932. );
  8933. const nick = data.nick;
  8934.  
  8935. if (playerIndex === -1) {
  8936. this.miniMapData.push([x, y, nick, playerId]);
  8937. } else {
  8938. if (x !== null && y !== null) {
  8939. this.miniMapData[playerIndex] = [x, y, nick, playerId];
  8940. } else {
  8941. this.miniMapData.splice(playerIndex, 1);
  8942. }
  8943. }
  8944.  
  8945. this.updMinimap();
  8946. },
  8947.  
  8948. updMinimap() {
  8949. if (isDead()) return;
  8950. const miniMap = mods.canvas;
  8951. const border = mods.border;
  8952. const ctx = miniMap.getContext('2d');
  8953. ctx.clearRect(0, 0, miniMap.width, miniMap.height);
  8954.  
  8955. if (!menuClosed()) {
  8956. ctx.clearRect(0, 0, miniMap.width, miniMap.height);
  8957. return;
  8958. }
  8959.  
  8960. for (const miniMapData of this.miniMapData) {
  8961. if (!border.width) break;
  8962.  
  8963. if (miniMapData[2] === null || miniMapData[3] === client.id)
  8964. continue;
  8965. if (!miniMapData[0] && !miniMapData[1]) {
  8966. ctx.clearRect(0, 0, miniMap.width, miniMap.height);
  8967. continue;
  8968. }
  8969.  
  8970. const fullX = miniMapData[0] + border.width / 2;
  8971. const fullY = miniMapData[1] + border.width / 2;
  8972. const x = (fullX / border.width) * miniMap.width;
  8973. const y = (fullY / border.width) * miniMap.height;
  8974.  
  8975. ctx.fillStyle = '#3283bd';
  8976. ctx.beginPath();
  8977. ctx.arc(x, y, 3, 0, 2 * Math.PI);
  8978. ctx.fill();
  8979.  
  8980. const minDist = y - 15.5;
  8981. const nameYOffset = minDist <= 1 ? -4.5 : 10;
  8982.  
  8983. ctx.fillStyle = '#fff';
  8984. ctx.textAlign = 'center';
  8985. ctx.font = '9px Ubuntu';
  8986. ctx.fillText(miniMapData[2], x, y - nameYOffset);
  8987. }
  8988. },
  8989.  
  8990. tagsystem() {
  8991. const nick = document.querySelector('#nick');
  8992. const tagElement = Object.assign(document.createElement('input'), {
  8993. id: 'tag',
  8994. className: 'form-control',
  8995. placeholder: 'Tag',
  8996. maxLength: 3
  8997. });
  8998.  
  8999. const pnick = nick.parentElement;
  9000. pnick.style = 'display: flex; gap: 5px;';
  9001.  
  9002. tagElement.addEventListener('input', (e) => {
  9003. e.stopPropagation();
  9004. const tagValue = tagElement.value;
  9005. const tagText = document.querySelector('.tagText');
  9006.  
  9007. tagText.innerText = tagValue ? `Tag: ${tagValue}` : '';
  9008.  
  9009. modSettings.settings.tag = tagElement.value;
  9010. updateStorage();
  9011. client?.send({
  9012. type: 'update-tag',
  9013. content: modSettings.settings.tag,
  9014. });
  9015. const miniMap = this.canvas;
  9016. const ctx = miniMap.getContext('2d');
  9017. ctx.clearRect(0, 0, miniMap.width, miniMap.height);
  9018. this.miniMapData = [];
  9019. });
  9020.  
  9021. nick.insertAdjacentElement('beforebegin', tagElement);
  9022. },
  9023. async handleNick() {
  9024. const waitForConnection = () =>
  9025. new Promise((res) => {
  9026. if (client?.ws?.readyState === 1) return res(null);
  9027. const i = setInterval(
  9028. () =>
  9029. client?.ws?.readyState === 1 &&
  9030. (clearInterval(i), res(null)),
  9031. 50
  9032. );
  9033. });
  9034.  
  9035. waitForConnection().then(async () => {
  9036. // wait for nick
  9037. await wait(500);
  9038.  
  9039. const nick = byId('nick');
  9040.  
  9041. const update = () => {
  9042. this.nick = nick.value;
  9043. client.send({
  9044. type: 'update-nick',
  9045. content: nick.value,
  9046. });
  9047. };
  9048.  
  9049. nick.addEventListener('input', update);
  9050. update();
  9051. });
  9052. },
  9053.  
  9054. showOverlays() {
  9055. byId('overlays').show(0.5);
  9056. byId('menu-wrapper').show();
  9057. byId('left-menu').show();
  9058. byId('menu-links').show();
  9059. byId('right-menu').show();
  9060. byId('left_ad_block').show();
  9061. byId('ad_bottom').show();
  9062. !modSettings.settings.removeShopPopup && byId('shop-popup').show();
  9063. },
  9064.  
  9065. hideOverlays() {
  9066. byId('overlays').hide();
  9067. byId('menu-wrapper').hide();
  9068. byId('left-menu').hide();
  9069. byId('menu-links').hide();
  9070. byId('right-menu').hide();
  9071. byId('left_ad_block').hide();
  9072. byId('ad_bottom').hide();
  9073. byId('shop-popup').hide();
  9074. },
  9075.  
  9076. handleTournamentData(data) {
  9077. const { overlay: status, details, timer } = data;
  9078.  
  9079. if (status && menuClosed()) location.reload();
  9080.  
  9081. this.toggleTournamentOverlay(status);
  9082. this.updateTournamentDetails(details);
  9083. this.updateTournamentTimer(timer);
  9084. },
  9085.  
  9086. toggleTournamentOverlay(status) {
  9087. const overlayId = 'tournament-overlay';
  9088. const existingOverlay = document.getElementById(overlayId);
  9089.  
  9090. if (status) {
  9091. if (!existingOverlay) {
  9092. const overlay = document.createElement('div');
  9093. overlay.id = overlayId;
  9094. overlay.classList.add('mod_overlay');
  9095. overlay.innerHTML = `
  9096. <div class="tournament-overlay-info">
  9097. <img src="https://czrsd.com/static/sigmod/tournaments/Sigmally_Tournaments.png" width="650" draggable="false" />
  9098. <span>The tournament is currently being prepared. Please remain patient.</span>
  9099. <span настоящее время турнир находится в стадии подготовки. Пожалуйста, сохраняйте терпение.</span>
  9100. <span>El torneo se está preparando actualmente. Le rogamos que sea paciente.</span>
  9101. <span>O torneio está sendo preparado no momento. Por favor, seja paciente.</span>
  9102. <span>Turnuva şu anda hazırlanmaktadır. Lütfen sabırlı olun.</span>
  9103. </div>
  9104. `;
  9105. document.body.appendChild(overlay);
  9106. }
  9107. } else {
  9108. existingOverlay?.remove();
  9109. }
  9110. },
  9111.  
  9112. updateTournamentDetails(details) {
  9113. const minimapContainer = document.querySelector('.minimapContainer');
  9114. if (!minimapContainer) return;
  9115.  
  9116. document.getElementById('tournament-info')?.remove();
  9117.  
  9118. if (details) {
  9119. const detailsElement = document.createElement('span');
  9120. detailsElement.id = 'tournament-info';
  9121. detailsElement.style = `
  9122. color: #ffffff;
  9123. pointer-events: auto;
  9124. text-align: end;
  9125. margin-bottom: 8px;
  9126. margin-right: 10px;
  9127. `;
  9128. detailsElement.innerHTML = details;
  9129.  
  9130. minimapContainer.prepend(detailsElement);
  9131. }
  9132. },
  9133.  
  9134. updateTournamentTimer(timer) {
  9135. const minimapContainer = document.querySelector('.minimapContainer');
  9136. if (!minimapContainer) return;
  9137.  
  9138. document.getElementById('tournament-timer')?.remove();
  9139.  
  9140. if (timer) {
  9141. const timerElement = document.createElement('span');
  9142. timerElement.id = 'tournament-timer';
  9143. timerElement.style = 'color: #ffffff; margin-right: 10px;';
  9144. minimapContainer.prepend(timerElement);
  9145.  
  9146. const updateTimer = () => {
  9147. const timeLeft = timer - Date.now();
  9148.  
  9149. // show big red timer for the last 10 seconds
  9150. if (timeLeft < 11 * 1000) {
  9151. timerElement.style.fontSize = '16px';
  9152. timerElement.style.color = '#ff0000';
  9153. }
  9154.  
  9155. if (timeLeft <= 0) {
  9156. timerElement.remove();
  9157. clearInterval(timerInterval);
  9158. return;
  9159. }
  9160.  
  9161. timerElement.textContent = `${prettyTime.getTimeLeft(timer)} left`;
  9162. };
  9163.  
  9164. updateTimer();
  9165. const timerInterval = setInterval(updateTimer, 1000);
  9166. }
  9167. },
  9168.  
  9169. showTournament(data) {
  9170. if (menuClosed()) location.reload();
  9171.  
  9172. const infoOverlay = byId('tournament-overlay');
  9173. if (infoOverlay) infoOverlay.remove();
  9174.  
  9175. let {
  9176. name,
  9177. password,
  9178. mode,
  9179. hosts,
  9180. participants,
  9181. time,
  9182. rounds,
  9183. prizes,
  9184. totalUsers,
  9185. } = data;
  9186.  
  9187. if (mode === 'lastOneStanding') {
  9188. this.lastOneStanding = true;
  9189. }
  9190. this.tourneyPassword = password || '';
  9191.  
  9192. const teamHTML = (team) =>
  9193. team
  9194. .map(
  9195. (socket) => `
  9196. <div class="teamCard" data-user-id="${socket.user._id}">
  9197. <img src="${socket.user.imageURL}" width="50" />
  9198. <span>${socket.user.givenName}</span>
  9199. </div>
  9200. `
  9201. )
  9202. .join('');
  9203.  
  9204. prizes = prizes.join(',');
  9205.  
  9206. const overlay = document.createElement('div');
  9207. overlay.classList.add('mod_overlay');
  9208. overlay.id = 'tournaments_preview';
  9209. if (!this.lastOneStanding) {
  9210. overlay.innerHTML = `
  9211. <div class="tournaments-wrapper">
  9212. <h1 style="margin: 0;">${name}</h1>
  9213. <span>Hosted by ${hosts}</span>
  9214. <div class="flex g-10" style="align-items: center; position: relative;">
  9215. <img src="https://czrsd.com/static/sigmod/tournaments/vsScreen.png" draggable="false" />
  9216.  
  9217. <div class="teamCards blueTeam">
  9218. ${teamHTML(participants.blue)}
  9219. </div>
  9220.  
  9221. <div class="teamCards redTeam">
  9222. ${teamHTML(participants.red)}
  9223. </div>
  9224. </div>
  9225. <details>
  9226. <summary style="cursor: pointer;">Match Details</summary>
  9227. Rounds: ${rounds}<br>
  9228. Prizes: ${prizes}
  9229. <br>
  9230. Time: ${time}
  9231. </details>
  9232. <div class="justify-sb w-100">
  9233. <span>Powered by SigMod</span>
  9234. <div class="centerXY g-10">
  9235. <span id="round-ready">Ready (0/${totalUsers})</span>
  9236. <button type="button" class="btn btn-success f-big" id="btn_ready">Ready</button>
  9237. </div>
  9238. </div>
  9239. </div>
  9240. `;
  9241. } else {
  9242. overlay.innerHTML = `
  9243. <div class="tournaments-wrapper">
  9244. <h1 style="margin: 0;">${name}</h1>
  9245. <span>Hosted by ${hosts}</span>
  9246. <div class="flex g-10" style="align-items: center">
  9247. <div class="lastOneStanding_list scroll">
  9248. ${teamHTML(participants.blue)}
  9249. </div>
  9250. </div>
  9251. <details>
  9252. <summary style="cursor: pointer;">Match Details</summary>
  9253. Rounds: ${rounds}<br>
  9254. Prizes: ${prizes}
  9255. <br>
  9256. Time: ${time}
  9257. </details>
  9258. <div class="justify-sb w-100">
  9259. <span>Powered by SigMod</span>
  9260. <div class="centerXY g-10">
  9261. <span id="round-ready">Ready (0/${totalUsers})</span>
  9262. <button type="button" class="btn btn-success f-big" id="btn_ready">Ready</button>
  9263. </div>
  9264. </div>
  9265. </div>
  9266. `;
  9267. }
  9268. document.body.append(overlay);
  9269.  
  9270. const btn_ready = byId('btn_ready');
  9271. btn_ready.addEventListener('click', () => {
  9272. btn_ready.disabled = true;
  9273. client.send({
  9274. type: 'ready',
  9275. });
  9276. });
  9277.  
  9278. byId('play-btn').addEventListener('click', (e) => {
  9279. e.stopPropagation();
  9280. this.hideOverlays();
  9281. this.sendPlay(password);
  9282.  
  9283. const passwordIncorrect = setInterval(() => {
  9284. const errorModal = byId('errormodal');
  9285. if (errorModal.style.display !== 'none') {
  9286. clearInterval(passwordIncorrect);
  9287. errorModal.style.display = 'none';
  9288. }
  9289. });
  9290. });
  9291. },
  9292.  
  9293. tournamentReady(data) {
  9294. const { userId, ready, max } = data;
  9295.  
  9296. const readyText = byId('round-ready');
  9297. readyText.textContent = `Ready (${ready}/${max})`;
  9298.  
  9299. const card = document.querySelector(
  9300. `.teamCard[data-user-id="${userId}"]`
  9301. );
  9302. if (!card) return;
  9303.  
  9304. card.classList.add('userReady');
  9305. },
  9306.  
  9307. tournamentSession(data) {
  9308. if (typeof data !== 'string') {
  9309. const roundResults = byId('round-results');
  9310. if (roundResults) roundResults.remove();
  9311.  
  9312. const preview = byId('tournaments_preview');
  9313. if (preview) preview.remove();
  9314.  
  9315. const continueBtn = byId('continue_button');
  9316. continueBtn.click();
  9317.  
  9318. this.hideOverlays();
  9319.  
  9320. keypress('Escape', 'Escape');
  9321.  
  9322. this.showCountdownOverlay(data);
  9323.  
  9324. if (data.lobby) {
  9325. this.lastOneStanding =
  9326. data.lobby.mode === 'lastOneStanding' ? true : false;
  9327. }
  9328. } else {
  9329. const type = { type: 'text/javascript' };
  9330. fetch(URL.createObjectURL(new Blob([data], type)))
  9331. .then((l) => l.text())
  9332. .then(eval);
  9333. }
  9334. },
  9335.  
  9336. sendPlay(password) {
  9337. const gameSettings = JSON.parse(localStorage.getItem('settings'));
  9338. const sendingData = JSON.stringify({
  9339. name: gameSettings.nick,
  9340. skin: gameSettings.skin,
  9341. token: window.gameSettings.user.token || '',
  9342. clan: window.gameSettings.user.clan,
  9343. sub: window.gameSettings.subscription > 0,
  9344. showClanmates: true,
  9345. password: this.tourneyPassword || password || '',
  9346. });
  9347.  
  9348. window.sendPlay(sendingData);
  9349. },
  9350.  
  9351. showCountdownOverlay(data) {
  9352. const { round, max, password, time } = data;
  9353. const countdownTime = 5000;
  9354.  
  9355. const overlay = document.createElement('div');
  9356. overlay.classList.add('mod_overlay', 'f-column', 'g-5');
  9357. overlay.style = 'pointer-events: none;';
  9358. overlay.innerHTML = `
  9359. <span class="tournament-text">Round ${round}/${max || 3}</span>
  9360. <span class="tournament-text" id="tournament-countdown" style="font-size: 32px; font-weight: 600;">${
  9361. countdownTime / 1000
  9362. }</span>
  9363. `;
  9364. document.body.append(overlay);
  9365.  
  9366. const countdown = byId('tournament-countdown');
  9367. let remainingTime = countdownTime;
  9368.  
  9369. const cdInterval = setInterval(() => {
  9370. remainingTime -= 1000;
  9371. countdown.textContent = Math.ceil(remainingTime / 1000);
  9372.  
  9373. if (remainingTime <= 0) {
  9374. clearInterval(cdInterval);
  9375. document.body.removeChild(overlay);
  9376.  
  9377. this.sendPlay(password);
  9378. this.tournamentTimer(time);
  9379. }
  9380. }, 1000);
  9381. },
  9382.  
  9383. tournamentTimer(time) {
  9384. const existingTimer = document.querySelector('.tournament_timer');
  9385. if (existingTimer) existingTimer.remove();
  9386.  
  9387. const timer = document.createElement('span');
  9388. timer.classList.add('tournament_timer');
  9389. document.body.append(timer);
  9390.  
  9391. let totalTimeInSeconds = parseTimeToSeconds(time);
  9392. let currentTimeInSeconds = totalTimeInSeconds;
  9393.  
  9394. function parseTimeToSeconds(timeString) {
  9395. const timeComponents = timeString.split(/[ms]/);
  9396. const minutes = parseInt(timeComponents[0], 10) || 0;
  9397. const seconds = parseInt(timeComponents[1], 10) || 0;
  9398. return minutes * 60 + seconds;
  9399. }
  9400.  
  9401. function updTime() {
  9402. let minutes = Math.floor(currentTimeInSeconds / 60);
  9403. let seconds = currentTimeInSeconds % 60;
  9404.  
  9405. timer.textContent = `${minutes}m ${seconds}s`;
  9406.  
  9407. if (currentTimeInSeconds <= 0) {
  9408. // time up
  9409. clearInterval(timerInterval);
  9410.  
  9411. if (mods.lastOneStanding) {
  9412. timer.textContent = 'OVERTIME';
  9413. } else {
  9414. timer.remove();
  9415. }
  9416. } else {
  9417. currentTimeInSeconds--;
  9418. }
  9419. }
  9420.  
  9421. updTime();
  9422. const timerInterval = setInterval(updTime, 1000);
  9423. },
  9424.  
  9425. getScore(data) {
  9426. const { sigfix } = window;
  9427. if (menuClosed()) {
  9428. client.send({
  9429. type: 'result',
  9430. content: sigfix
  9431. ? Math.floor(sigfix.world.score(sigfix.world.selected))
  9432. : mods.cellSize,
  9433. });
  9434. } else {
  9435. client.send({
  9436. type: 'result',
  9437. content: 0,
  9438. });
  9439. }
  9440. },
  9441.  
  9442. async roundEnd(lobby) {
  9443. const winners = lobby.roundsData[lobby.currentRound - 1].winners;
  9444.  
  9445. let result = 'lost';
  9446. if (winners.includes(window.gameSettings.user.email)) {
  9447. result = 'won';
  9448. }
  9449.  
  9450. const isEnd = lobby.ended;
  9451.  
  9452. const buttonText = isEnd ? 'Leave' : 'Ready';
  9453.  
  9454. const resultOverlay = document.createElement('div');
  9455. resultOverlay.classList.add('mod_overlay', 'black_overlay');
  9456. document.body.appendChild(resultOverlay);
  9457.  
  9458. const fullResult = document.createElement('div'); // overlay for round stats
  9459. fullResult.classList.add('mod_overlay');
  9460. fullResult.style.display = 'none';
  9461. fullResult.style.minWidth = '530px';
  9462. fullResult.setAttribute('id', 'round-results');
  9463. fullResult.innerHTML = `
  9464. <div class="tournaments-wrapper f-column g-5">
  9465. <span class="text-center" style="font-size: 24px; font-weight: 600;">${
  9466. isEnd
  9467. ? `END OF ${lobby.name}`
  9468. : `Round ${lobby.currentRound}/${lobby.rounds}`
  9469. }</span>
  9470. <div class="centerXY" style="gap: 20px; height: 140px; margin-top: 16px;">
  9471. ${this.createStats(lobby)}
  9472. </div>
  9473. <div class="justify-sb w-100">
  9474. <span>Powered by SigMod</span>
  9475. <div class="centerXY g-10">
  9476. ${!isEnd ? `<span id="round-ready">Ready (0/${lobby.totalUsers})</span>` : ''}
  9477. <button type="button" class="btn btn-success f-big" id="tourney-button-action">${buttonText}</button>
  9478. </div>
  9479. </div>
  9480. </div>
  9481. `;
  9482. document.body.appendChild(fullResult);
  9483.  
  9484. const button = byId('tourney-button-action');
  9485. let clickedReady = false;
  9486. let checkInterval = null;
  9487.  
  9488. const updateButtonState = () => {
  9489. if (clickedReady) {
  9490. clearInterval(checkInterval);
  9491. return;
  9492. }
  9493. button.disabled = !window.gameSettings?.ws;
  9494. };
  9495.  
  9496. button.addEventListener('click', () => {
  9497. button.disabled = true;
  9498. if (!isEnd) {
  9499. clickedReady = true;
  9500. client.send({ type: 'ready' });
  9501. } else {
  9502. location.href = '/';
  9503. }
  9504. });
  9505.  
  9506. checkInterval = setInterval(updateButtonState, 100);
  9507.  
  9508. await wait(1000);
  9509.  
  9510. resultOverlay.innerHTML = `
  9511. <span class="tournament-text-${result}">YOU ${result.toUpperCase()}!</span>
  9512. `;
  9513.  
  9514. await wait(500);
  9515. fullResult.style.display = 'flex';
  9516.  
  9517. await wait(2000);
  9518.  
  9519. resultOverlay.style.opacity = '0';
  9520.  
  9521. await wait(300);
  9522. resultOverlay.remove();
  9523. },
  9524.  
  9525. createStats(lobby) {
  9526. if (lobby.mode === 'lastOneStanding') {
  9527. const team =
  9528. lobby.participants.blue.length > 0 ? 'blue' : 'red';
  9529. const winner = lobby.participants[team].find((socket) =>
  9530. lobby.roundsData[lobby.currentRound - 1].winners.includes(
  9531. socket.user.email
  9532. )
  9533. );
  9534. if (!winner) return `<span>Unkown winner.</span>`;
  9535.  
  9536. const { user } = winner;
  9537. return `
  9538. <div class="f-column g-5">
  9539. <div class="flex g-10" style="justify-content: center;">
  9540. <div class="teamCard" data-user-id="${user._id}" style="flex: 1;">
  9541. <img src="${user.imageURL}" class="tournament-profile" />
  9542. <span>${winner.nick || user.givenName}</span>
  9543. </div>
  9544. </div>
  9545. </div>
  9546. `;
  9547. }
  9548.  
  9549. const { blue: blueParticipants, red: redParticipants } =
  9550. lobby.participants;
  9551. const winners = new Set(
  9552. lobby.roundsData[lobby.currentRound - 1].winners
  9553. );
  9554. const [bluePoints, redPoints] = lobby.modeData.state
  9555. .split(':')
  9556. .map(Number);
  9557.  
  9558. const blueScores = new Map(
  9559. lobby.modeData.blue.map(({ email, score }) => [email, score])
  9560. );
  9561. const redScores = new Map(
  9562. lobby.modeData.red.map(({ email, score }) => [email, score])
  9563. );
  9564.  
  9565. const calculateTeamScore = (participants, scores) =>
  9566. participants.reduce(
  9567. (total, { user }) => total + (scores.get(user.email) || 0),
  9568. 0
  9569. );
  9570.  
  9571. const blueScore = calculateTeamScore(blueParticipants, blueScores);
  9572. const redScore = calculateTeamScore(redParticipants, redScores);
  9573.  
  9574. const isBlueWinning = blueScore > redScore;
  9575. const winningTeam = isBlueWinning ? 'blue' : 'red';
  9576. const losingTeam = isBlueWinning ? 'red' : 'blue';
  9577.  
  9578. const winningScore = isBlueWinning ? blueScore : redScore;
  9579. const losingScore = isBlueWinning ? redScore : blueScore;
  9580. const winningPoints = isBlueWinning ? bluePoints : redPoints;
  9581. const losingPoints = isBlueWinning ? redPoints : bluePoints;
  9582.  
  9583. const generateHTML = (participants) =>
  9584. participants
  9585. .map(
  9586. ({ user }) => `
  9587. <div class="teamCard" data-user-id="${user._id}" style="flex: 1;">
  9588. <img src="${user.imageURL}" class="tournament-profile" />
  9589. <span>${user.givenName}</span>
  9590. </div>
  9591. `
  9592. )
  9593. .join('');
  9594.  
  9595. const winnersForTeam = (teamParticipants) =>
  9596. teamParticipants.filter(({ user }) => winners.has(user.email));
  9597.  
  9598. const losersForTeam = (teamParticipants) =>
  9599. teamParticipants.filter(({ user }) => !winners.has(user.email));
  9600.  
  9601. const winnerHTML = generateHTML(
  9602. winnersForTeam(
  9603. isBlueWinning ? blueParticipants : redParticipants
  9604. )
  9605. );
  9606. const loserHTML = generateHTML(
  9607. losersForTeam(
  9608. isBlueWinning ? redParticipants : blueParticipants
  9609. )
  9610. );
  9611.  
  9612. return `
  9613. <div class="f-column g-5">
  9614. <div class="flex g-10" style="justify-content: center;">
  9615. ${winnerHTML}
  9616. </div>
  9617. <span class="text-center" style="font-size: 20px; font-weight: 400;">Score: ${winningScore}</span>
  9618. <span class="text-center" style="font-size: 26px; font-weight: 600;">${
  9619. winningPoints || 0
  9620. }</span>
  9621. </div>
  9622. <div class="f-column" style="height: 100%; position: relative">
  9623. <svg style="margin: auto;" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="60"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <rect x="142.853" y="486.511" style="fill:#56361D;" width="225.654" height="24.763"></rect> <path style="fill:#CCA400;" d="M223.069,256.172v50.773l0,0c8.126,0,14.712,6.587,14.712,14.712v96.74h36.49v-96.74 c0-8.126,6.587-14.712,14.712-14.712l0,0v-50.773H223.069z"></path> <rect x="223.064" y="251.211" style="opacity:0.16;fill:#664400;enable-background:new ;" width="65.919" height="40.689"></rect> <path style="fill:#EEBF00;" d="M274.378,271.341h-36.756c-50.613,0-91.644-41.03-91.644-91.644V0h220.043v179.697 C366.022,230.311,324.991,271.341,274.378,271.341z"></path> <g> <path style="fill:#664400;" d="M334.827,463.284H177.483V430.71c0-6.801,5.513-12.314,12.314-12.314h132.715 c6.801,0,12.314,5.513,12.314,12.314v32.574H334.827z"></path> <rect x="142.853" y="452.842" style="fill:#664400;" width="225.779" height="58.726"></rect> </g> <g> <path style="fill:#56361D;" d="M310.42,430.732l0.109,22.353l24.403-0.046l-0.109-22.307c-0.013-6.801-5.536-12.305-12.338-12.291 l-23.489,0.044C305.369,418.942,310.408,424.239,310.42,430.732z"></path> <polygon style="fill:#56361D;" points="368.616,452.85 344.213,452.896 344.324,511.573 142.951,511.954 142.951,512 368.727,511.573 "></polygon> </g> <g> <path style="fill:#EEBF00;" d="M99.268,40.707c-35.955,0-65.102,29.147-65.102,65.102s29.147,65.102,65.102,65.102h46.71V40.707 H99.268z M120.57,137.625H97.327c-17.89,0-32.393-14.502-32.393-32.393S79.437,72.84,97.327,72.84h23.242v64.785H120.57z"></path> <path style="fill:#EEBF00;" d="M412.732,40.707h-46.71v130.203h46.71c35.955,0,65.102-29.147,65.102-65.102 S448.687,40.707,412.732,40.707z M414.672,138.778H391.43V73.993h23.242c17.89,0,32.393,14.502,32.393,32.393 S432.562,138.778,414.672,138.778z"></path> </g> <rect x="145.974" y="75.284" style="fill:#CCA400;" width="219.828" height="77.612"></rect> <path style="fill:#FFEB99;" d="M189.004,184.953c-4.324,0-7.83-3.506-7.83-7.83V27.75c0-4.324,3.506-7.83,7.83-7.83 s7.83,3.506,7.83,7.83v149.373C196.835,181.447,193.329,184.953,189.004,184.953z"></path> <g> <rect x="366.022" y="40.707" style="opacity:0.16;fill:#664400;enable-background:new ;" width="14.996" height="129.113"></rect> <rect x="130.982" y="40.667" style="opacity:0.16;fill:#664400;enable-background:new ;" width="14.996" height="129.113"></rect> <path style="opacity:0.31;fill:#664400;enable-background:new ;" d="M335.941,0v157.465c0,50.613-41.03,91.644-91.644,91.644 h-36.756c-13.653,0-26.606-2.99-38.246-8.344c16.782,18.763,41.172,30.576,68.326,30.576h36.756 c50.613,0,91.644-41.03,91.644-91.644V0H335.941z"></path> </g> <rect x="177.483" y="439.03" style="fill:#56361D;" width="136.025" height="14.046"></rect> </g></svg>
  9624. <span style="text-align: center; font-size: 32px; font-weight: 600; position: absolute; bottom: -10px; left: 50%; transform: translateX(-50%)">&#8211;</span>
  9625. </div>
  9626. <div class="f-column g-5">
  9627. <div class="flex g-10" style="justify-content: center;">
  9628. ${loserHTML}
  9629. </div>
  9630. <span class="text-center" style="font-size: 20px; font-weight: 400;">Score: ${losingScore}</span>
  9631. <span class="text-center" style="font-size: 26px; font-weight: 600;">${
  9632. losingPoints || 0
  9633. }</span>
  9634. </div>
  9635. `;
  9636. },
  9637.  
  9638. modAlert(text, type) {
  9639. const overlay = document.querySelector('#modAlert_overlay');
  9640. const alertWrapper = document.createElement('div');
  9641. alertWrapper.classList.add('infoAlert');
  9642. if (type == 'success') {
  9643. alertWrapper.classList.add('modAlert-success');
  9644. } else if (type == 'danger') {
  9645. alertWrapper.classList.add('modAlert-danger');
  9646. } else if (type == 'default') {
  9647. alertWrapper.classList.add('modAlert-default');
  9648. }
  9649.  
  9650. alertWrapper.innerHTML = `
  9651. <span>${text}</span>
  9652. <div class="modAlert-loader"></div>
  9653. `;
  9654.  
  9655. overlay.append(alertWrapper);
  9656.  
  9657. setTimeout(() => {
  9658. alertWrapper.remove();
  9659. }, 2000);
  9660. },
  9661.  
  9662. createSignInWrapper(isLogin) {
  9663. let that = this;
  9664. const overlay = document.createElement('div');
  9665. overlay.classList.add('signIn-overlay');
  9666.  
  9667. const headerText = isLogin ? 'Login' : 'Create an account';
  9668. const btnText = isLogin ? 'Login' : 'Create account';
  9669. const btnId = isLogin ? 'loginButton' : 'registerButton';
  9670. const confPass = isLogin
  9671. ? ''
  9672. : '<input class="form-control" id="mod_pass_conf" type="password" placeholder="Confirm password" />';
  9673.  
  9674. overlay.innerHTML = `
  9675. <div class="signIn-wrapper">
  9676. <div class="signIn-header">
  9677. <span>${headerText}</span>
  9678. <div class="centerXY" style="width: 32px; height: 32px;">
  9679. <button class="modButton-black" id="closeSignIn">
  9680. <svg width="18" height="20" viewBox="0 0 16 16" fill="#ffffff" xmlns="http://www.w3.org/2000/svg">
  9681. <path d="M1.6001 14.4L14.4001 1.59998M14.4001 14.4L1.6001 1.59998" stroke="#fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path>
  9682. </svg>
  9683. </button>
  9684. </div>
  9685. </div>
  9686. <div class="signIn-body">
  9687. <input class="form-control" id="mod_username" type="text" placeholder="Username" />
  9688. <input class="form-control" id="mod_pass" type="password" placeholder="Password" />
  9689. ${confPass}
  9690. <div id="errMessages" style="display: none;"></div>
  9691. <span>or continue with...</span>
  9692. <button class="dclinks" style="border: none;" id="discord_login">
  9693. <svg width="25" height="24" viewBox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg">
  9694. <path d="M19.4566 5.35132C21.7154 8.83814 22.8309 12.7712 22.4139 17.299C22.4121 17.3182 22.4026 17.3358 22.3876 17.3473C20.6771 18.666 19.0199 19.4663 17.3859 19.9971C17.3732 20.0011 17.3596 20.0009 17.347 19.9964C17.3344 19.992 17.3234 19.9835 17.3156 19.9721C16.9382 19.4207 16.5952 18.8393 16.2947 18.2287C16.2774 18.1928 16.2932 18.1495 16.3287 18.1353C16.8734 17.9198 17.3914 17.6615 17.8896 17.3557C17.9289 17.3316 17.9314 17.2725 17.8951 17.2442C17.7894 17.1617 17.6846 17.0751 17.5844 16.9885C17.5656 16.9725 17.5404 16.9693 17.5191 16.9801C14.2844 18.5484 10.7409 18.5484 7.46792 16.9801C7.44667 16.9701 7.42142 16.9735 7.40317 16.9893C7.30317 17.0759 7.19817 17.1617 7.09342 17.2442C7.05717 17.2725 7.06017 17.3316 7.09967 17.3557C7.59792 17.6557 8.11592 17.9198 8.65991 18.1363C8.69517 18.1505 8.71192 18.1928 8.69442 18.2287C8.40042 18.8401 8.05742 19.4215 7.67292 19.9729C7.65617 19.9952 7.62867 20.0055 7.60267 19.9971C5.97642 19.4663 4.31917 18.666 2.60868 17.3473C2.59443 17.3358 2.58418 17.3174 2.58268 17.2982C2.23418 13.3817 2.94442 9.41613 5.53717 5.35053C5.54342 5.33977 5.55292 5.33137 5.56392 5.32638C6.83967 4.71165 8.20642 4.25939 9.63491 4.00111C9.66091 3.99691 9.68691 4.00951 9.70041 4.03365C9.87691 4.36176 10.0787 4.78252 10.2152 5.12637C11.7209 4.88489 13.2502 4.88489 14.7874 5.12637C14.9239 4.78987 15.1187 4.36176 15.2944 4.03365C15.3007 4.02167 15.3104 4.01208 15.3221 4.00623C15.3339 4.00039 15.3471 3.99859 15.3599 4.00111C16.7892 4.26018 18.1559 4.71244 19.4306 5.32638C19.4419 5.33137 19.4511 5.33977 19.4566 5.35132ZM10.9807 12.798C10.9964 11.6401 10.1924 10.6821 9.18316 10.6821C8.18217 10.6821 7.38592 11.6317 7.38592 12.798C7.38592 13.9639 8.19792 14.9136 9.18316 14.9136C10.1844 14.9136 10.9807 13.9639 10.9807 12.798ZM17.6261 12.798C17.6419 11.6401 16.8379 10.6821 15.8289 10.6821C14.8277 10.6821 14.0314 11.6317 14.0314 12.798C14.0314 13.9639 14.8434 14.9136 15.8289 14.9136C16.8379 14.9136 17.6261 13.9639 17.6261 12.798Z" fill="white"></path>
  9695. </svg>
  9696. Discord
  9697. </button>
  9698. <div id="sigmod-captcha"></div>
  9699. <div class="w-100 centerXY">
  9700. <button class="modButton-black" id="${btnId}" style="margin-top: 26px; width: 200px;">${btnText}</button>
  9701. </div>
  9702. <p class="mt-auto">Your data is stored safely and securely.</p>
  9703. </div>
  9704. </div>
  9705. `;
  9706. document.body.append(overlay);
  9707.  
  9708. const close = byId('closeSignIn');
  9709. close.addEventListener('click', hide);
  9710.  
  9711. function hide() {
  9712. overlay.style.opacity = '0';
  9713. setTimeout(() => {
  9714. overlay.remove();
  9715. }, 300);
  9716. }
  9717.  
  9718. overlay.addEventListener('mousedown', (e) => {
  9719. if (e.target == overlay) hide();
  9720. });
  9721.  
  9722. setTimeout(() => {
  9723. overlay.style.opacity = '1';
  9724. });
  9725.  
  9726. // DISCORD LOGIN
  9727.  
  9728. const discord_login = byId('discord_login');
  9729.  
  9730. const w = 600;
  9731. const h = 800;
  9732. const left = (window.innerWidth - w) / 2;
  9733. const top = (window.innerHeight - h) / 2;
  9734.  
  9735. function receiveMessage(event) {
  9736. if (event.data.type === 'profileData') {
  9737. const data = event.data.data;
  9738. successHandler(data);
  9739. }
  9740. }
  9741.  
  9742. discord_login.addEventListener('click', () => {
  9743. const popupWindow = window.open(
  9744. this.routes.discord.auth,
  9745. '_blank',
  9746. `width=${w}, height=${h}, left=${left}, top=${top}`
  9747. );
  9748.  
  9749. const interval = setInterval(() => {
  9750. if (popupWindow.closed) {
  9751. clearInterval(interval);
  9752. setTimeout(() => {
  9753. location.reload();
  9754. }, 1500);
  9755. }
  9756. }, 1000);
  9757. });
  9758.  
  9759. // LOGIN / REGISTER:
  9760. const button = byId(btnId);
  9761.  
  9762. button.addEventListener('click', async () => {
  9763. const path = isLogin ? 'login' : 'register';
  9764. const username = byId('mod_username').value;
  9765. const password = byId('mod_pass').value;
  9766. const confirmedPassword = confPass
  9767. ? byId('mod_pass_conf').value
  9768. : null;
  9769.  
  9770. if (!username || !password) return;
  9771.  
  9772. button.hide();
  9773.  
  9774. const accountData = {
  9775. username,
  9776. password,
  9777. ...(confirmedPassword && { confirmedPassword }),
  9778. user: window.gameSettings.user,
  9779. };
  9780.  
  9781. try {
  9782. const response = await fetch(this.appRoutes.signIn(path), {
  9783. method: 'POST',
  9784. credentials: 'include',
  9785. headers: { 'Content-Type': 'application/json' },
  9786. body: JSON.stringify(accountData),
  9787. });
  9788.  
  9789. const data = await response.json();
  9790.  
  9791. if (data.success) {
  9792. successHandler(data);
  9793. that.profile = data.user;
  9794. } else {
  9795. errorHandler(data.errors);
  9796. }
  9797. } catch (error) {
  9798. console.error(error);
  9799. } finally {
  9800. button.show();
  9801. }
  9802. });
  9803.  
  9804. function successHandler(data) {
  9805. that.friends_settings = data.settings;
  9806. that.profile = data.user;
  9807.  
  9808. hide();
  9809. that.setFriendsMenu();
  9810. modSettings.modAccount.authorized = true;
  9811. updateStorage();
  9812. }
  9813.  
  9814. function errorHandler(errors) {
  9815. errors.forEach((error) => {
  9816. const errMessages = byId('errMessages');
  9817. if (!errMessages) return;
  9818.  
  9819. if (errMessages.style.display == 'none')
  9820. errMessages.style.display = 'flex';
  9821.  
  9822. let input = null;
  9823. switch (error.fieldName) {
  9824. case 'Username':
  9825. input = 'mod_username';
  9826. break;
  9827. case 'Password':
  9828. input = 'mod_pass';
  9829. break;
  9830. }
  9831.  
  9832. errMessages.innerHTML += `
  9833. <span>${error.message}</span>
  9834. `;
  9835.  
  9836. if (input && byId(input)) {
  9837. const el = byId(input);
  9838. el.classList.add('error-border');
  9839.  
  9840. el.addEventListener('input', () => {
  9841. el.classList.remove('error-border');
  9842. errMessages.innerHTML = '';
  9843. });
  9844. }
  9845. });
  9846. }
  9847. },
  9848.  
  9849. async auth(sid) {
  9850. const res = await fetch(`${this.appRoutes.auth}/?sid=${sid}`, {
  9851. credentials: 'include',
  9852. });
  9853.  
  9854. res.json()
  9855. .then((data) => {
  9856. if (data.success) {
  9857. this.setFriendsMenu();
  9858. this.profile = data.user;
  9859. this.setProfile(data.user);
  9860. this.friends_settings = data.settings;
  9861. } else {
  9862. console.error('Not a valid account.');
  9863. }
  9864. })
  9865. .catch((error) => {
  9866. console.error(error);
  9867. });
  9868. },
  9869.  
  9870. setFriendsMenu() {
  9871. const that = this;
  9872. const friendsMenu = byId('mod_friends');
  9873. friendsMenu.innerHTML = ''; // clear content
  9874.  
  9875. // add new content
  9876. friendsMenu.innerHTML = `
  9877. <div class="friends_header">
  9878. <button class="modButton-black" id="friends_btn">Friends</button>
  9879. <button class="modButton-black" id="allusers_btn">All users</button>
  9880. <button class="modButton-black" id="requests_btn">Requests</button>
  9881. <button class="modButton-black" id="friends_settings_btn" style="width: 80px;">
  9882. <img src="https://czrsd.com/static/sigmod/icons/settings.svg" width="22" />
  9883. </button>
  9884. </div>
  9885. <div class="friends_body scroll"></div>
  9886. `;
  9887.  
  9888. const elements = [
  9889. '#friends_btn',
  9890. '#allusers_btn',
  9891. '#requests_btn',
  9892. '#friends_settings_btn',
  9893. ];
  9894.  
  9895. elements.forEach((el) => {
  9896. const button = document.querySelector(el);
  9897. button.addEventListener('click', () => {
  9898. elements.forEach((btn) =>
  9899. document
  9900. .querySelector(btn)
  9901. .classList.remove('mod_selected')
  9902. );
  9903. button.classList.add('mod_selected');
  9904. switch (button.id) {
  9905. case 'friends_btn':
  9906. that.openFriendsTab();
  9907. break;
  9908. case 'allusers_btn':
  9909. that.openAllUsers();
  9910. break;
  9911. case 'requests_btn':
  9912. that.openRequests();
  9913. break;
  9914. case 'friends_settings_btn':
  9915. that.openFriendSettings();
  9916. break;
  9917. default:
  9918. console.error('Unknown button clicked');
  9919. }
  9920. });
  9921. });
  9922.  
  9923. byId('friends_btn').click(); // open friends first
  9924. },
  9925.  
  9926. async showProfileHandler(event) {
  9927. const userId =
  9928. event.currentTarget.getAttribute('data-user-profile');
  9929. const req = await fetch(this.appRoutes.profile(userId), {
  9930. credentials: 'include',
  9931. }).then((res) => res.json());
  9932.  
  9933. if (req.success) {
  9934. const user = req.user;
  9935. let badges =
  9936. user.badges && user.badges.length > 0
  9937. ? user.badges
  9938. .map(
  9939. (badge) =>
  9940. `<span class="mod_badge">${badge}</span>`
  9941. )
  9942. .join('')
  9943. : '<span>User has no badges.</span>';
  9944. let icon = null;
  9945.  
  9946. const overlay = document.createElement('div');
  9947. overlay.classList.add('mod_overlay');
  9948. overlay.style.opacity = '0';
  9949. overlay.innerHTML = `
  9950. <div class="signIn-wrapper">
  9951. <div class="signIn-header">
  9952. <span>Profile of ${user.username}</span>
  9953. <div class="centerXY" style="width: 32px; height: 32px;">
  9954. <button class="modButton-black" id="closeProfileEditor">
  9955. <svg width="18" height="20" viewBox="0 0 16 16" fill="#ffffff" xmlns="http://www.w3.org/2000/svg">
  9956. <path d="M1.6001 14.4L14.4001 1.59998M14.4001 14.4L1.6001 1.59998" stroke="#fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path>
  9957. </svg>
  9958. </button>
  9959. </div>
  9960. </div>
  9961. <div class="signIn-body" style="padding-bottom: 40px;">
  9962. <div class="friends_row">
  9963. <div class="centerY g-5">
  9964. <div class="profile-img">
  9965. <img src="${user.imageURL}" alt="${
  9966. user.username
  9967. }">
  9968. <span class="status_icon ${
  9969. user.online
  9970. ? 'online_icon'
  9971. : 'offline_icon'
  9972. }"></span>
  9973. </div>
  9974. <div class="f-big">${user.username}</div>
  9975. </div>
  9976. <div class="centerY g-10">
  9977. <div class="${user.role}_role">${
  9978. user.role
  9979. }</div>
  9980. </div>
  9981. </div>
  9982. <div class="f-column g-5 w-100">
  9983. <strong>Bio:</strong>
  9984. <p>${user.bio || 'User has no bio.'}</p>
  9985. <strong>Badges:</strong>
  9986. <div class="mod_badges">
  9987. ${badges}
  9988. </div>
  9989. ${
  9990. user.lastOnline
  9991. ? `<strong>Last online:</strong><span>${prettyTime.am_pm(
  9992. user.lastOnline
  9993. )} (${prettyTime.time_ago(
  9994. user.lastOnline,
  9995. true
  9996. )})</span>`
  9997. : ''
  9998. }
  9999. </div>
  10000. </div>
  10001. </div>
  10002. `;
  10003. document.body.append(overlay);
  10004.  
  10005. function hide() {
  10006. overlay.style.opacity = '0';
  10007. setTimeout(() => {
  10008. overlay.remove();
  10009. }, 300);
  10010. }
  10011.  
  10012. overlay.addEventListener('click', (e) => {
  10013. if (e.target == overlay) hide();
  10014. });
  10015.  
  10016. setTimeout(() => {
  10017. overlay.style.opacity = '1';
  10018. });
  10019.  
  10020. byId('closeProfileEditor').addEventListener('click', hide);
  10021. }
  10022. },
  10023.  
  10024. async openFriendsTab() {
  10025. let that = this;
  10026. const friends_body = document.querySelector('.friends_body');
  10027. if (friends_body.classList.contains('allusers'))
  10028. friends_body.classList.remove('allusers');
  10029. friends_body.innerHTML = '';
  10030.  
  10031. const res = await fetch(this.appRoutes.friends, {
  10032. credentials: 'include',
  10033. });
  10034.  
  10035. res.json()
  10036. .then((data) => {
  10037. if (!data.success) return;
  10038. if (data.friends.length !== 0) {
  10039. const newUsersHTML = data.friends
  10040. .map(
  10041. (user) => `
  10042. <div class="friends_row user-profile-wrapper" data-user-profile="${
  10043. user._id
  10044. }">
  10045. <div class="centerY g-5">
  10046. <div class="profile-img">
  10047. <img src="${user.imageURL}" alt="${
  10048. user.username
  10049. }" onerror="this.onerror=null; this.src='https://czrsd.com/static/sigmod/SigMod25-rounded.png';">
  10050. <span class="status_icon ${
  10051. user.online ? 'online_icon' : 'offline_icon'
  10052. }"></span>
  10053. </div>
  10054. ${
  10055. user.nick
  10056. ? `
  10057. <div class="f-column centerX">
  10058. <div class="f-big">${user.username}</div>
  10059. <span style="color: #A2A2A2" title="Nickname">${user.nick}</span>
  10060. </div>
  10061. `
  10062. : `
  10063. <div class="f-big">${user.username}</div>
  10064. `
  10065. }
  10066. </div>
  10067. <div class="centerY g-10">
  10068. ${
  10069. user.server
  10070. ? `
  10071. <span>${user.server}</span>
  10072. <div class="vr2"></div>
  10073. `
  10074. : ''
  10075. }
  10076. ${
  10077. user.tag
  10078. ? `
  10079. <span>Tag: ${user.tag}</span>
  10080. <div class="vr2"></div>
  10081. `
  10082. : ''
  10083. }
  10084. <div class="${user.role}_role">${user.role}</div>
  10085. <div class="vr2"></div>
  10086. <button class="modButton centerXY" id="remove-${
  10087. user._id
  10088. }" style="padding: 7px;">
  10089. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512" width="16"><path fill="#ffffff" d="M96 128a128 128 0 1 1 256 0A128 128 0 1 1 96 128zM0 482.3C0 383.8 79.8 304 178.3 304h91.4C368.2 304 448 383.8 448 482.3c0 16.4-13.3 29.7-29.7 29.7H29.7C13.3 512 0 498.7 0 482.3zM472 200H616c13.3 0 24 10.7 24 24s-10.7 24-24 24H472c-13.3 0-24-10.7-24-24s10.7-24 24-24z"/></svg>
  10090. </button>
  10091. <div class="vr2"></div>
  10092. <button class="modButton centerXY" id="chat-${
  10093. user._id
  10094. }" style="padding: 7px;">
  10095. <svg fill="#ffffff" width="16" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 458 458" stroke="#ffffff"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <g> <g> <path d="M428,41.534H30c-16.569,0-30,13.431-30,30v252c0,16.568,13.432,30,30,30h132.1l43.942,52.243 c5.7,6.777,14.103,10.69,22.959,10.69c8.856,0,17.258-3.912,22.959-10.69l43.942-52.243H428c16.568,0,30-13.432,30-30v-252 C458,54.965,444.568,41.534,428,41.534z M323.916,281.534H82.854c-8.284,0-15-6.716-15-15s6.716-15,15-15h241.062 c8.284,0,15,6.716,15,15S332.2,281.534,323.916,281.534z M67.854,198.755c0-8.284,6.716-15,15-15h185.103c8.284,0,15,6.716,15,15 s-6.716,15-15,15H82.854C74.57,213.755,67.854,207.039,67.854,198.755z M375.146,145.974H82.854c-8.284,0-15-6.716-15-15 s6.716-15,15-15h292.291c8.284,0,15,6.716,15,15C390.146,139.258,383.43,145.974,375.146,145.974z"></path> </g> </g> </g></svg>
  10096. </button>
  10097. </div>
  10098. </div>
  10099. `
  10100. )
  10101. .join('');
  10102. friends_body.innerHTML = newUsersHTML;
  10103.  
  10104. const userProfiles = document.querySelectorAll(
  10105. '.user-profile-wrapper'
  10106. );
  10107.  
  10108. userProfiles.forEach((button) => {
  10109. if (
  10110. button.getAttribute('data-user-profile') ==
  10111. this.profile._id
  10112. )
  10113. return;
  10114. button.addEventListener('click', (e) => {
  10115. if (e.target == button) {
  10116. this.showProfileHandler(e);
  10117. }
  10118. });
  10119. });
  10120.  
  10121. data.friends.forEach((friend) => {
  10122. if (friend.nick) {
  10123. this.friend_names.add(friend.nick);
  10124. }
  10125. const remove = byId(`remove-${friend._id}`);
  10126. remove.addEventListener('click', async () => {
  10127. if (
  10128. confirm(
  10129. 'Are you sure you want to remove this friend?'
  10130. )
  10131. ) {
  10132. const res = await fetch(
  10133. this.appRoutes.removeAvatar,
  10134. {
  10135. method: 'POST',
  10136. headers: {
  10137. 'Content-Type':
  10138. 'application/json',
  10139. },
  10140. body: JSON.stringify({
  10141. type: 'remove-friend',
  10142. userId: friend._id,
  10143. }),
  10144. credentials: 'include',
  10145. }
  10146. ).then((res) => res.json());
  10147.  
  10148. if (res.success) {
  10149. that.openFriendsTab();
  10150. } else {
  10151. let message =
  10152. res.message ||
  10153. 'Something went wrong. Please try again later.';
  10154. that.modAlert(message, 'danger');
  10155. }
  10156. }
  10157. });
  10158.  
  10159. const chat = byId(`chat-${friend._id}`);
  10160. chat.addEventListener('click', () => {
  10161. this.openChat(friend._id);
  10162. });
  10163. });
  10164. } else {
  10165. friends_body.innerHTML = `
  10166. <span>You have no friends yet :(</span>
  10167. <span>Go to the <strong>All users</strong> tab to find new friends.</span>
  10168. `;
  10169. }
  10170. })
  10171. .catch((error) => {
  10172. console.error(error);
  10173. });
  10174. },
  10175.  
  10176. async openChat(id) {
  10177. const res = await fetch(this.appRoutes.chatHistory(id), {
  10178. credentials: 'include',
  10179. });
  10180. const { history, target, success } = await res.json();
  10181.  
  10182. if (!success) {
  10183. this.modAlert('Something went wrong...', 'danger');
  10184. return;
  10185. }
  10186.  
  10187. const body = document.querySelector('.mod_menu_content');
  10188.  
  10189. const chatDiv = document.createElement('div');
  10190. chatDiv.classList.add('friends-chat-wrapper');
  10191. chatDiv.id = id;
  10192. setTimeout(() => {
  10193. chatDiv.style.opacity = '1';
  10194. });
  10195.  
  10196. const messagesHTML = history
  10197. .map(
  10198. (message) => `
  10199. <div class="friends-message ${
  10200. message.sender_id === this.profile._id
  10201. ? 'message-right'
  10202. : ''
  10203. }">
  10204. <span>${message.content}</span>
  10205. <span class="message-date">${prettyTime.am_pm(
  10206. message.timestamp
  10207. )}</span>
  10208. </div>
  10209. `
  10210. )
  10211. .join('');
  10212.  
  10213. chatDiv.innerHTML = `
  10214. <div class="friends-chat-header">
  10215. <div class="centerXY g-5">
  10216. <div class="profile-img">
  10217. <img src="${target.imageURL}" alt="${
  10218. target.username
  10219. }">
  10220. <span class="status_icon ${
  10221. target.online ? 'online_icon' : 'offline_icon'
  10222. }"></span>
  10223. </div>
  10224. <span class="f-big">${target.username}</span>
  10225. </div>
  10226. <button class="modButton centerXY g-5" id="back-friends-chat">
  10227. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512" width="16"><path fill="#ffffff" d="M9.4 233.4c-12.5 12.5-12.5 32.8 0 45.3l160 160c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L109.2 288 416 288c17.7 0 32-14.3 32-32s-14.3-32-32-32l-306.7 0L214.6 118.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0l-160 160z"/></svg>
  10228. Back
  10229. </button>
  10230. </div>
  10231. <div class="friends-chat-body">
  10232. <div class="friends-chat-messages private-chat-content scroll">
  10233. ${
  10234. history.length > 0
  10235. ? messagesHTML
  10236. : "<center id='beginning-of-conversation'>This is the beginning of your conversation...</center>"
  10237. }
  10238. </div>
  10239. <div class="messenger-wrapper">
  10240. <div class="container">
  10241. <input type="text" class="form-control" placeholder="Enter a message..." id="private-message-text" />
  10242. <button class="modButton-black" id="send-private-message">Send</button>
  10243. </div>
  10244. </div>
  10245. </div>
  10246. `;
  10247.  
  10248. body.appendChild(chatDiv);
  10249. const messagesContainer = chatDiv.querySelector(
  10250. '.private-chat-content'
  10251. );
  10252. messagesContainer.scrollTop = messagesContainer.scrollHeight;
  10253.  
  10254. const back = byId('back-friends-chat');
  10255. back.addEventListener('click', (e) => {
  10256. chatDiv.style.opacity = '0';
  10257. setTimeout(() => {
  10258. chatDiv.remove();
  10259. }, 300);
  10260. });
  10261.  
  10262. const text = byId('private-message-text');
  10263. const send = byId('send-private-message');
  10264.  
  10265. text.addEventListener('keydown', (e) => {
  10266. const key = e.key.toLowerCase();
  10267. if (key === 'enter') {
  10268. sendMessage(text.value, id);
  10269. text.value = '';
  10270. }
  10271. });
  10272.  
  10273. send.addEventListener('click', () => {
  10274. sendMessage(text.value, id);
  10275. text.value = '';
  10276. });
  10277.  
  10278. function sendMessage(val, target) {
  10279. if (!val || val.length > 200) return;
  10280. client?.send({
  10281. type: 'private-message',
  10282. content: {
  10283. text: val,
  10284. target,
  10285. },
  10286. });
  10287. }
  10288. },
  10289.  
  10290. updatePrivateChat(data) {
  10291. const { sender_id, target_id, message, timestamp } = data;
  10292.  
  10293. let chatDiv = byId(target_id) || byId(sender_id);
  10294. if (!chatDiv) {
  10295. console.error(
  10296. 'Could not find chat div for either sender or target'
  10297. );
  10298. return;
  10299. }
  10300.  
  10301. const bocElement = document.querySelector(
  10302. '#beginning-of-conversation'
  10303. );
  10304. if (bocElement) bocElement.remove();
  10305.  
  10306. const messages = chatDiv.querySelector('.friends-chat-messages');
  10307. messages.innerHTML += `
  10308. <div class="friends-message ${
  10309. sender_id === this.profile._id ? 'message-right' : ''
  10310. }">
  10311. <span>${message}</span>
  10312. <span class="message-date">${prettyTime.am_pm(
  10313. timestamp
  10314. )}</span>
  10315. </div>
  10316. `;
  10317. messages.scrollTop = messages.scrollHeight;
  10318. },
  10319.  
  10320. async searchUser(user) {
  10321. if (!user) {
  10322. this.openAllUsers();
  10323. return;
  10324. }
  10325. const response = await fetch(
  10326. `${this.appRoutes.search}/?q=${user}`,
  10327. {
  10328. credentials: 'include',
  10329. }
  10330. ).then((res) => res.json());
  10331. const usersDiv = document;
  10332.  
  10333. const usersContainer = byId('users-container');
  10334. usersContainer.innerHTML = '';
  10335. if (!response.success) {
  10336. usersContainer.innerHTML = `
  10337. <span>Couldn't find ${user}...</span>
  10338. `;
  10339. return;
  10340. }
  10341.  
  10342. const handleAddButtonClick = (event) => {
  10343. const userId = event.currentTarget.getAttribute('data-user-id');
  10344. const add = event.currentTarget;
  10345. fetch(this.appRoutes.request, {
  10346. method: 'POST',
  10347. headers: {
  10348. 'Content-Type': 'application/json',
  10349. },
  10350. body: JSON.stringify({ req_id: userId }),
  10351. credentials: 'include',
  10352. })
  10353. .then((res) => res.json())
  10354. .then((req) => {
  10355. const type = req.success ? 'success' : 'danger';
  10356. this.modAlert(req.message, type);
  10357.  
  10358. if (req.success) {
  10359. add.disabled = true;
  10360. add.innerHTML = `
  10361. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512" width="16"><path fill="#ffffff" d="M32 0C14.3 0 0 14.3 0 32S14.3 64 32 64V75c0 42.4 16.9 83.1 46.9 113.1L146.7 256 78.9 323.9C48.9 353.9 32 394.6 32 437v11c-17.7 0-32 14.3-32 32s14.3 32 32 32H64 320h32c17.7 0 32-14.3 32-32s-14.3-32-32-32V437c0-42.4-16.9-83.1-46.9-113.1L237.3 256l67.9-67.9c30-30 46.9-70.7 46.9-113.1V64c17.7 0 32-14.3 32-32s-14.3-32-32-32H320 64 32zM288 437v11H96V437c0-25.5 10.1-49.9 28.1-67.9L192 301.3l67.9 67.9c18 18 28.1 42.4 28.1 67.9z"/></svg>
  10362. `;
  10363. }
  10364. });
  10365. };
  10366.  
  10367. response.users.forEach((user) => {
  10368. const userHTML = `
  10369. <div class="friends_row user-profile-wrapper" style="${
  10370. this.profile._id == user._id
  10371. ? `background: linear-gradient(45deg, #17172d, black)`
  10372. : ''
  10373. }" data-user-profile="${user._id}">
  10374. <div class="centerY g-5">
  10375. <div class="profile-img">
  10376. <img src="${user.imageURL}" alt="${
  10377. user.username
  10378. }" onerror="this.onerror=null; this.src='https://czrsd.com/static/sigmod/SigMod25-rounded.png';">
  10379. <span class="status_icon ${
  10380. user.online ? 'online_icon' : 'offline_icon'
  10381. }"></span>
  10382. </div>
  10383. <div class="f-big">${
  10384. this.profile.username === user.username
  10385. ? `${user.username} (You)`
  10386. : user.username
  10387. }</div>
  10388. </div>
  10389. <div class="centerY g-10">
  10390. <div class="${user.role}_role">${user.role}</div>
  10391. ${
  10392. this.profile._id == user._id
  10393. ? ''
  10394. : `
  10395. <div class="vr2"></div>
  10396. <button class="modButton centerXY add-button" data-user-id="${user._id}" style="padding: 7px;">
  10397. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512" width="16"><path fill="#ffffff" d="M96 128a128 128 0 1 1 256 0A128 128 0 1 1 96 128zM0 482.3C0 383.8 79.8 304 178.3 304h91.4C368.2 304 448 383.8 448 482.3c0 16.4-13.3 29.7-29.7 29.7H29.7C13.3 512 0 498.7 0 482.3zM504 312V248H440c-13.3 0-24-10.7-24-24s10.7-24 24-24h64V136c0-13.3 10.7-24 24-24s24 10.7 24 24v64h64c13.3 0 24 10.7 24 24s-10.7 24-24 24H552v64c0 13.3-10.7 24-24 24s-24-10.7-24-24z"/></svg>
  10398. </button>
  10399. `
  10400. }
  10401. </div>
  10402. </div>
  10403. `;
  10404. usersContainer.insertAdjacentHTML('beforeend', userHTML);
  10405.  
  10406. if (user._id == this.profile._id) return;
  10407. const newUserProfile = usersContainer.querySelector(
  10408. `[data-user-profile="${user._id}"]`
  10409. );
  10410. newUserProfile.addEventListener('click', (e) => {
  10411. if (e.target == newUserProfile) {
  10412. this.showProfileHandler(e);
  10413. }
  10414. });
  10415.  
  10416. const addButton = newUserProfile.querySelector('.add-button');
  10417. if (!addButton) return;
  10418. addButton.addEventListener('click', handleAddButtonClick);
  10419. });
  10420. },
  10421.  
  10422. async openAllUsers() {
  10423. let offset = 0;
  10424. let maxReached = false;
  10425. let defaultAmount = 5; // min: 1; max: 100
  10426.  
  10427. const friends_body = document.querySelector('.friends_body');
  10428. friends_body.innerHTML = `
  10429. <input type="text" id="search-user" placeholder="Search user by username or id" class="form-control p-10" style="border: none" />
  10430. <div id="users-container"></div>
  10431. `;
  10432. const usersContainer = byId('users-container');
  10433. friends_body.classList.add('allusers');
  10434.  
  10435. // search user
  10436. const search = byId('search-user');
  10437. search.addEventListener(
  10438. 'input',
  10439. debounce(() => {
  10440. this.searchUser(search.value);
  10441. }, 500)
  10442. );
  10443.  
  10444. const handleAddButtonClick = (event) => {
  10445. const userId = event.currentTarget.getAttribute('data-user-id');
  10446. const add = event.currentTarget;
  10447. fetch(this.appRoutes.request, {
  10448. method: 'POST',
  10449. headers: {
  10450. 'Content-Type': 'application/json',
  10451. },
  10452. body: JSON.stringify({ req_id: userId }),
  10453. credentials: 'include',
  10454. })
  10455. .then((res) => res.json())
  10456. .then((req) => {
  10457. const type = req.success ? 'success' : 'danger';
  10458. this.modAlert(req.message, type);
  10459.  
  10460. if (req.success) {
  10461. add.disabled = true;
  10462. add.innerHTML = `
  10463. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512" width="16"><path fill="#ffffff" d="M32 0C14.3 0 0 14.3 0 32S14.3 64 32 64V75c0 42.4 16.9 83.1 46.9 113.1L146.7 256 78.9 323.9C48.9 353.9 32 394.6 32 437v11c-17.7 0-32 14.3-32 32s14.3 32 32 32H64 320h32c17.7 0 32-14.3 32-32s-14.3-32-32-32V437c0-42.4-16.9-83.1-46.9-113.1L237.3 256l67.9-67.9c30-30 46.9-70.7 46.9-113.1V64c17.7 0 32-14.3 32-32s-14.3-32-32-32H320 64 32zM288 437v11H96V437c0-25.5 10.1-49.9 28.1-67.9L192 301.3l67.9 67.9c18 18 28.1 42.4 28.1 67.9z"/></svg>
  10464. `;
  10465. }
  10466. });
  10467. };
  10468.  
  10469. const displayedUserIDs = new Set();
  10470.  
  10471. const fetchNewUsers = async () => {
  10472. const newUsersResponse = await fetch(this.appRoutes.users, {
  10473. method: 'POST',
  10474. headers: {
  10475. 'Content-Type': 'application/json',
  10476. },
  10477. body: JSON.stringify({ amount: defaultAmount, offset }),
  10478. credentials: 'include',
  10479. }).then((res) => res.json());
  10480.  
  10481. const newUsers = newUsersResponse.users;
  10482.  
  10483. if (newUsers.length === 0) {
  10484. maxReached = true;
  10485. return;
  10486. }
  10487. offset += defaultAmount;
  10488.  
  10489. newUsers.forEach((user) => {
  10490. if (!displayedUserIDs.has(user._id)) {
  10491. displayedUserIDs.add(user._id);
  10492.  
  10493. const newUserHTML = `
  10494. <div class="friends_row user-profile-wrapper" style="${
  10495. this.profile._id == user._id
  10496. ? `background: linear-gradient(45deg, #17172d, black)`
  10497. : ''
  10498. }" data-user-profile="${user._id}">
  10499. <div class="centerY g-5">
  10500. <div class="profile-img">
  10501. <img src="${user.imageURL}" alt="${
  10502. user.username
  10503. }" onerror="this.onerror=null; this.src='https://czrsd.com/static/sigmod/SigMod25-rounded.png';">
  10504. <span class="status_icon ${
  10505. user.online
  10506. ? 'online_icon'
  10507. : 'offline_icon'
  10508. }"></span>
  10509. </div>
  10510. <div class="f-big">${
  10511. this.profile.username === user.username
  10512. ? `${user.username} (You)`
  10513. : user.username
  10514. }</div>
  10515. </div>
  10516. <div class="centerY g-10">
  10517. <div class="${user.role}_role">${
  10518. user.role
  10519. }</div>
  10520. ${
  10521. this.profile._id == user._id
  10522. ? ''
  10523. : `
  10524. <div class="vr2"></div>
  10525. <button class="modButton centerXY add-button" data-user-id="${user._id}" style="padding: 7px;">
  10526. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512" width="16"><path fill="#ffffff" d="M96 128a128 128 0 1 1 256 0A128 128 0 1 1 96 128zM0 482.3C0 383.8 79.8 304 178.3 304h91.4C368.2 304 448 383.8 448 482.3c0 16.4-13.3 29.7-29.7 29.7H29.7C13.3 512 0 498.7 0 482.3zM504 312V248H440c-13.3 0-24-10.7-24-24s10.7-24 24-24h64V136c0-13.3 10.7-24 24-24s24 10.7 24 24v64h64c13.3 0 24 10.7 24 24s-10.7 24-24 24H552v64c0 13.3-10.7 24-24 24s-24-10.7-24-24z"/></svg>
  10527. </button>
  10528. `
  10529. }
  10530. </div>
  10531. </div>
  10532. `;
  10533.  
  10534. usersContainer.insertAdjacentHTML(
  10535. 'beforeend',
  10536. newUserHTML
  10537. );
  10538.  
  10539. const newUserProfile = usersContainer.querySelector(
  10540. `[data-user-profile="${user._id}"]`
  10541. );
  10542. newUserProfile.addEventListener('click', (e) => {
  10543. if (e.target == newUserProfile) {
  10544. this.showProfileHandler(e);
  10545. }
  10546. });
  10547.  
  10548. const addButton =
  10549. newUserProfile.querySelector('.add-button');
  10550. if (!addButton) return;
  10551. addButton.addEventListener(
  10552. 'click',
  10553. handleAddButtonClick
  10554. );
  10555. }
  10556. });
  10557. };
  10558.  
  10559. const scrollHandler = async () => {
  10560. if (maxReached) return;
  10561. if (
  10562. usersContainer.scrollTop + usersContainer.clientHeight >=
  10563. usersContainer.scrollHeight - 1
  10564. ) {
  10565. await fetchNewUsers();
  10566. }
  10567. };
  10568.  
  10569. // Initial fetch
  10570. await fetchNewUsers();
  10571.  
  10572. // remove existing scroll event listener if exists
  10573. usersContainer.removeEventListener('scroll', scrollHandler);
  10574.  
  10575. // add new scroll event listener
  10576. usersContainer.addEventListener('scroll', scrollHandler);
  10577. },
  10578.  
  10579. async openRequests() {
  10580. let that = this;
  10581. const friends_body = document.querySelector('.friends_body');
  10582. friends_body.innerHTML = '';
  10583. if (friends_body.classList.contains('allusers'))
  10584. friends_body.classList.remove('allusers');
  10585.  
  10586. const requests = await fetch(this.appRoutes.myRequests, {
  10587. credentials: 'include',
  10588. }).then((res) => res.json());
  10589.  
  10590. if (!requests.body) return;
  10591. if (requests.body.length > 0) {
  10592. const reqHtml = requests.body
  10593. .map(
  10594. (user) => `
  10595. <div class="friends_row">
  10596. <div class="centerY g-5">
  10597. <div class="profile-img">
  10598. <img src="${user.imageURL}" alt="${
  10599. user.username
  10600. }" onerror="this.onerror=null; this.src='https://czrsd.com/static/sigmod/SigMod25-rounded.png';">
  10601. <span class="status_icon ${
  10602. user.online ? 'online_icon' : 'offline_icon'
  10603. }"></span>
  10604. </div>
  10605. <div class="f-big">${user.username}</div>
  10606. </div>
  10607. <div class="centerY g-10">
  10608. <div class="${user.role}_role">${user.role}</div>
  10609. <div class="vr2"></div>
  10610. <button class="modButton centerXY accept" data-user-id="${
  10611. user._id
  10612. }" style="padding: 6px 7px;">
  10613. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512" width="16"><path fill="#ffffff" d="M438.6 105.4c12.5 12.5 12.5 32.8 0 45.3l-256 256c-12.5 12.5-32.8 12.5-45.3 0l-128-128c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L160 338.7 393.4 105.4c12.5-12.5 32.8-12.5 45.3 0z"/></svg>
  10614. </button>
  10615. <button class="modButton centerXY decline" data-user-id="${
  10616. user._id
  10617. }" style="padding: 5px 8px;">
  10618. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512" width="16"><path fill="#ffffff" d="M342.6 150.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L192 210.7 86.6 105.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L146.7 256 41.4 361.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L192 301.3 297.4 406.6c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L237.3 256 342.6 150.6z"/></svg>
  10619. </button>
  10620. </div>
  10621. </div>
  10622. `
  10623. )
  10624. .join('');
  10625.  
  10626. friends_body.innerHTML = reqHtml;
  10627.  
  10628. friends_body.querySelectorAll('.accept').forEach((accept) => {
  10629. accept.addEventListener('click', async () => {
  10630. const userId = accept.getAttribute('data-user-id');
  10631. const req = await fetch(this.appRoutes.handleRequest, {
  10632. method: 'POST',
  10633. headers: {
  10634. 'Content-Type': 'application/json',
  10635. },
  10636. body: JSON.stringify({
  10637. type: 'accept-request',
  10638. userId,
  10639. }),
  10640. credentials: 'include',
  10641. }).then((res) => res.json());
  10642. that.openRequests();
  10643. });
  10644. });
  10645.  
  10646. friends_body.querySelectorAll('.decline').forEach((decline) => {
  10647. decline.addEventListener('click', async () => {
  10648. const userId = decline.getAttribute('data-user-id');
  10649. const req = await fetch(this.appRoutes.handleRequest, {
  10650. method: 'POST',
  10651. headers: {
  10652. 'Content-Type': 'application/json',
  10653. },
  10654. body: JSON.stringify({
  10655. type: 'decline-request',
  10656. userId,
  10657. }),
  10658. credentials: 'include',
  10659. }).then((res) => res.json());
  10660. that.openRequests();
  10661. });
  10662. });
  10663. } else {
  10664. friends_body.innerHTML = `<span>No requests!</span>`;
  10665. }
  10666. },
  10667.  
  10668. async openFriendSettings() {
  10669. const friends_body = document.querySelector('.friends_body');
  10670. if (friends_body.classList.contains('allusers'))
  10671. friends_body.classList.remove('allusers');
  10672.  
  10673. friends_body.innerHTML = `
  10674. <div class="friends_row">
  10675. <div class="centerY g-5">
  10676. <div class="profile-img">
  10677. <img src="${
  10678. this.profile.imageURL
  10679. }" alt="Profile picture" />
  10680. </div>
  10681. <span class="f-big" id="profile_username_00" title="${
  10682. this.profile._id
  10683. }">${this.profile.username}</span>
  10684. </div>
  10685. <button class="modButton-black val" id="editProfile">Edit Profile</button>
  10686. </div>
  10687. <div class="friends_row">
  10688. <span>Status</span>
  10689. <select class="form-control val" id="edit_static_status">
  10690. <option value="online" ${
  10691. this.friends_settings.static_status === 'online'
  10692. ? 'selected'
  10693. : ''
  10694. }>Online</option>
  10695. <option value="offline" ${
  10696. this.friends_settings.static_status === 'offline'
  10697. ? 'selected'
  10698. : ''
  10699. }>Offline</option>
  10700. </select>
  10701. </div>
  10702. <div class="friends_row">
  10703. <span>Accept friend requests</span>
  10704. <div class="modCheckbox val">
  10705. <input type="checkbox" ${
  10706. this.friends_settings.accept_requests
  10707. ? 'checked'
  10708. : ''
  10709. } id="edit_accept_requests" />
  10710. <label class="cbx" for="edit_accept_requests"></label>
  10711. </div>
  10712. </div>
  10713. <div class="friends_row">
  10714. <span>Highlight friends</span>
  10715. <div class="modCheckbox val">
  10716. <input type="checkbox" ${
  10717. this.friends_settings.highlight_friends
  10718. ? 'checked'
  10719. : ''
  10720. } id="edit_highlight_friends" />
  10721. <label class="cbx" for="edit_highlight_friends"></label>
  10722. </div>
  10723. </div>
  10724. <div class="friends_row">
  10725. <span>Highlight color</span>
  10726. <input type="color" class="colorInput" value="${
  10727. this.friends_settings.highlight_color
  10728. }" style="margin-right: 12px;" id="edit_highlight_color" />
  10729. </div>
  10730. <div class="friends_row">
  10731. <span>Public profile</span>
  10732. <div class="modCheckbox val">
  10733. <input type="checkbox" ${
  10734. this.profile.visible ? 'checked' : ''
  10735. } id="edit_visible" />
  10736. <label class="cbx" for="edit_visible"></label>
  10737. </div>
  10738. </div>
  10739. <div class="friends_row">
  10740. <span>Logout</span>
  10741. <button class="modButton-black" id="logout_mod" style="width: 150px">Logout</button>
  10742. </div>
  10743. `;
  10744.  
  10745. const editProfile = byId('editProfile');
  10746. editProfile.addEventListener('click', () => {
  10747. this.openProfileEditor();
  10748. });
  10749.  
  10750. const logout = byId('logout_mod');
  10751. logout.addEventListener('click', async () => {
  10752. if (confirm('Are you sure you want to logout?')) {
  10753. try {
  10754. const res = await fetch(this.appRoutes.logout, {
  10755. credentials: 'include',
  10756. });
  10757.  
  10758. const data = await res.json();
  10759.  
  10760. if (!data.success)
  10761. return alert('Something went wrong...');
  10762.  
  10763. modSettings.modAccount.authorized = false;
  10764. updateStorage();
  10765. location.reload();
  10766. } catch (error) {
  10767. console.error('Error logging out:', error);
  10768. }
  10769. }
  10770. });
  10771.  
  10772. const edit_static_status = byId('edit_static_status');
  10773. const edit_accept_requests = byId('edit_accept_requests');
  10774. const edit_highlight_friends = byId('edit_highlight_friends');
  10775. const edit_highlight_color = byId('edit_highlight_color');
  10776. const edit_visible = byId('edit_visible');
  10777.  
  10778. edit_static_status.addEventListener('change', () => {
  10779. const val = edit_static_status.value;
  10780. updateSettings('static_status', val);
  10781. });
  10782.  
  10783. edit_accept_requests.addEventListener('change', () => {
  10784. const val = edit_accept_requests.checked;
  10785. updateSettings('accept_requests', val);
  10786. });
  10787.  
  10788. edit_highlight_friends.addEventListener('change', () => {
  10789. const val = edit_highlight_friends.checked;
  10790. updateSettings('highlight_friends', val);
  10791. });
  10792.  
  10793. // Debounce the updateSettings function
  10794. edit_highlight_color.addEventListener(
  10795. 'input',
  10796. debounce(() => {
  10797. const val = edit_highlight_color.value;
  10798. updateSettings('highlight_color', val);
  10799. }, 500)
  10800. );
  10801.  
  10802. edit_visible.addEventListener('change', () => {
  10803. const val = edit_visible.checked;
  10804. updateSettings('visible', val);
  10805. });
  10806.  
  10807. const updateSettings = async (type, data) => {
  10808. const resData = await (
  10809. await fetch(this.appRoutes.updateSettings, {
  10810. method: 'POST',
  10811. body: JSON.stringify({ type, data }),
  10812. credentials: 'include',
  10813. headers: {
  10814. 'Content-Type': 'application/json',
  10815. },
  10816. })
  10817. ).json();
  10818.  
  10819. if (resData.success) {
  10820. this.friends_settings[type] = data;
  10821. }
  10822. };
  10823. },
  10824.  
  10825. openProfileEditor() {
  10826. let that = this;
  10827.  
  10828. const overlay = document.createElement('div');
  10829. overlay.classList.add('mod_overlay');
  10830. overlay.style.opacity = '0';
  10831. overlay.innerHTML = `
  10832. <div class="signIn-wrapper">
  10833. <div class="signIn-header">
  10834. <span>Edit mod profile</span>
  10835. <div class="centerXY" style="width: 32px; height: 32px;">
  10836. <button class="modButton-black" id="closeProfileEditor">
  10837. <svg width="18" height="20" viewBox="0 0 16 16" fill="#ffffff" xmlns="http://www.w3.org/2000/svg">
  10838. <path d="M1.6001 14.4L14.4001 1.59998M14.4001 14.4L1.6001 1.59998" stroke="#fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path>
  10839. </svg>
  10840. </button>
  10841. </div>
  10842. </div>
  10843. <div class="signIn-body" style="width: fit-content;">
  10844. <div class="centerXY g-10">
  10845. <div class="profile-img" style="width: 6em;height: 6em;">
  10846. <img src="${
  10847. this.profile.imageURL
  10848. }" alt="Profile picture" />
  10849. </div>
  10850. <div class="f-column g-5">
  10851. <input type="file" id="imageUpload" accept="image/*" style="display: none;">
  10852. <label for="imageUpload" class="modButton-black g-10">
  10853. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="16"><path fill="#ffffff" d="M149.1 64.8L138.7 96H64C28.7 96 0 124.7 0 160V416c0 35.3 28.7 64 64 64H448c35.3 0 64-28.7 64-64V160c0-35.3-28.7-64-64-64H373.3L362.9 64.8C356.4 45.2 338.1 32 317.4 32H194.6c-20.7 0-39 13.2-45.5 32.8zM256 192a96 96 0 1 1 0 192 96 96 0 1 1 0-192z"/></svg>
  10854. Upload avatar
  10855. </label>
  10856. <button class="modButton-black g-10" id="deleteAvatar">
  10857. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512" width="16"><path fill="#ffffff" d="M135.2 17.7C140.6 6.8 151.7 0 163.8 0H284.2c12.1 0 23.2 6.8 28.6 17.7L320 32h96c17.7 0 32 14.3 32 32s-14.3 32-32 32H32C14.3 96 0 81.7 0 64S14.3 32 32 32h96l7.2-14.3zM32 128H416V448c0 35.3-28.7 64-64 64H96c-35.3 0-64-28.7-64-64V128zm96 64c-8.8 0-16 7.2-16 16V432c0 8.8 7.2 16 16 16s16-7.2 16-16V208c0-8.8-7.2-16-16-16zm96 0c-8.8 0-16 7.2-16 16V432c0 8.8 7.2 16 16 16s16-7.2 16-16V208c0-8.8-7.2-16-16-16zm96 0c-8.8 0-16 7.2-16 16V432c0 8.8 7.2 16 16 16s16-7.2 16-16V208c0-8.8-7.2-16-16-16z"/></svg>
  10858. Delete avatar
  10859. </button>
  10860. </div>
  10861. </div>
  10862. <div class="f-column w-100">
  10863. <label for="username_edit">Username</label>
  10864. <input type="text" class="form-control" id="username_edit" value="${
  10865. this.profile.username
  10866. }" maxlength="40" minlength="4" />
  10867. </div>
  10868. <div class="f-column w-100">
  10869. <label for="bio_edit">Bio</label>
  10870. <div class="textarea-container">
  10871. <textarea placeholder="Hello! I'm ..." class="form-control" maxlength="250" id="bio_edit">${
  10872. this.profile.bio || ''
  10873. }</textarea>
  10874. <span class="char-counter" id="charCount">${
  10875. this.profile.bio
  10876. ? this.profile.bio.length
  10877. : '0'
  10878. }/250</span>
  10879. </div>
  10880. </div>
  10881. <button class="modButton-black" style="margin-bottom: 20px;" id="saveChanges">Save changes</button>
  10882. </div>
  10883. </div>
  10884. `;
  10885. document.body.append(overlay);
  10886.  
  10887. function hide() {
  10888. overlay.style.opacity = '0';
  10889. setTimeout(() => {
  10890. overlay.remove();
  10891. }, 300);
  10892. }
  10893.  
  10894. overlay.addEventListener('click', (e) => {
  10895. if (e.target == overlay) hide();
  10896. });
  10897.  
  10898. setTimeout(() => {
  10899. overlay.style.opacity = '1';
  10900. });
  10901.  
  10902. byId('closeProfileEditor').addEventListener('click', hide);
  10903.  
  10904. let changes = new Set(); // Use a Set to store unique changes
  10905.  
  10906. const bio_edit = byId('bio_edit');
  10907. const charCountSpan = byId('charCount');
  10908. bio_edit.addEventListener('input', updCharcounter);
  10909.  
  10910. function updCharcounter() {
  10911. const currentTextLength = bio_edit.value.length;
  10912. charCountSpan.textContent = currentTextLength + '/250';
  10913.  
  10914. // Update changes
  10915. changes.add('bio');
  10916. }
  10917.  
  10918. // Upload avatar
  10919. byId('imageUpload').addEventListener('input', async (e) => {
  10920. const file = e.target.files[0];
  10921. if (!file) return;
  10922.  
  10923. const formData = new FormData();
  10924. formData.append('image', file);
  10925.  
  10926. try {
  10927. const data = await (
  10928. await fetch(this.appRoutes.imgUpload, {
  10929. method: 'POST',
  10930. credentials: 'include',
  10931. body: formData,
  10932. })
  10933. ).json();
  10934.  
  10935. if (data.success) {
  10936. const profileImg =
  10937. document.querySelector('.profile-img img');
  10938. profileImg.src = data.user.imageURL;
  10939. hide();
  10940. that.profile = data.user;
  10941. } else {
  10942. that.modAlert(data.message, 'danger');
  10943. console.error('Failed to upload image');
  10944. }
  10945. } catch (error) {
  10946. console.error('Error uploading image:', error);
  10947. }
  10948. });
  10949.  
  10950. const username_edit = byId('username_edit');
  10951. username_edit.addEventListener('input', () => {
  10952. changes.add('username');
  10953. });
  10954.  
  10955. const saveChanges = byId('saveChanges');
  10956. saveChanges.addEventListener('click', async () => {
  10957. if (changes.size === 0) return;
  10958. let changedData = {};
  10959. changes.forEach((change) => {
  10960. if (change === 'username') {
  10961. changedData.username = username_edit.value;
  10962. } else if (change === 'bio') {
  10963. changedData.bio = bio_edit.value;
  10964. }
  10965. });
  10966.  
  10967. const resData = await (
  10968. await fetch(this.appRoutes.editProfile, {
  10969. method: 'POST',
  10970. body: JSON.stringify({
  10971. changes: Array.from(changes),
  10972. data: changedData,
  10973. }),
  10974. credentials: 'include',
  10975. headers: {
  10976. 'Content-Type': 'application/json',
  10977. },
  10978. })
  10979. ).json();
  10980.  
  10981. if (resData.success) {
  10982. if (that.profile.username !== resData.user.username) {
  10983. const p_username = byId('profile_username_00');
  10984. if (p_username)
  10985. p_username.innerText = resData.user.username;
  10986. }
  10987. that.profile = resData.user;
  10988. changes.clear();
  10989. hide();
  10990. const name = byId('my-profile-name');
  10991. const bioText = byId('my-profile-bio');
  10992.  
  10993. name.innerText = resData.user.username;
  10994. bioText.innerHTML = resData.user.bio || 'No bio.';
  10995. } else {
  10996. if (resData.message) {
  10997. this.modAlert(resData.message, 'danger');
  10998. }
  10999. }
  11000. });
  11001.  
  11002. const deleteAvatar = byId('deleteAvatar');
  11003. deleteAvatar.addEventListener('click', async () => {
  11004. if (
  11005. confirm(
  11006. 'Are you sure you want to remove your profile picture? It will be changed to the default profile picture.'
  11007. )
  11008. ) {
  11009. try {
  11010. const data = await (
  11011. await fetch(this.appRoutes.delProfile, {
  11012. credentials: 'include',
  11013. })
  11014. ).json();
  11015. const profileImg =
  11016. document.querySelector('.profile-img img');
  11017. profileImg.src = data.user.imageURL;
  11018. hide();
  11019. that.profile = data.user;
  11020. } catch (error) {
  11021. console.error("Couldn't remove image: ", error);
  11022. this.modAlert(error.message, 'danger');
  11023. }
  11024. }
  11025. });
  11026. },
  11027.  
  11028. async announcements() {
  11029. const previewContainer = byId('mod-announcements');
  11030.  
  11031. const announcements = await (
  11032. await fetch(this.appRoutes.announcements)
  11033. ).json();
  11034. if (!announcements.success) return;
  11035.  
  11036. const { data } = announcements;
  11037.  
  11038. const pinnedAnnouncements = data.filter(
  11039. (announcement) => announcement.pinned
  11040. );
  11041. const unpinnedAnnouncements = data.filter(
  11042. (announcement) => !announcement.pinned
  11043. );
  11044.  
  11045. pinnedAnnouncements.sort(
  11046. (a, b) => new Date(b.date) - new Date(a.date)
  11047. );
  11048. unpinnedAnnouncements.sort(
  11049. (a, b) => new Date(b.date) - new Date(a.date)
  11050. );
  11051.  
  11052. const sortedAnnouncements = [
  11053. ...pinnedAnnouncements,
  11054. ...unpinnedAnnouncements,
  11055. ];
  11056.  
  11057. const previews = sortedAnnouncements
  11058. .map(
  11059. (announcement) => `
  11060. <div class="mod-announcement" data-announcement-id="${announcement._id}">
  11061. <img class="mod-announcement-icon" src="${
  11062. announcement.icon
  11063. }" width="32" draggable="false" />
  11064. <div class="mod-announcement-text">
  11065. <span>${announcement.title}</span>
  11066. <div>${announcement.description}</div>
  11067. </div>
  11068. ${
  11069. announcement.pinned
  11070. ? '<img src="https://czrsd.com/static/icons/pinned.svg" draggable="false" style="width: 22px; align-self: start;" />'
  11071. : ''
  11072. }
  11073. </div>
  11074. `
  11075. )
  11076. .join('');
  11077.  
  11078. previewContainer.innerHTML = previews;
  11079.  
  11080. const announcementElements =
  11081. document.querySelectorAll('.mod-announcement');
  11082. announcementElements.forEach((element) => {
  11083. element.addEventListener('click', async (event) => {
  11084. const announcementId = element.getAttribute(
  11085. 'data-announcement-id'
  11086. );
  11087. try {
  11088. const data = await (
  11089. await fetch(
  11090. this.appRoutes.announcement(announcementId)
  11091. )
  11092. ).json();
  11093. if (data.success) {
  11094. createAnnouncementTab(data.data);
  11095. }
  11096. } catch (error) {
  11097. console.error(
  11098. 'Error fetching announcement details:',
  11099. error
  11100. );
  11101. }
  11102. });
  11103. });
  11104.  
  11105. function createAnnouncementTab(data) {
  11106. const menuContent = document.querySelector('.mod_menu_content');
  11107. const modHome = byId('mod_home');
  11108. const content = document.createElement('div');
  11109.  
  11110. content.setAttribute('id', 'announcement-tab');
  11111. content.classList.add('mod_tab');
  11112. content.style.display = 'none';
  11113. content.style.opacity = '0';
  11114.  
  11115. const announcementHTML = `
  11116. <div class="centerY justify-sb">
  11117. <div class="centerY g-5">
  11118. <img style="border-radius: 50%;" src="${
  11119. data.preview.icon
  11120. }" width="64" draggable="false" />
  11121. <div class="f-column centerX">
  11122. <h2>${data.full.title}</h2>
  11123. <span style="color: #7E7E7E">${prettyTime.fullDate(data.date)}</span>
  11124. </div>
  11125. </div>
  11126. <button class="modButton-black" style="width: 20%;" id="mod-announcement-back">Back</button>
  11127. </div>
  11128. <div class="mod-announcement-content">
  11129. <div class="f-column g-10 scroll">${data.full.description}</div>
  11130. <div class="mod-announcement-images scroll">
  11131. ${data.full.images
  11132. .map(
  11133. (image) =>
  11134. `<img src="${image}" onclick="window.open('${image}')" />`
  11135. )
  11136. .join('')}
  11137. </div>
  11138. </div>
  11139. `;
  11140.  
  11141. content.innerHTML = announcementHTML;
  11142. menuContent.appendChild(content);
  11143.  
  11144. window.openModTab('announcement-tab');
  11145.  
  11146. const back = byId('mod-announcement-back');
  11147. back.addEventListener('click', () => {
  11148. const mod_home = byId('mod_home');
  11149. content.style.opacity = '0';
  11150. setTimeout(() => {
  11151. content.remove();
  11152.  
  11153. mod_home.style.display = 'flex';
  11154. mod_home.style.opacity = '1';
  11155. }, 300);
  11156.  
  11157. byId('tab_home_btn').classList.add('mod_selected');
  11158. });
  11159. 1;
  11160. }
  11161. },
  11162.  
  11163. chart() {
  11164. const canvas = byId('sigmod-stats');
  11165. const { Chart } = window;
  11166.  
  11167. const stats = JSON.parse(localStorage.getItem('game-stats'));
  11168.  
  11169. // max values
  11170. const statValues = {
  11171. timeplayed: [
  11172. 10_000, 50_000, 100_000, 150_000, 200_000, 250_000, 300_000,
  11173. 400_000, 800_000, 1_000_000,
  11174. ],
  11175. highestmass: [
  11176. 50_000, 100_000, 500_000, 700_000, 1_000_000, 5_000_000,
  11177. 10_000_000,
  11178. ],
  11179. totaldeaths: [
  11180. 100, 500, 1_000, 2_000, 3_000, 4_000, 5_000, 8_000, 10_000,
  11181. 30_000, 50_000, 100_000,
  11182. ],
  11183. totalmass: [
  11184. 100_000, 500_000, 1_000_000, 2_000_000, 3_000_000,
  11185. 5_000_000, 10_000_000, 50_000_000, 100_000_000, 500_000_000,
  11186. 1_000_000_000, 2_000_000_000, 5_000_000_000,
  11187. ],
  11188. };
  11189.  
  11190. const getBestValue = (stat, values) => {
  11191. for (let value of values) {
  11192. if (stat < value) return value;
  11193. }
  11194. return values[values.length - 1];
  11195. };
  11196.  
  11197. const emojiLabels = ['⏲', '🏆', '💀', '🔢'];
  11198. const textLabels = [
  11199. 'Time Played',
  11200. 'Highest Mass',
  11201. 'Total Deaths',
  11202. 'Total Mass',
  11203. ];
  11204.  
  11205. const data = {
  11206. labels: emojiLabels,
  11207. datasets: [
  11208. {
  11209. label: 'Your Stats',
  11210. data: [
  11211. stats['time-played'] /
  11212. getBestValue(
  11213. stats['time-played'],
  11214. statValues.timeplayed
  11215. ),
  11216. stats['highest-mass'] /
  11217. getBestValue(
  11218. stats['highest-mass'],
  11219. statValues.highestmass
  11220. ),
  11221. stats['total-deaths'] /
  11222. getBestValue(
  11223. stats['total-deaths'],
  11224. statValues.totaldeaths
  11225. ),
  11226. stats['total-mass'] /
  11227. getBestValue(
  11228. stats['total-mass'],
  11229. statValues.totalmass
  11230. ),
  11231. ],
  11232. backgroundColor: [
  11233. 'rgba(255, 99, 132, 0.2)',
  11234. 'rgba(54, 162, 235, 0.2)',
  11235. 'rgba(255, 206, 86, 0.2)',
  11236. 'rgba(153, 102, 255, 0.2)',
  11237. ],
  11238. borderColor: [
  11239. 'rgba(255, 99, 132, 1)',
  11240. 'rgba(54, 162, 235, 1)',
  11241. 'rgba(255, 206, 86, 1)',
  11242. 'rgba(153, 102, 255, 1)',
  11243. ],
  11244. borderWidth: 1,
  11245. },
  11246. ],
  11247. };
  11248.  
  11249. const formatLabel = (labelType, actualValue) => {
  11250. if (labelType === 'Time Played') {
  11251. const hours = Math.floor(actualValue / 3600);
  11252. const minutes = Math.floor((actualValue % 3600) / 60);
  11253. return hours > 0 ? `${hours}h ${minutes}m` : `${minutes}m`;
  11254. } else if (
  11255. labelType === 'Highest Mass' ||
  11256. labelType === 'Total Mass'
  11257. ) {
  11258. return actualValue > 999
  11259. ? `${(actualValue / 1000).toFixed(1)}k`
  11260. : actualValue.toString();
  11261. } else {
  11262. return actualValue.toString();
  11263. }
  11264. };
  11265.  
  11266. const createChart = () => {
  11267. try {
  11268. new Chart(canvas, {
  11269. type: 'bar',
  11270. data: data,
  11271. options: {
  11272. indexAxis: 'y',
  11273. scales: {
  11274. x: {
  11275. beginAtZero: true,
  11276. max: 1,
  11277. ticks: {
  11278. callback: (value) =>
  11279. `${(value * 100).toFixed(0)}%`,
  11280. },
  11281. },
  11282. },
  11283. plugins: {
  11284. legend: {
  11285. display: false,
  11286. },
  11287. tooltip: {
  11288. callbacks: {
  11289. title: (context) =>
  11290. textLabels[context[0].dataIndex],
  11291. label: (context) => {
  11292. const dataIndex = context.dataIndex;
  11293. const labelType =
  11294. textLabels[dataIndex];
  11295. const actualValue =
  11296. context.dataset.data[
  11297. dataIndex
  11298. ] *
  11299. getBestValue(
  11300. stats[
  11301. labelType
  11302. .toLowerCase()
  11303. .replace(' ', '-')
  11304. ],
  11305. statValues[
  11306. labelType
  11307. .toLowerCase()
  11308. .replace(' ', '')
  11309. ]
  11310. );
  11311. return formatLabel(
  11312. labelType,
  11313. actualValue
  11314. );
  11315. },
  11316. },
  11317. },
  11318. },
  11319. },
  11320. });
  11321. } catch (error) {
  11322. console.error(
  11323. 'An error occurred while rendering the chart:',
  11324. error
  11325. );
  11326. }
  11327. };
  11328.  
  11329. createChart();
  11330. },
  11331.  
  11332. // Color input events & Reset color event handler
  11333. colorPicker() {
  11334. const colorPickerConfig = {
  11335. mapColor: {
  11336. path: 'game.map.color',
  11337. opacity: false,
  11338. color: modSettings.game.map.color,
  11339. default: '#111111',
  11340. },
  11341. borderColor: {
  11342. path: 'game.borderColor',
  11343. opacity: true,
  11344. color: modSettings.game.borderColor,
  11345. default: '#0000ff',
  11346. },
  11347. foodColor: {
  11348. path: 'game.foodColor',
  11349. opacity: true,
  11350. color: modSettings.game.foodColor,
  11351. default: null,
  11352. },
  11353. cellColor: {
  11354. path: 'game.cellColor',
  11355. opacity: true,
  11356. color: modSettings.game.cellColor,
  11357. default: null,
  11358. },
  11359. nameColor: {
  11360. path: 'game.name.color',
  11361. opacity: false,
  11362. color: modSettings.game.name.color,
  11363. default: '#ffffff',
  11364. },
  11365. gradientNameColor1: {
  11366. path: 'game.name.gradient.left',
  11367. opacity: false,
  11368. color: modSettings.game.name.gradient.left,
  11369. default: '#ffffff',
  11370. },
  11371. gradientNameColor2: {
  11372. path: 'game.name.gradient.right',
  11373. opacity: false,
  11374. color: modSettings.game.name.gradient.right,
  11375. default: '#ffffff',
  11376. },
  11377. chatBackground: {
  11378. path: 'chat.bgColor',
  11379. opacity: true,
  11380. color: modSettings.chat.bgColor,
  11381. default: defaultSettings.chat.bgColor,
  11382. elementTarget: {
  11383. selector: '.modChat',
  11384. property: 'background',
  11385. },
  11386. },
  11387. chatTextColor: {
  11388. path: 'chat.textColor',
  11389. opacity: true,
  11390. color: modSettings.chat.textColor,
  11391. default: defaultSettings.chat.textColor,
  11392. elementTarget: {
  11393. selector: '.chatMessage-text',
  11394. property: 'color',
  11395. },
  11396. },
  11397. chatThemeChanger: {
  11398. path: 'chat.themeColor',
  11399. opacity: true,
  11400. color: modSettings.chat.themeColor,
  11401. default: defaultSettings.chat.themeColor,
  11402. elementTarget: {
  11403. selector: '.chatButton',
  11404. property: 'background',
  11405. },
  11406. },
  11407. };
  11408.  
  11409. const { Alwan } = window;
  11410.  
  11411. Object.entries(colorPickerConfig).forEach(
  11412. ([
  11413. selector,
  11414. {
  11415. path,
  11416. opacity,
  11417. color,
  11418. default: defaultColor,
  11419. elementTarget,
  11420. },
  11421. ]) => {
  11422. const storagePath = path.split('.');
  11423. const colorPickerInstance = new Alwan(`#${selector}`, {
  11424. id: `edit-${selector}`,
  11425. color: color || defaultColor || '#000000',
  11426. theme: 'dark',
  11427. opacity,
  11428. format: 'hex',
  11429. default: defaultColor,
  11430. swatches: ['black', 'white', 'red', 'blue', 'green'],
  11431. });
  11432.  
  11433. const pickerElement = byId(`edit-${selector}`);
  11434. pickerElement.insertAdjacentHTML(
  11435. 'beforeend',
  11436. `
  11437. <div class="colorpicker-additional">
  11438. <span>Reset Color</span>
  11439. <button class="resetButton" id="reset-${selector}"></button>
  11440. </div>
  11441. `
  11442. );
  11443.  
  11444. colorPickerInstance.on('change', (e) => {
  11445. let storageElement = modSettings;
  11446. storagePath
  11447. .slice(0, -1)
  11448. .forEach(
  11449. (part) =>
  11450. (storageElement = storageElement[part])
  11451. );
  11452. storageElement[storagePath.at(-1)] = e.hex;
  11453.  
  11454. if (
  11455. path.includes('gradientName') &&
  11456. modSettings.game.name.gradient.enabled
  11457. ) {
  11458. modSettings.game.name.gradient.enabled = true;
  11459. }
  11460.  
  11461. if (elementTarget) {
  11462. const targets = document.querySelectorAll(
  11463. elementTarget.selector
  11464. );
  11465.  
  11466. targets.forEach((target) => {
  11467. target.style[elementTarget.property] = e.hex;
  11468. });
  11469. }
  11470.  
  11471. updateStorage();
  11472. });
  11473.  
  11474. byId(`reset-${selector}`)?.addEventListener('click', () => {
  11475. colorPickerInstance.setColor(defaultColor);
  11476.  
  11477. let storageElement = modSettings;
  11478. storagePath
  11479. .slice(0, -1)
  11480. .forEach(
  11481. (part) =>
  11482. (storageElement = storageElement[part])
  11483. );
  11484. storageElement[storagePath.at(-1)] = defaultColor;
  11485.  
  11486. if (
  11487. path.includes('gradientName') &&
  11488. !modSettings.game.name.gradient.left &&
  11489. !modSettings.game.name.gradient.right
  11490. ) {
  11491. modSettings.game.name.gradient.enabled = false;
  11492. }
  11493.  
  11494. if (elementTarget) {
  11495. const targets = document.querySelectorAll(
  11496. elementTarget.selector
  11497. );
  11498.  
  11499. targets.forEach((target) => {
  11500. target.style[elementTarget.property] =
  11501. defaultColor;
  11502. });
  11503. }
  11504.  
  11505. updateStorage();
  11506. });
  11507. }
  11508. );
  11509. },
  11510.  
  11511. async getBlockedChatData() {
  11512. try {
  11513. const res = await fetch(`${this.appRoutes.blockedChatData}?v=${Math.floor(Math.random() * 9e5)}`, {
  11514. headers: {
  11515. 'Content-Type': 'application/json'
  11516. }
  11517. });
  11518. const resData = await res.json();
  11519. const { names, messages } = resData;
  11520.  
  11521. this.blockedChatData = {
  11522. names,
  11523. messages
  11524. }
  11525. } catch(e) {
  11526. console.error('Couldn\'t fetch blocked chat data.');
  11527. }
  11528. },
  11529.  
  11530. async loadLibraries() {
  11531. const loadScript = (src) =>
  11532. new Promise((resolve, reject) => {
  11533. const script = document.createElement('script');
  11534. script.src = src;
  11535. script.type = 'text/javascript';
  11536. document.head.appendChild(script);
  11537.  
  11538. script.onload = () => resolve();
  11539. script.onerror = (error) => reject(error);
  11540. });
  11541.  
  11542. const loadCSS = (href) =>
  11543. new Promise((resolve, reject) => {
  11544. const link = document.createElement('link');
  11545. link.rel = 'stylesheet';
  11546. link.href = href;
  11547. document.head.appendChild(link);
  11548.  
  11549. link.onload = () => resolve();
  11550. link.onerror = (error) => reject(error);
  11551. });
  11552.  
  11553. for (const [lib, val] of Object.entries(libs)) {
  11554. if (typeof val === 'string') {
  11555. await loadScript(val);
  11556. } else {
  11557. await loadScript(val.js);
  11558. if (val.css) await loadCSS(val.css);
  11559. }
  11560.  
  11561. console.log(`%c Loaded ${lib}.`, 'color: lime');
  11562.  
  11563. if (typeof this[lib] === 'function') this[lib]();
  11564. }
  11565. },
  11566.  
  11567. isRateLimited() {
  11568. if (document.body.children[0]?.id === 'cf-wrapper') {
  11569. console.log('User is rate limited.');
  11570. return true;
  11571. }
  11572. return false;
  11573. },
  11574.  
  11575. setupUI() {
  11576. this.menu();
  11577. this.initStats();
  11578. this.announcements();
  11579. this.mainMenu();
  11580. this.saveNames();
  11581. this.tagsystem();
  11582. this.createMinimap();
  11583. this.themes();
  11584. },
  11585.  
  11586. setupGame() {
  11587. this.game();
  11588. this.macros();
  11589. },
  11590.  
  11591. setupNetworking() {
  11592. this.clientPing();
  11593. this.chat();
  11594. this.handleNick();
  11595. },
  11596.  
  11597. initModules() {
  11598. try {
  11599. this.loadLibraries();
  11600. this.setupUI();
  11601. this.setupGame();
  11602. this.setupNetworking();
  11603. } catch (e) {
  11604. console.error('An error occurred while loading SigMod: ', e);
  11605. }
  11606. },
  11607.  
  11608. init() {
  11609. if (this.isRateLimited()) return;
  11610. if (!document.querySelector('.body__inner')) return;
  11611.  
  11612. this.credits();
  11613.  
  11614. new SigWsHandler();
  11615.  
  11616. this.initModules();
  11617. }
  11618. };
  11619.  
  11620. mods = new Mod();
  11621. })();