gimkitcheat

A userscript that allows you to cheat across various gimkit games

  1. // ==UserScript==
  2. // @name gimkitcheat
  3. // @description A userscript that allows you to cheat across various gimkit games
  4. // @namespace https://www.github.com/TheLazySquid/GimkitCheat
  5. // @match https://www.gimkit.com/join*
  6. // @run-at document-start
  7. // @iconURL https://www.gimkit.com/favicon.png
  8. // @author TheLazySquid
  9. // @version 0.3.5
  10. // @license ISC
  11. // @grant GM_getValue
  12. // @grant GM_setValue
  13. // @grant GM_deleteValue
  14. // ==/UserScript==
  15. (function () {
  16. 'use strict';
  17.  
  18. var version = "0.3.5";
  19.  
  20. function utf8Read$1(bytes, offset, length) {
  21. var string = '', chr = 0;
  22. for (var i = offset, end = offset + length; i < end; i++) {
  23. var byte = bytes[i];
  24. if ((byte & 0x80) === 0x00) {
  25. string += String.fromCharCode(byte);
  26. continue;
  27. }
  28. if ((byte & 0xe0) === 0xc0) {
  29. string += String.fromCharCode(
  30. ((byte & 0x1f) << 6) |
  31. (bytes[++i] & 0x3f)
  32. );
  33. continue;
  34. }
  35. if ((byte & 0xf0) === 0xe0) {
  36. string += String.fromCharCode(
  37. ((byte & 0x0f) << 12) |
  38. ((bytes[++i] & 0x3f) << 6) |
  39. ((bytes[++i] & 0x3f) << 0)
  40. );
  41. continue;
  42. }
  43. if ((byte & 0xf8) === 0xf0) {
  44. chr = ((byte & 0x07) << 18) |
  45. ((bytes[++i] & 0x3f) << 12) |
  46. ((bytes[++i] & 0x3f) << 6) |
  47. ((bytes[++i] & 0x3f) << 0);
  48. if (chr >= 0x010000) { // surrogate pair
  49. chr -= 0x010000;
  50. string += String.fromCharCode((chr >>> 10) + 0xD800, (chr & 0x3FF) + 0xDC00);
  51. } else {
  52. string += String.fromCharCode(chr);
  53. }
  54. continue;
  55. }
  56.  
  57. console.error('Invalid byte ' + byte.toString(16));
  58. // (do not throw error to avoid server/client from crashing due to hack attemps)
  59. // throw new Error('Invalid byte ' + byte.toString(16));
  60. }
  61. return string;
  62. }
  63.  
  64. function int8(bytes, it) {
  65. return uint8(bytes, it) << 24 >> 24;
  66. }
  67. function uint8(bytes, it) {
  68. return bytes[it.offset++];
  69. }
  70. function int16(bytes, it) {
  71. return uint16(bytes, it) << 16 >> 16;
  72. }
  73. function uint16(bytes, it) {
  74. return bytes[it.offset++] | bytes[it.offset++] << 8;
  75. }
  76. function int32(bytes, it) {
  77. return bytes[it.offset++] | bytes[it.offset++] << 8 | bytes[it.offset++] << 16 | bytes[it.offset++] << 24;
  78. }
  79. function uint32(bytes, it) {
  80. return int32(bytes, it) >>> 0;
  81. }
  82. function int64(bytes, it) {
  83. const low = uint32(bytes, it);
  84. const high = int32(bytes, it) * Math.pow(2, 32);
  85. return high + low;
  86. }
  87. function uint64(bytes, it) {
  88. const low = uint32(bytes, it);
  89. const high = uint32(bytes, it) * Math.pow(2, 32);
  90. return high + low;
  91. }const _int32 = new Int32Array(2);
  92. const _float32 = new Float32Array(_int32.buffer);
  93. const _float64 = new Float64Array(_int32.buffer);
  94.  
  95. function readFloat32(bytes, it) {
  96. _int32[0] = int32(bytes, it);
  97. return _float32[0];
  98. }
  99. function readFloat64(bytes, it) {
  100. _int32[0 ] = int32(bytes, it);
  101. _int32[1 ] = int32(bytes, it);
  102. return _float64[0];
  103. }
  104. function string(bytes, it) {
  105. const prefix = bytes[it.offset++];
  106. let length;
  107.  
  108. if (prefix < 0xc0) {
  109. // fixstr
  110. length = prefix & 0x1f;
  111.  
  112. } else if (prefix === 0xd9) {
  113. length = uint8(bytes, it);
  114.  
  115. } else if (prefix === 0xda) {
  116. length = uint16(bytes, it);
  117.  
  118. } else if (prefix === 0xdb) {
  119. length = uint32(bytes, it);
  120. }
  121.  
  122. const value = utf8Read$1(bytes, it.offset, length);
  123. it.offset += length;
  124.  
  125. return value;
  126. }
  127.  
  128. function stringCheck(bytes, it) {
  129. const prefix = bytes[it.offset];
  130. return (
  131. // fixstr
  132. (prefix < 0xc0 && prefix > 0xa0) ||
  133. // str 8
  134. prefix === 0xd9 ||
  135. // str 16
  136. prefix === 0xda ||
  137. // str 32
  138. prefix === 0xdb
  139. );
  140. }
  141.  
  142. function number(bytes, it) {
  143. const prefix = bytes[it.offset++];
  144.  
  145. if (prefix < 0x80) {
  146. // positive fixint
  147. return prefix;
  148.  
  149. } else if (prefix === 0xca) {
  150. // float 32
  151. return readFloat32(bytes, it);
  152.  
  153. } else if (prefix === 0xcb) {
  154. // float 64
  155. return readFloat64(bytes, it);
  156.  
  157. } else if (prefix === 0xcc) {
  158. // uint 8
  159. return uint8(bytes, it);
  160.  
  161. } else if (prefix === 0xcd) {
  162. // uint 16
  163. return uint16(bytes, it);
  164.  
  165. } else if (prefix === 0xce) {
  166. // uint 32
  167. return uint32(bytes, it);
  168.  
  169. } else if (prefix === 0xcf) {
  170. // uint 64
  171. return uint64(bytes, it);
  172.  
  173. } else if (prefix === 0xd0) {
  174. // int 8
  175. return int8(bytes, it);
  176.  
  177. } else if (prefix === 0xd1) {
  178. // int 16
  179. return int16(bytes, it);
  180.  
  181. } else if (prefix === 0xd2) {
  182. // int 32
  183. return int32(bytes, it);
  184.  
  185. } else if (prefix === 0xd3) {
  186. // int 64
  187. return int64(bytes, it);
  188.  
  189. } else if (prefix > 0xdf) {
  190. // negative fixint
  191. return (0xff - prefix + 1) * -1
  192. }
  193. }
  194.  
  195. const Protocol = {
  196. // Room-related (10~19)
  197. JOIN_ROOM: 10,
  198. ERROR: 11,
  199. LEAVE_ROOM: 12,
  200. ROOM_DATA: 13,
  201. ROOM_STATE: 14,
  202. ROOM_STATE_PATCH: 15,
  203. ROOM_DATA_SCHEMA: 16
  204. };
  205.  
  206. function Decoder(buffer, offset) {
  207. this._offset = offset;
  208. if (buffer instanceof ArrayBuffer) {
  209. this._buffer = buffer;
  210. this._view = new DataView(this._buffer);
  211. }
  212. else if (ArrayBuffer.isView(buffer)) {
  213. this._buffer = buffer.buffer;
  214. this._view = new DataView(this._buffer, buffer.byteOffset, buffer.byteLength);
  215. }
  216. else {
  217. throw new Error('Invalid argument');
  218. }
  219. }
  220. function utf8Read(view, offset, length) {
  221. var string = '', chr = 0;
  222. for (var i = offset, end = offset + length; i < end; i++) {
  223. var byte = view.getUint8(i);
  224. if ((byte & 0x80) === 0x00) {
  225. string += String.fromCharCode(byte);
  226. continue;
  227. }
  228. if ((byte & 0xe0) === 0xc0) {
  229. string += String.fromCharCode(((byte & 0x1f) << 6) |
  230. (view.getUint8(++i) & 0x3f));
  231. continue;
  232. }
  233. if ((byte & 0xf0) === 0xe0) {
  234. string += String.fromCharCode(((byte & 0x0f) << 12) |
  235. ((view.getUint8(++i) & 0x3f) << 6) |
  236. ((view.getUint8(++i) & 0x3f) << 0));
  237. continue;
  238. }
  239. if ((byte & 0xf8) === 0xf0) {
  240. chr = ((byte & 0x07) << 18) |
  241. ((view.getUint8(++i) & 0x3f) << 12) |
  242. ((view.getUint8(++i) & 0x3f) << 6) |
  243. ((view.getUint8(++i) & 0x3f) << 0);
  244. if (chr >= 0x010000) { // surrogate pair
  245. chr -= 0x010000;
  246. string += String.fromCharCode((chr >>> 10) + 0xD800, (chr & 0x3FF) + 0xDC00);
  247. }
  248. else {
  249. string += String.fromCharCode(chr);
  250. }
  251. continue;
  252. }
  253. throw new Error('Invalid byte ' + byte.toString(16));
  254. }
  255. return string;
  256. }
  257. Decoder.prototype._array = function (length) {
  258. var value = new Array(length);
  259. for (var i = 0; i < length; i++) {
  260. value[i] = this._parse();
  261. }
  262. return value;
  263. };
  264. Decoder.prototype._map = function (length) {
  265. var key = '', value = {};
  266. for (var i = 0; i < length; i++) {
  267. key = this._parse();
  268. value[key] = this._parse();
  269. }
  270. return value;
  271. };
  272. Decoder.prototype._str = function (length) {
  273. var value = utf8Read(this._view, this._offset, length);
  274. this._offset += length;
  275. return value;
  276. };
  277. Decoder.prototype._bin = function (length) {
  278. var value = this._buffer.slice(this._offset, this._offset + length);
  279. this._offset += length;
  280. return value;
  281. };
  282. Decoder.prototype._parse = function () {
  283. var prefix = this._view.getUint8(this._offset++);
  284. var value, length = 0, type = 0, hi = 0, lo = 0;
  285. if (prefix < 0xc0) {
  286. // positive fixint
  287. if (prefix < 0x80) {
  288. return prefix;
  289. }
  290. // fixmap
  291. if (prefix < 0x90) {
  292. return this._map(prefix & 0x0f);
  293. }
  294. // fixarray
  295. if (prefix < 0xa0) {
  296. return this._array(prefix & 0x0f);
  297. }
  298. // fixstr
  299. return this._str(prefix & 0x1f);
  300. }
  301. // negative fixint
  302. if (prefix > 0xdf) {
  303. return (0xff - prefix + 1) * -1;
  304. }
  305. switch (prefix) {
  306. // nil
  307. case 0xc0:
  308. return null;
  309. // false
  310. case 0xc2:
  311. return false;
  312. // true
  313. case 0xc3:
  314. return true;
  315. // bin
  316. case 0xc4:
  317. length = this._view.getUint8(this._offset);
  318. this._offset += 1;
  319. return this._bin(length);
  320. case 0xc5:
  321. length = this._view.getUint16(this._offset);
  322. this._offset += 2;
  323. return this._bin(length);
  324. case 0xc6:
  325. length = this._view.getUint32(this._offset);
  326. this._offset += 4;
  327. return this._bin(length);
  328. // ext
  329. case 0xc7:
  330. length = this._view.getUint8(this._offset);
  331. type = this._view.getInt8(this._offset + 1);
  332. this._offset += 2;
  333. return [type, this._bin(length)];
  334. case 0xc8:
  335. length = this._view.getUint16(this._offset);
  336. type = this._view.getInt8(this._offset + 2);
  337. this._offset += 3;
  338. return [type, this._bin(length)];
  339. case 0xc9:
  340. length = this._view.getUint32(this._offset);
  341. type = this._view.getInt8(this._offset + 4);
  342. this._offset += 5;
  343. return [type, this._bin(length)];
  344. // float
  345. case 0xca:
  346. value = this._view.getFloat32(this._offset);
  347. this._offset += 4;
  348. return value;
  349. case 0xcb:
  350. value = this._view.getFloat64(this._offset);
  351. this._offset += 8;
  352. return value;
  353. // uint
  354. case 0xcc:
  355. value = this._view.getUint8(this._offset);
  356. this._offset += 1;
  357. return value;
  358. case 0xcd:
  359. value = this._view.getUint16(this._offset);
  360. this._offset += 2;
  361. return value;
  362. case 0xce:
  363. value = this._view.getUint32(this._offset);
  364. this._offset += 4;
  365. return value;
  366. case 0xcf:
  367. hi = this._view.getUint32(this._offset) * Math.pow(2, 32);
  368. lo = this._view.getUint32(this._offset + 4);
  369. this._offset += 8;
  370. return hi + lo;
  371. // int
  372. case 0xd0:
  373. value = this._view.getInt8(this._offset);
  374. this._offset += 1;
  375. return value;
  376. case 0xd1:
  377. value = this._view.getInt16(this._offset);
  378. this._offset += 2;
  379. return value;
  380. case 0xd2:
  381. value = this._view.getInt32(this._offset);
  382. this._offset += 4;
  383. return value;
  384. case 0xd3:
  385. hi = this._view.getInt32(this._offset) * Math.pow(2, 32);
  386. lo = this._view.getUint32(this._offset + 4);
  387. this._offset += 8;
  388. return hi + lo;
  389. // fixext
  390. case 0xd4:
  391. type = this._view.getInt8(this._offset);
  392. this._offset += 1;
  393. if (type === 0x00) {
  394. this._offset += 1;
  395. return void 0;
  396. }
  397. return [type, this._bin(1)];
  398. case 0xd5:
  399. type = this._view.getInt8(this._offset);
  400. this._offset += 1;
  401. return [type, this._bin(2)];
  402. case 0xd6:
  403. type = this._view.getInt8(this._offset);
  404. this._offset += 1;
  405. return [type, this._bin(4)];
  406. case 0xd7:
  407. type = this._view.getInt8(this._offset);
  408. this._offset += 1;
  409. if (type === 0x00) {
  410. hi = this._view.getInt32(this._offset) * Math.pow(2, 32);
  411. lo = this._view.getUint32(this._offset + 4);
  412. this._offset += 8;
  413. return new Date(hi + lo);
  414. }
  415. return [type, this._bin(8)];
  416. case 0xd8:
  417. type = this._view.getInt8(this._offset);
  418. this._offset += 1;
  419. return [type, this._bin(16)];
  420. // str
  421. case 0xd9:
  422. length = this._view.getUint8(this._offset);
  423. this._offset += 1;
  424. return this._str(length);
  425. case 0xda:
  426. length = this._view.getUint16(this._offset);
  427. this._offset += 2;
  428. return this._str(length);
  429. case 0xdb:
  430. length = this._view.getUint32(this._offset);
  431. this._offset += 4;
  432. return this._str(length);
  433. // array
  434. case 0xdc:
  435. length = this._view.getUint16(this._offset);
  436. this._offset += 2;
  437. return this._array(length);
  438. case 0xdd:
  439. length = this._view.getUint32(this._offset);
  440. this._offset += 4;
  441. return this._array(length);
  442. // map
  443. case 0xde:
  444. length = this._view.getUint16(this._offset);
  445. this._offset += 2;
  446. return this._map(length);
  447. case 0xdf:
  448. length = this._view.getUint32(this._offset);
  449. this._offset += 4;
  450. return this._map(length);
  451. }
  452. throw new Error('Could not parse');
  453. };
  454. function decode$1(buffer, offset) {
  455. if (offset === void 0) { offset = 0; }
  456. var decoder = new Decoder(buffer, offset);
  457. var value = decoder._parse();
  458. if (decoder._offset !== buffer.byteLength) {
  459. throw new Error((buffer.byteLength - decoder._offset) + ' trailing bytes');
  460. }
  461. return value;
  462. }
  463. //
  464. // ENCODER
  465. //
  466. function utf8Write(view, offset, str) {
  467. var c = 0;
  468. for (var i = 0, l = str.length; i < l; i++) {
  469. c = str.charCodeAt(i);
  470. if (c < 0x80) {
  471. view.setUint8(offset++, c);
  472. }
  473. else if (c < 0x800) {
  474. view.setUint8(offset++, 0xc0 | (c >> 6));
  475. view.setUint8(offset++, 0x80 | (c & 0x3f));
  476. }
  477. else if (c < 0xd800 || c >= 0xe000) {
  478. view.setUint8(offset++, 0xe0 | (c >> 12));
  479. view.setUint8(offset++, 0x80 | (c >> 6) & 0x3f);
  480. view.setUint8(offset++, 0x80 | (c & 0x3f));
  481. }
  482. else {
  483. i++;
  484. c = 0x10000 + (((c & 0x3ff) << 10) | (str.charCodeAt(i) & 0x3ff));
  485. view.setUint8(offset++, 0xf0 | (c >> 18));
  486. view.setUint8(offset++, 0x80 | (c >> 12) & 0x3f);
  487. view.setUint8(offset++, 0x80 | (c >> 6) & 0x3f);
  488. view.setUint8(offset++, 0x80 | (c & 0x3f));
  489. }
  490. }
  491. }
  492. function utf8Length(str) {
  493. var c = 0, length = 0;
  494. for (var i = 0, l = str.length; i < l; i++) {
  495. c = str.charCodeAt(i);
  496. if (c < 0x80) {
  497. length += 1;
  498. }
  499. else if (c < 0x800) {
  500. length += 2;
  501. }
  502. else if (c < 0xd800 || c >= 0xe000) {
  503. length += 3;
  504. }
  505. else {
  506. i++;
  507. length += 4;
  508. }
  509. }
  510. return length;
  511. }
  512. function _encode(bytes, defers, value) {
  513. var type = typeof value, i = 0, l = 0, hi = 0, lo = 0, length = 0, size = 0;
  514. if (type === 'string') {
  515. length = utf8Length(value);
  516. // fixstr
  517. if (length < 0x20) {
  518. bytes.push(length | 0xa0);
  519. size = 1;
  520. }
  521. // str 8
  522. else if (length < 0x100) {
  523. bytes.push(0xd9, length);
  524. size = 2;
  525. }
  526. // str 16
  527. else if (length < 0x10000) {
  528. bytes.push(0xda, length >> 8, length);
  529. size = 3;
  530. }
  531. // str 32
  532. else if (length < 0x100000000) {
  533. bytes.push(0xdb, length >> 24, length >> 16, length >> 8, length);
  534. size = 5;
  535. }
  536. else {
  537. throw new Error('String too long');
  538. }
  539. defers.push({ _str: value, _length: length, _offset: bytes.length });
  540. return size + length;
  541. }
  542. if (type === 'number') {
  543. // TODO: encode to float 32?
  544. // float 64
  545. if (Math.floor(value) !== value || !isFinite(value)) {
  546. bytes.push(0xcb);
  547. defers.push({ _float: value, _length: 8, _offset: bytes.length });
  548. return 9;
  549. }
  550. if (value >= 0) {
  551. // positive fixnum
  552. if (value < 0x80) {
  553. bytes.push(value);
  554. return 1;
  555. }
  556. // uint 8
  557. if (value < 0x100) {
  558. bytes.push(0xcc, value);
  559. return 2;
  560. }
  561. // uint 16
  562. if (value < 0x10000) {
  563. bytes.push(0xcd, value >> 8, value);
  564. return 3;
  565. }
  566. // uint 32
  567. if (value < 0x100000000) {
  568. bytes.push(0xce, value >> 24, value >> 16, value >> 8, value);
  569. return 5;
  570. }
  571. // uint 64
  572. hi = (value / Math.pow(2, 32)) >> 0;
  573. lo = value >>> 0;
  574. bytes.push(0xcf, hi >> 24, hi >> 16, hi >> 8, hi, lo >> 24, lo >> 16, lo >> 8, lo);
  575. return 9;
  576. }
  577. else {
  578. // negative fixnum
  579. if (value >= -0x20) {
  580. bytes.push(value);
  581. return 1;
  582. }
  583. // int 8
  584. if (value >= -0x80) {
  585. bytes.push(0xd0, value);
  586. return 2;
  587. }
  588. // int 16
  589. if (value >= -0x8000) {
  590. bytes.push(0xd1, value >> 8, value);
  591. return 3;
  592. }
  593. // int 32
  594. if (value >= -0x80000000) {
  595. bytes.push(0xd2, value >> 24, value >> 16, value >> 8, value);
  596. return 5;
  597. }
  598. // int 64
  599. hi = Math.floor(value / Math.pow(2, 32));
  600. lo = value >>> 0;
  601. bytes.push(0xd3, hi >> 24, hi >> 16, hi >> 8, hi, lo >> 24, lo >> 16, lo >> 8, lo);
  602. return 9;
  603. }
  604. }
  605. if (type === 'object') {
  606. // nil
  607. if (value === null) {
  608. bytes.push(0xc0);
  609. return 1;
  610. }
  611. if (Array.isArray(value)) {
  612. length = value.length;
  613. // fixarray
  614. if (length < 0x10) {
  615. bytes.push(length | 0x90);
  616. size = 1;
  617. }
  618. // array 16
  619. else if (length < 0x10000) {
  620. bytes.push(0xdc, length >> 8, length);
  621. size = 3;
  622. }
  623. // array 32
  624. else if (length < 0x100000000) {
  625. bytes.push(0xdd, length >> 24, length >> 16, length >> 8, length);
  626. size = 5;
  627. }
  628. else {
  629. throw new Error('Array too large');
  630. }
  631. for (i = 0; i < length; i++) {
  632. size += _encode(bytes, defers, value[i]);
  633. }
  634. return size;
  635. }
  636. // fixext 8 / Date
  637. if (value instanceof Date) {
  638. var time = value.getTime();
  639. hi = Math.floor(time / Math.pow(2, 32));
  640. lo = time >>> 0;
  641. bytes.push(0xd7, 0, hi >> 24, hi >> 16, hi >> 8, hi, lo >> 24, lo >> 16, lo >> 8, lo);
  642. return 10;
  643. }
  644. if (value instanceof ArrayBuffer) {
  645. length = value.byteLength;
  646. // bin 8
  647. if (length < 0x100) {
  648. bytes.push(0xc4, length);
  649. size = 2;
  650. }
  651. else
  652. // bin 16
  653. if (length < 0x10000) {
  654. bytes.push(0xc5, length >> 8, length);
  655. size = 3;
  656. }
  657. else
  658. // bin 32
  659. if (length < 0x100000000) {
  660. bytes.push(0xc6, length >> 24, length >> 16, length >> 8, length);
  661. size = 5;
  662. }
  663. else {
  664. throw new Error('Buffer too large');
  665. }
  666. defers.push({ _bin: value, _length: length, _offset: bytes.length });
  667. return size + length;
  668. }
  669. if (typeof value.toJSON === 'function') {
  670. return _encode(bytes, defers, value.toJSON());
  671. }
  672. var keys = [], key = '';
  673. var allKeys = Object.keys(value);
  674. for (i = 0, l = allKeys.length; i < l; i++) {
  675. key = allKeys[i];
  676. if (typeof value[key] !== 'function') {
  677. keys.push(key);
  678. }
  679. }
  680. length = keys.length;
  681. // fixmap
  682. if (length < 0x10) {
  683. bytes.push(length | 0x80);
  684. size = 1;
  685. }
  686. // map 16
  687. else if (length < 0x10000) {
  688. bytes.push(0xde, length >> 8, length);
  689. size = 3;
  690. }
  691. // map 32
  692. else if (length < 0x100000000) {
  693. bytes.push(0xdf, length >> 24, length >> 16, length >> 8, length);
  694. size = 5;
  695. }
  696. else {
  697. throw new Error('Object too large');
  698. }
  699. for (i = 0; i < length; i++) {
  700. key = keys[i];
  701. size += _encode(bytes, defers, key);
  702. size += _encode(bytes, defers, value[key]);
  703. }
  704. return size;
  705. }
  706. // false/true
  707. if (type === 'boolean') {
  708. bytes.push(value ? 0xc3 : 0xc2);
  709. return 1;
  710. }
  711. // fixext 1 / undefined
  712. if (type === 'undefined') {
  713. bytes.push(0xd4, 0, 0);
  714. return 3;
  715. }
  716. throw new Error('Could not encode');
  717. }
  718. function encode$1(value) {
  719. var bytes = [];
  720. var defers = [];
  721. var size = _encode(bytes, defers, value);
  722. var buf = new ArrayBuffer(size);
  723. var view = new DataView(buf);
  724. var deferIndex = 0;
  725. var deferWritten = 0;
  726. var nextOffset = -1;
  727. if (defers.length > 0) {
  728. nextOffset = defers[0]._offset;
  729. }
  730. var defer, deferLength = 0, offset = 0;
  731. for (var i = 0, l = bytes.length; i < l; i++) {
  732. view.setUint8(deferWritten + i, bytes[i]);
  733. if (i + 1 !== nextOffset) {
  734. continue;
  735. }
  736. defer = defers[deferIndex];
  737. deferLength = defer._length;
  738. offset = deferWritten + nextOffset;
  739. if (defer._bin) {
  740. var bin = new Uint8Array(defer._bin);
  741. for (var j = 0; j < deferLength; j++) {
  742. view.setUint8(offset + j, bin[j]);
  743. }
  744. }
  745. else if (defer._str) {
  746. utf8Write(view, offset, defer._str);
  747. }
  748. else if (defer._float !== undefined) {
  749. view.setFloat64(offset, defer._float);
  750. }
  751. deferIndex++;
  752. deferWritten += deferLength;
  753. if (defers[deferIndex]) {
  754. nextOffset = defers[deferIndex]._offset;
  755. }
  756. }
  757. return buf;
  758. }
  759.  
  760. function decodeExport(packet) {
  761. const u8arr = new Uint8Array(packet);
  762. const bytes = Array.from(u8arr);
  763. const prefix = bytes[0];
  764.  
  765. if(prefix == Protocol.ROOM_DATA) {
  766. let it = { offset: 1 };
  767.  
  768. stringCheck(bytes, it) ? string(bytes, it) : number(bytes, it);
  769. let parsed = decode$1(packet, it.offset);
  770. return parsed
  771. } else {
  772. return null; // hopefully isn't important lol
  773. }
  774. }
  775.  
  776. function encodeExport(channel, packet) {
  777. let header = [Protocol.ROOM_DATA];
  778. let channelEncoded = encode$1(channel);
  779. let packetEncoded = encode$1(packet);
  780.  
  781. // combine the arraybuffers
  782. let combined = new Uint8Array(channelEncoded.byteLength + packetEncoded.byteLength + header.length);
  783. combined.set(header);
  784. combined.set(new Uint8Array(channelEncoded), header.length);
  785. combined.set(new Uint8Array(packetEncoded), header.length + channelEncoded.byteLength);
  786.  
  787. return combined.buffer
  788. }
  789.  
  790. var colyseus = {
  791. decode: decodeExport,
  792. encode: encodeExport
  793. };
  794.  
  795. // this code was stolen from the original Gimkit Util extension
  796. function n(t, e, n) {
  797. for (var i = 0, s = 0, o = n.length; s < o; s++)(i = n.charCodeAt(s)) < 128 ? t.setUint8(e++, i) : (i < 2048 ? t.setUint8(e++, 192 | i >> 6) : (i < 55296 || 57344 <= i ? t.setUint8(e++, 224 | i >> 12) : (s++, i = 65536 + ((1023 & i) << 10 | 1023 & n.charCodeAt(s)), t.setUint8(e++, 240 | i >> 18), t.setUint8(e++, 128 | i >> 12 & 63)), t.setUint8(e++, 128 | i >> 6 & 63)), t.setUint8(e++, 128 | 63 & i));
  798. }
  799.  
  800. function encode(t, e, s) {
  801. const o = {
  802. type: 2,
  803. data: ["blueboat_SEND_MESSAGE", {
  804. room: s,
  805. key: t,
  806. data: e
  807. }],
  808. options: {
  809. compress: !0
  810. },
  811. nsp: "/"
  812. };
  813. return function(t) {
  814. var e = [],
  815. i = [],
  816. s = function t(e, n, i) {
  817. var s = typeof i,
  818. o = 0,
  819. r = 0,
  820. a = 0,
  821. c = 0,
  822. l = 0,
  823. u = 0;
  824. if ("string" === s) {
  825. if ((l = function(t) {
  826. for (var e = 0, n = 0, i = 0, s = t.length; i < s; i++)(e = t.charCodeAt(i)) < 128 ? n += 1 : e < 2048 ? n += 2 : e < 55296 || 57344 <= e ? n += 3 : (i++, n += 4);
  827. return n
  828. }(i)) < 32) e.push(160 | l), u = 1;
  829. else if (l < 256) e.push(217, l), u = 2;
  830. else if (l < 65536) e.push(218, l >> 8, l), u = 3;
  831. else {
  832. if (!(l < 4294967296)) throw new Error("String too long");
  833. e.push(219, l >> 24, l >> 16, l >> 8, l), u = 5;
  834. }
  835. return n.push({
  836. h: i,
  837. u: l,
  838. t: e.length
  839. }), u + l
  840. }
  841. if ("number" === s) return Math.floor(i) === i && isFinite(i) ? 0 <= i ? i < 128 ? (e.push(i), 1) : i < 256 ? (e.push(204, i), 2) : i < 65536 ? (e.push(205, i >> 8, i), 3) : i < 4294967296 ? (e.push(206, i >> 24, i >> 16, i >> 8, i), 5) : (a = i / Math.pow(2, 32) >> 0, c = i >>> 0, e.push(207, a >> 24, a >> 16, a >> 8, a, c >> 24, c >> 16, c >> 8, c), 9) : -32 <= i ? (e.push(i), 1) : -128 <= i ? (e.push(208, i), 2) : -32768 <= i ? (e.push(209, i >> 8, i), 3) : -2147483648 <= i ? (e.push(210, i >> 24, i >> 16, i >> 8, i), 5) : (a = Math.floor(i / Math.pow(2, 32)), c = i >>> 0, e.push(211, a >> 24, a >> 16, a >> 8, a, c >> 24, c >> 16, c >> 8, c), 9) : (e.push(203), n.push({
  842. o: i,
  843. u: 8,
  844. t: e.length
  845. }), 9);
  846. if ("object" === s) {
  847. if (null === i) return e.push(192), 1;
  848. if (Array.isArray(i)) {
  849. if ((l = i.length) < 16) e.push(144 | l), u = 1;
  850. else if (l < 65536) e.push(220, l >> 8, l), u = 3;
  851. else {
  852. if (!(l < 4294967296)) throw new Error("Array too large");
  853. e.push(221, l >> 24, l >> 16, l >> 8, l), u = 5;
  854. }
  855. for (o = 0; o < l; o++) u += t(e, n, i[o]);
  856. return u
  857. }
  858. if (i instanceof Date) {
  859. var h = i.getTime();
  860. return a = Math.floor(h / Math.pow(2, 32)), c = h >>> 0, e.push(215, 0, a >> 24, a >> 16, a >> 8, a, c >> 24, c >> 16, c >> 8, c), 10
  861. }
  862. if (i instanceof ArrayBuffer) {
  863. if ((l = i.byteLength) < 256) e.push(196, l), u = 2;
  864. else if (l < 65536) e.push(197, l >> 8, l), u = 3;
  865. else {
  866. if (!(l < 4294967296)) throw new Error("Buffer too large");
  867. e.push(198, l >> 24, l >> 16, l >> 8, l), u = 5;
  868. }
  869. return n.push({
  870. l: i,
  871. u: l,
  872. t: e.length
  873. }), u + l
  874. }
  875. if ("function" == typeof i.toJSON) return t(e, n, i.toJSON());
  876. var d = [],
  877. f = "",
  878. p = Object.keys(i);
  879. for (o = 0, r = p.length; o < r; o++) "function" != typeof i[f = p[o]] && d.push(f);
  880. if ((l = d.length) < 16) e.push(128 | l), u = 1;
  881. else if (l < 65536) e.push(222, l >> 8, l), u = 3;
  882. else {
  883. if (!(l < 4294967296)) throw new Error("Object too large");
  884. e.push(223, l >> 24, l >> 16, l >> 8, l), u = 5;
  885. }
  886. for (o = 0; o < l; o++) u += t(e, n, f = d[o]), u += t(e, n, i[f]);
  887. return u
  888. }
  889. if ("boolean" === s) return e.push(i ? 195 : 194), 1;
  890. if ("undefined" === s) return e.push(212, 0, 0), 3;
  891. throw new Error("Could not encode")
  892. }(e, i, t),
  893. o = new ArrayBuffer(s),
  894. r = new DataView(o),
  895. a = 0,
  896. c = 0,
  897. l = -1;
  898. 0 < i.length && (l = i[0].t);
  899. for (var u, h = 0, d = 0, f = 0, p = e.length; f < p; f++)
  900. if (r.setUint8(c + f, e[f]), f + 1 === l) {
  901. if (h = (u = i[a]).u, d = c + l, u.l)
  902. for (var g = new Uint8Array(u.l), E = 0; E < h; E++) r.setUint8(d + E, g[E]);
  903. else u.h ? n(r, d, u.h) : void 0 !== u.o && r.setFloat64(d, u.o);
  904. c += h, i[++a] && (l = i[a].t);
  905. } let y = Array.from(new Uint8Array(o));
  906. y.unshift(4);
  907. return new Uint8Array(y).buffer
  908. }(o)
  909. }
  910.  
  911. function decode(packet) {
  912. function e(t) {
  913. if (this.t = 0, t instanceof ArrayBuffer) this.i = t, this.s = new DataView(this.i);
  914. else {
  915. if (!ArrayBuffer.isView(t)) return null;
  916. this.i = t.buffer, this.s = new DataView(this.i, t.byteOffset, t.byteLength);
  917. }
  918. }
  919.  
  920. e.prototype.g = function(t) {
  921. for (var e = new Array(t), n = 0; n < t; n++) e[n] = this.v();
  922. return e
  923. }, e.prototype.M = function(t) {
  924. for (var e = {}, n = 0; n < t; n++) e[this.v()] = this.v();
  925. return e
  926. }, e.prototype.h = function(t) {
  927. var e = function(t, e, n) {
  928. for (var i = "", s = 0, o = e, r = e + n; o < r; o++) {
  929. var a = t.getUint8(o);
  930. if (0 != (128 & a))
  931. if (192 != (224 & a))
  932. if (224 != (240 & a)) {
  933. if (240 != (248 & a)) throw new Error("Invalid byte " + a.toString(16));
  934. 65536 <= (s = (7 & a) << 18 | (63 & t.getUint8(++o)) << 12 | (63 & t.getUint8(++o)) << 6 | (63 & t.getUint8(++o)) << 0) ? (s -= 65536, i += String.fromCharCode(55296 + (s >>> 10), 56320 + (1023 & s))) : i += String.fromCharCode(s);
  935. } else i += String.fromCharCode((15 & a) << 12 | (63 & t.getUint8(++o)) << 6 | (63 & t.getUint8(++o)) << 0);
  936. else i += String.fromCharCode((31 & a) << 6 | 63 & t.getUint8(++o));
  937. else i += String.fromCharCode(a);
  938. }
  939. return i
  940. }(this.s, this.t, t);
  941. return this.t += t, e
  942. }, e.prototype.l = function(t) {
  943. var e = this.i.slice(this.t, this.t + t);
  944. return this.t += t, e
  945. }, e.prototype.v = function() {
  946. if(!this.s) return null;
  947. var t, e = this.s.getUint8(this.t++),
  948. n = 0,
  949. i = 0,
  950. s = 0,
  951. o = 0;
  952. if (e < 192) return e < 128 ? e : e < 144 ? this.M(15 & e) : e < 160 ? this.g(15 & e) : this.h(31 & e);
  953. if (223 < e) return -1 * (255 - e + 1);
  954. switch (e) {
  955. case 192:
  956. return null;
  957. case 194:
  958. return !1;
  959. case 195:
  960. return !0;
  961. case 196:
  962. return n = this.s.getUint8(this.t), this.t += 1, this.l(n);
  963. case 197:
  964. return n = this.s.getUint16(this.t), this.t += 2, this.l(n);
  965. case 198:
  966. return n = this.s.getUint32(this.t), this.t += 4, this.l(n);
  967. case 199:
  968. return n = this.s.getUint8(this.t), i = this.s.getInt8(this.t + 1), this.t += 2, [i, this.l(n)];
  969. case 200:
  970. return n = this.s.getUint16(this.t), i = this.s.getInt8(this.t + 2), this.t += 3, [i, this.l(n)];
  971. case 201:
  972. return n = this.s.getUint32(this.t), i = this.s.getInt8(this.t + 4), this.t += 5, [i, this.l(n)];
  973. case 202:
  974. return t = this.s.getFloat32(this.t), this.t += 4, t;
  975. case 203:
  976. return t = this.s.getFloat64(this.t), this.t += 8, t;
  977. case 204:
  978. return t = this.s.getUint8(this.t), this.t += 1, t;
  979. case 205:
  980. return t = this.s.getUint16(this.t), this.t += 2, t;
  981. case 206:
  982. return t = this.s.getUint32(this.t), this.t += 4, t;
  983. case 207:
  984. return s = this.s.getUint32(this.t) * Math.pow(2, 32), o = this.s.getUint32(this.t + 4), this.t += 8, s + o;
  985. case 208:
  986. return t = this.s.getInt8(this.t), this.t += 1, t;
  987. case 209:
  988. return t = this.s.getInt16(this.t), this.t += 2, t;
  989. case 210:
  990. return t = this.s.getInt32(this.t), this.t += 4, t;
  991. case 211:
  992. return s = this.s.getInt32(this.t) * Math.pow(2, 32), o = this.s.getUint32(this.t + 4), this.t += 8, s + o;
  993. case 212:
  994. return i = this.s.getInt8(this.t), this.t += 1, 0 === i ? void(this.t += 1) : [i, this.l(1)];
  995. case 213:
  996. return i = this.s.getInt8(this.t), this.t += 1, [i, this.l(2)];
  997. case 214:
  998. return i = this.s.getInt8(this.t), this.t += 1, [i, this.l(4)];
  999. case 215:
  1000. return i = this.s.getInt8(this.t), this.t += 1, 0 === i ? (s = this.s.getInt32(this.t) * Math.pow(2, 32), o = this.s.getUint32(this.t + 4), this.t += 8, new Date(s + o)) : [i, this.l(8)];
  1001. case 216:
  1002. return i = this.s.getInt8(this.t), this.t += 1, [i, this.l(16)];
  1003. case 217:
  1004. return n = this.s.getUint8(this.t), this.t += 1, this.h(n);
  1005. case 218:
  1006. return n = this.s.getUint16(this.t), this.t += 2, this.h(n);
  1007. case 219:
  1008. return n = this.s.getUint32(this.t), this.t += 4, this.h(n);
  1009. case 220:
  1010. return n = this.s.getUint16(this.t), this.t += 2, this.g(n);
  1011. case 221:
  1012. return n = this.s.getUint32(this.t), this.t += 4, this.g(n);
  1013. case 222:
  1014. return n = this.s.getUint16(this.t), this.t += 2, this.M(n);
  1015. case 223:
  1016. return n = this.s.getUint32(this.t), this.t += 4, this.M(n)
  1017. }
  1018. throw new Error("Could not parse")
  1019. };
  1020.  
  1021. const q = function(t) {
  1022. var n = new e(t = t.slice(1)),
  1023. i = n.v();
  1024. if (n.t === t.byteLength) return i;
  1025. return null
  1026. }(packet);
  1027.  
  1028. return q?.data?.[1];
  1029. }
  1030.  
  1031. var blueboat = {
  1032. encode,
  1033. decode
  1034. };
  1035.  
  1036. function HexAlphaToRGBA(hex, alpha) {
  1037. let r = parseInt(hex.slice(1, 3), 16);
  1038. let g = parseInt(hex.slice(3, 5), 16);
  1039. let b = parseInt(hex.slice(5, 7), 16);
  1040. return `rgba(${r}, ${g}, ${b}, ${alpha})`;
  1041. }
  1042. function RGBAtoHexAlpha(rgba) {
  1043. let [r, g, b, a] = rgba.slice(5, -1).split(",").map(x => parseFloat(x.trim()));
  1044. let hex = `#${r.toString(16).padStart(2, "0")}${g.toString(16).padStart(2, "0")}${b.toString(16).padStart(2, "0")}`;
  1045. return [hex, a];
  1046. }
  1047. function parseChangePacket(packet) {
  1048. let returnVar = [];
  1049. for (let change of packet.changes) {
  1050. let data = {};
  1051. let keys = change[1].map((index) => packet.values[index]);
  1052. for (let i = 0; i < keys.length; i++) {
  1053. data[keys[i]] = change[2][i];
  1054. }
  1055. returnVar.push({
  1056. id: change[0],
  1057. data
  1058. });
  1059. }
  1060. return returnVar;
  1061. }
  1062.  
  1063. // @ts-ignore (can't be bothered to figure out how to import this)
  1064. class SocketHandler extends EventTarget {
  1065. constructor(cheat) {
  1066. super();
  1067. this.socket = null;
  1068. this.hasFired = false;
  1069. this.transportType = "unknown";
  1070. this.blueboatRoomId = null;
  1071. this.cheat = cheat;
  1072. }
  1073. getSocket() {
  1074. let handlerThis = this;
  1075. if (!Object.isFrozen(WebSocket)) {
  1076. // intercept any outgoing socket connections
  1077. WebSocket.prototype._send = WebSocket.prototype.send;
  1078. WebSocket.prototype.send = function (data) {
  1079. // if the url is a local url, don't intercept it
  1080. if (this.url.startsWith("ws://localhost"))
  1081. return this._send(data);
  1082. handlerThis.registerSocket(this);
  1083. if (!handlerThis.socket)
  1084. return;
  1085. handlerThis.socket._send(data);
  1086. // attempt to get the room id
  1087. if (handlerThis.transportType == "blueboat") {
  1088. let decoded = blueboat.decode(data);
  1089. if (decoded.roomId)
  1090. handlerThis.blueboatRoomId = decoded.roomId;
  1091. if (decoded.room)
  1092. handlerThis.blueboatRoomId = decoded.room;
  1093. if (!handlerThis.blueboatRoomId)
  1094. handlerThis.cheat.log("Room ID: ", handlerThis.blueboatRoomId);
  1095. }
  1096. };
  1097. }
  1098. else {
  1099. // periodically attempt to extract the socket, in case something failed
  1100. let tryGetSocket = setInterval(() => {
  1101. var _a, _b, _c, _d, _e;
  1102. let gotSocket = (_e = (_d = (_c = (_b = (_a = window === null || window === void 0 ? void 0 : window.stores) === null || _a === void 0 ? void 0 : _a.network) === null || _b === void 0 ? void 0 : _b.room) === null || _c === void 0 ? void 0 : _c.connection) === null || _d === void 0 ? void 0 : _d.transport) === null || _e === void 0 ? void 0 : _e.ws;
  1103. if (gotSocket) {
  1104. handlerThis.registerSocket(gotSocket);
  1105. clearInterval(tryGetSocket);
  1106. }
  1107. }, 100);
  1108. }
  1109. }
  1110. registerSocket(socket) {
  1111. if (this.hasFired)
  1112. return;
  1113. this.socket = socket;
  1114. this.hasFired = true;
  1115. this.dispatchEvent(new CustomEvent("socket", { detail: socket }));
  1116. // detect the transport type
  1117. if ("stores" in unsafeWindow)
  1118. this.transportType = "colyseus";
  1119. else
  1120. this.transportType = "blueboat";
  1121. let handlerThis = this;
  1122. socket.addEventListener("message", (e) => {
  1123. // decode the message
  1124. let decoded;
  1125. if (this.transportType == "colyseus")
  1126. decoded = colyseus.decode(e.data);
  1127. else
  1128. decoded = blueboat.decode(e.data);
  1129. if (!decoded)
  1130. return;
  1131. handlerThis.dispatchEvent(new CustomEvent("recieveMessage", { detail: decoded }));
  1132. if (typeof decoded != "object")
  1133. return;
  1134. if ('changes' in decoded) {
  1135. let parsed = parseChangePacket(decoded);
  1136. handlerThis.dispatchEvent(new CustomEvent("recieveChanges", { detail: parsed }));
  1137. }
  1138. });
  1139. }
  1140. sendData(channel, data) {
  1141. if (!this.socket)
  1142. return;
  1143. if (!this.blueboatRoomId && this.transportType == "blueboat")
  1144. return this.cheat.log("Room ID not found, can't send data");
  1145. let encoded;
  1146. if (this.transportType == "colyseus")
  1147. encoded = colyseus.encode(channel, data);
  1148. else
  1149. encoded = blueboat.encode(channel, data, this.blueboatRoomId);
  1150. this.socket.send(encoded);
  1151. }
  1152. }
  1153.  
  1154. class KeybindManager {
  1155. constructor() {
  1156. this.keys = new Set();
  1157. this.binds = [];
  1158. this.addListeners();
  1159. }
  1160. addListeners() {
  1161. window.addEventListener("keydown", (e) => {
  1162. this.keys.add(e.key.toLowerCase());
  1163. this.checkBinds(e);
  1164. });
  1165. window.addEventListener("keyup", (e) => {
  1166. this.keys.delete(e.key.toLowerCase());
  1167. });
  1168. window.addEventListener("blur", () => {
  1169. this.keys.clear();
  1170. });
  1171. }
  1172. checkBinds(e) {
  1173. var _a;
  1174. if (e.repeat)
  1175. return;
  1176. for (let bind of this.binds) {
  1177. if (!bind.keys.has(e.key.toLowerCase()))
  1178. continue;
  1179. if (bind.keys.size == 0)
  1180. continue;
  1181. // if the bind is exclusive, make sure no other keys are pressed
  1182. if (bind.exclusive && bind.keys.size != this.keys.size)
  1183. continue;
  1184. // check whether the keys in the bind are pressed
  1185. if (Array.from(bind.keys).every(key => this.keys.has(key))) {
  1186. (_a = bind.callback) === null || _a === void 0 ? void 0 : _a.call(bind);
  1187. }
  1188. }
  1189. }
  1190. registerBind(bind) {
  1191. if (this.binds.includes(bind))
  1192. return;
  1193. this.binds.push(bind);
  1194. }
  1195. removeBind(bind) {
  1196. if (!this.binds.includes(bind))
  1197. return;
  1198. this.binds.splice(this.binds.indexOf(bind), 1);
  1199. }
  1200. clearBinds() {
  1201. this.binds = [];
  1202. }
  1203. }
  1204.  
  1205. var css = "#gc_hud {\r\n position: absolute;\r\n top: 0;\r\n left: 0;\r\n width: 100%;\r\n height: 100%;\r\n z-index: 999999999999;\r\n pointer-events: none;\r\n color: var(--text-color);\r\n}\r\n\r\n#gc_hud .menu_controls {\r\n width: 100%;\r\n height: 20px;\r\n background-color: var(--menu-controls-bg-color);\r\n color: var(--menu-controls-text-color);\r\n border-radius: 5px 5px 0px 0px;\r\n text-align: center;\r\n position: relative;\r\n}\r\n\r\n#gc_hud .menu_minimizer {\r\n margin-left: 20px;\r\n margin-right: 20px;\r\n position: absolute;\r\n top: 0;\r\n right: 0;\r\n user-select: none;\r\n}\r\n\r\n#gc_hud .menu {\r\n pointer-events: auto;\r\n position: absolute;\r\n background-color: var(--menu-bg-color);\r\n display: inline-block;\r\n border-radius: 5px;\r\n overflow-x: hidden;\r\n overflow-y: hidden;\r\n resize: both;\r\n width: 300px;\r\n height: 200px;\r\n outline: 3px solid var(--menu-border-color);\r\n}\r\n\r\n#gc_hud .menu.minimized {\r\n height: 20px !important;\r\n overflow-y: hidden;\r\n resize: horizontal;\r\n}\r\n\r\n#gc_hud .group {\r\n margin: 0px;\r\n padding: 0px;\r\n width: 100%;\r\n /* allocate some space at the top and bottom */\r\n height: calc(100% - 40px); \r\n position: absolute;\r\n top: 20px;\r\n left: 0;\r\n display: flex;\r\n flex-direction: column;\r\n justify-content: flex-start;\r\n align-items: center;\r\n overflow-y: auto;\r\n overflow-x: hidden;\r\n}\r\n\r\n#gc_hud .button, #gc_hud .group_opener {\r\n background-color: var(--button-bg-color);\r\n border: 1px solid var(--button-border-color);\r\n}\r\n\r\n#gc_hud .toggle {\r\n background-color: var(--toggle-bg-color);\r\n border: 1px solid var(--toggle-border-color);\r\n}\r\n\r\n#gc_hud .button, #gc_hud .toggle, #gc_hud .group_opener {\r\n border-radius: 5px;\r\n padding: 5px;\r\n margin: 5px;\r\n cursor: pointer;\r\n width: 90%;\r\n transition: transform 0.2s ease-in-out;\r\n}\r\n\r\n/* make it bounce smaller when clicked */\r\n#gc_hud .button:active, #gc_hud .toggle:active, #gc_hud .group_opener:active {\r\n transform: scale(0.93);\r\n}\r\n\r\n#gc_hud .colorpicker {\r\n width: 100%;\r\n}\r\n\r\n#gc_hud .colorpicker_wrapper {\r\n width: 100%;\r\n display: flex;\r\n flex-direction: row;\r\n justify-content: space-around;\r\n align-items: center;\r\n margin: 5px;\r\n}\r\n\r\n#gc_hud .colorpicker_opacity_wrapper {\r\n display: flex;\r\n flex-direction: column;\r\n justify-content: space-around;\r\n align-items: center;\r\n}\r\n\r\n#gc_hud .colorpicker_preview {\r\n width: 50px;\r\n height: 50px;\r\n border-radius: 5px;\r\n opacity: 1;\r\n}\r\n\r\n#gc_hud .text {\r\n text-align: center;\r\n width: 100%;\r\n}\r\n\r\n#gc_hud .textinput_wrapper, #gc_hud .dropdown_wrapper, #gc_hud .slider_wrapper {\r\n width: 100%;\r\n display: flex;\r\n flex-direction: column;\r\n justify-content: space-around;\r\n align-items: center;\r\n}\r\n\r\n#gc_hud .textinput {\r\n width: 90%;\r\n border-radius: 5px;\r\n border: 1px solid var(--textinput-border-color);\r\n background-color: var(--textinput-bg-color);\r\n color: var(--text-color);\r\n padding: 5px;\r\n margin: 5px;\r\n}\r\n\r\n#gc_hud .dropdown {\r\n width: 90%;\r\n border-radius: 5px;\r\n border: 1px solid var(--dropdown-border-color);\r\n background-color: var(--dropdown-bg-color);\r\n color: var(--text-color);\r\n padding: 5px;\r\n margin: 5px;\r\n}\r\n\r\n#gc_hud .toggle_wrapper, #gc_hud .button_wrapper {\r\n width: 90%;\r\n display: flex;\r\n flex-direction: row;\r\n justify-content: space-around;\r\n align-items: center;\r\n padding: 0px;\r\n}\r\n\r\n#gc_hud .toggle, #gc_hud .button {\r\n /* make it take up as much space as possible */\r\n width: 100%;\r\n margin-left: 0px;\r\n margin-right: 0px;\r\n}\r\n\r\n#gc_hud .keybind_opener {\r\n width: 30px;\r\n height: 30px;\r\n font-size: 30px;\r\n margin-left: 10px;\r\n}\r\n\r\n#gc_hud .keybind_editor_wrapper {\r\n background-color: var(--keybind-editor-bg-color);\r\n border: 3px solid var(--keybind-editor-border-color);\r\n border-radius: 8px;\r\n}\r\n\r\n#gc_hud .keybind_editor {\r\n width: 50vw;\r\n height: 50vh;\r\n display: flex;\r\n flex-direction: column;\r\n justify-content: space-around;\r\n align-items: center;\r\n color: var(--text-color);\r\n}\r\n\r\n#gc_hud .close {\r\n position: absolute;\r\n top: 0;\r\n right: 0;\r\n width: 20px;\r\n height: 20px;\r\n font-size: 20px;\r\n cursor: pointer;\r\n user-select: none;\r\n}\r\n\r\n#gc_hud .keybind_title {\r\n font-size: 40px;\r\n text-align: center;\r\n}\r\n\r\n#gc_hud .keybind_controls {\r\n width: 100%;\r\n display: flex;\r\n flex-direction: row;\r\n justify-content: space-around;\r\n align-items: center;\r\n}\r\n\r\n#gc_hud .keybind_display {\r\n border: 3px solid white;\r\n min-width: 300px;\r\n border-radius: 5px;\r\n height: 50px;\r\n text-align: center;\r\n display: flex;\r\n justify-content: center;\r\n align-items: center;\r\n cursor: pointer;\r\n}\r\n\r\n#gc_hud .keybind_exclusive {\r\n display: flex;\r\n}\r\n\r\n#gc_hud .keybind_exclusive .text {\r\n margin-right: 10px;\r\n}\r\n\r\n#gc_hud .keybind_editor .action {\r\n cursor: pointer;\r\n}\r\n\r\n#gc_hud .slider {\r\n width: 90%;\r\n margin: 5px;\r\n}\r\n\r\n.gc_overlay_canvas {\r\n position: absolute;\r\n top: 0;\r\n left: 0;\r\n width: 100vw;\r\n height: 100vh;\r\n z-index: 9999;\r\n pointer-events: none;\r\n}\r\n\r\n@keyframes slide_out_left {\r\n 0% {\r\n transform: translateX(0);\r\n opacity: 1;\r\n pointer-events: all;\r\n }\r\n\r\n 100% {\r\n transform: translateX(-100%);\r\n opacity: 0;\r\n pointer-events: none;\r\n }\r\n}\r\n\r\n@keyframes slide_out_right {\r\n 0% {\r\n transform: translateX(0);\r\n opacity: 1;\r\n pointer-events: all;\r\n }\r\n\r\n 100% {\r\n transform: translateX(100%);\r\n opacity: 0;\r\n pointer-events: none;\r\n }\r\n}\r\n\r\n@keyframes slide_in_left {\r\n 0% {\r\n transform: translateX(-100%);\r\n opacity: 0;\r\n pointer-events: none;\r\n }\r\n\r\n 100% {\r\n transform: translateX(0);\r\n opacity: 1;\r\n pointer-events: all;\r\n }\r\n}\r\n\r\n@keyframes slide_in_right {\r\n 0% {\r\n transform: translateX(100%);\r\n opacity: 0;\r\n pointer-events: none;\r\n }\r\n\r\n 100% {\r\n transform: translateX(0);\r\n opacity: 1;\r\n pointer-events: all;\r\n }\r\n}\r\n\r\n@keyframes idle {}";
  1206.  
  1207. class HudElement extends EventTarget {
  1208. // any is used to avoid circular dependencies
  1209. constructor(group, options) {
  1210. super();
  1211. this.group = null;
  1212. this.options = null;
  1213. this.element = null;
  1214. this.type = 'element';
  1215. this.group = group;
  1216. this.options = options;
  1217. }
  1218. remove() {
  1219. var _a;
  1220. (_a = this.element) === null || _a === void 0 ? void 0 : _a.remove();
  1221. this.group.elements.splice(this.group.elements.indexOf(this), 1);
  1222. }
  1223. }
  1224.  
  1225. class Text extends HudElement {
  1226. constructor(group, options) {
  1227. super(group, options);
  1228. this.type = "text";
  1229. this.element = document.createElement("div");
  1230. this.element.classList.add("text");
  1231. this.element.innerText = this.options.text;
  1232. }
  1233. set text(text) {
  1234. this.element.innerText = text;
  1235. }
  1236. get text() {
  1237. return this.element.innerText;
  1238. }
  1239. }
  1240.  
  1241. class GroupOpener extends HudElement {
  1242. constructor(group, options) {
  1243. super(group, options);
  1244. this.type = "groupOpener";
  1245. this.element = document.createElement("button");
  1246. this.element.classList.add("group_opener");
  1247. this.element.innerText = this.options.text;
  1248. this.element.addEventListener("click", () => {
  1249. var _a;
  1250. let direction = (_a = this.options.direction) !== null && _a !== void 0 ? _a : "right";
  1251. let oppositeDirection = direction == "right" ? "left" : "right";
  1252. // open the group
  1253. this.group.slide("out", direction);
  1254. let groupToOpen = this.group.menu.getAnyGroup(this.options.openGroup);
  1255. if (!groupToOpen)
  1256. return;
  1257. groupToOpen.slide("in", oppositeDirection);
  1258. });
  1259. }
  1260. set text(text) {
  1261. this.element.innerText = text;
  1262. }
  1263. get text() {
  1264. return this.element.innerText;
  1265. }
  1266. }
  1267.  
  1268. class ColorPicker extends HudElement {
  1269. constructor(group, options) {
  1270. var _a, _b;
  1271. super(group, options);
  1272. this.opacitySlider = null;
  1273. this.colorPicker = null;
  1274. this.preview = null;
  1275. this.type = "colorpicker";
  1276. // create the element
  1277. let element = document.createElement("div");
  1278. element.innerHTML = `
  1279. <div class="text">${this.options.text}</div>
  1280. <div class="colorpicker_wrapper">
  1281. <div class="colorpicker_opacity_wrapper">
  1282. <div class="text">Opacity</div>
  1283. <input type="range" min="0" max="255" value="255" class="colorpicker_opacity">
  1284. </div>
  1285. <input type="color" value="#ffffff" class="colorpicker_color">
  1286. <div class="colorpicker_preview"></div>
  1287. </div>
  1288. `;
  1289. element.classList.add("colorpicker");
  1290. this.opacitySlider = element.querySelector(".colorpicker_opacity");
  1291. this.colorPicker = element.querySelector(".colorpicker_color");
  1292. this.preview = element.querySelector(".colorpicker_preview");
  1293. if (this.options.bindVar)
  1294. this.color = window.cheat.hud.syncedVars.get("cssVars").get(this.options.bindVar);
  1295. else if (this.options.color)
  1296. this.color = this.options.color;
  1297. // prevent the menu from being dragged when the slider is moved
  1298. this.opacitySlider.addEventListener("mousedown", (e) => { e.stopPropagation(); });
  1299. (_a = this.opacitySlider) === null || _a === void 0 ? void 0 : _a.addEventListener("input", () => { this.updatePreview(); });
  1300. (_b = this.colorPicker) === null || _b === void 0 ? void 0 : _b.addEventListener("input", () => { this.updatePreview(); });
  1301. this.element = element;
  1302. this.updatePreview();
  1303. }
  1304. updatePreview() {
  1305. let color = this.colorPicker.value;
  1306. let opacity = parseInt(this.opacitySlider.value);
  1307. this.preview.style.backgroundColor = color;
  1308. this.preview.style.opacity = `${opacity / 255}`;
  1309. if (this.options.bindVar) {
  1310. window.cheat.hud.updateCssVar(this.options.bindVar, this.color);
  1311. }
  1312. this.dispatchEvent(new CustomEvent("change", {
  1313. detail: this.color
  1314. }));
  1315. }
  1316. set color(color) {
  1317. let [hex, alpha] = RGBAtoHexAlpha(color);
  1318. this.colorPicker.value = hex;
  1319. this.opacitySlider.value = `${255 * alpha}`;
  1320. this.updatePreview();
  1321. }
  1322. get color() {
  1323. let color = this.colorPicker.value;
  1324. let opacity = parseInt(this.opacitySlider.value);
  1325. let rgba = HexAlphaToRGBA(color, opacity / 255);
  1326. return rgba;
  1327. }
  1328. }
  1329.  
  1330. function keyboard() {
  1331. return (new DOMParser().parseFromString("<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 50 40\"><rect width=\"40\" height=\"26\" x=\"4\" y=\"10\" rx=\"2.038\" ry=\"2.234\" style=\"fill:#000;fill-opacity:1;fill-rule:evenodd;stroke:#fff;stroke-width:8;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none\"/><rect width=\"40\" height=\"26\" x=\"4\" y=\"10\" rx=\"2.038\" ry=\"2.234\" style=\"fill:#000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1\"/><path d=\"M14 30h19M7 30h5M35 30h6M7 16h4M13 16h4M19 16h4M25 16h4M31 16h4M34 23h4M28 23h4M22 23h4M16 23h4M37 16h4M10 23h4\" style=\"fill:none;fill-opacity:.75;fill-rule:evenodd;stroke:#fff;stroke-width:4;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1\"/></svg>", 'image/svg+xml')).firstChild;
  1332. }
  1333.  
  1334. // @ts-ignore
  1335. class KeybindEditor {
  1336. constructor(options) {
  1337. var _a;
  1338. this.capturing = false;
  1339. this.keys = new Set();
  1340. this.actionState = "start";
  1341. this.type = "keybindEditor";
  1342. this.options = options;
  1343. this.keybindOpener = keyboard();
  1344. this.keybindOpener.classList.add("keybind_opener");
  1345. this.keybindEditor = document.createElement("dialog");
  1346. this.keybindEditor.classList.add("keybind_editor_wrapper");
  1347. this.keybindEditor.innerHTML = `
  1348. <div class="keybind_editor">
  1349. <div class="close">x</div>
  1350. <h1 class="keybind_title">${options.title}</h1>
  1351. <div class="keybind_controls">
  1352. <div class="keybind_display"></div>
  1353. <div class="keybind_exclusive">
  1354. <div class="text">Exclusive?</div>
  1355. <input type="checkbox" class="exclusive" />
  1356. </div>
  1357. <div class="action">Start Capture</div>
  1358. </div>
  1359. </div>
  1360. `;
  1361. let bindExclusive = (_a = options.exclusive) !== null && _a !== void 0 ? _a : false;
  1362. let existingKeybind = window.cheat.hud.syncedVars.get("keybinds").get(options.id);
  1363. if (existingKeybind) {
  1364. this.keys = new Set(existingKeybind.keys);
  1365. bindExclusive = existingKeybind.exclusive;
  1366. }
  1367. else if (options.keys)
  1368. this.keys = options.keys;
  1369. if (bindExclusive)
  1370. this.keybindEditor.querySelector(".exclusive").setAttribute("checked", "true");
  1371. this.bind = {
  1372. keys: this.keys,
  1373. exclusive: bindExclusive,
  1374. callback: options.callback
  1375. };
  1376. window.cheat.keybindManager.registerBind(this.bind);
  1377. this.updateAction();
  1378. this.updateDisplay();
  1379. this.addEventListeners();
  1380. }
  1381. addEventListeners() {
  1382. let action = this.keybindEditor.querySelector(".action");
  1383. let close = this.keybindEditor.querySelector(".close");
  1384. let display = this.keybindEditor.querySelector(".keybind_display");
  1385. let exclusive = this.keybindEditor.querySelector(".exclusive");
  1386. this.keybindOpener.addEventListener("click", () => {
  1387. this.keybindEditor.showModal();
  1388. });
  1389. // prevent the menu from being dragged by the dialog
  1390. this.keybindEditor.addEventListener("mousedown", (e) => {
  1391. e.stopPropagation();
  1392. if (!this.capturing)
  1393. return;
  1394. if (e.target == action)
  1395. return;
  1396. this.endCapture();
  1397. });
  1398. display.addEventListener("mousedown", (e) => {
  1399. e.stopPropagation();
  1400. this.beginCapture();
  1401. });
  1402. close.addEventListener("click", () => {
  1403. this.keybindEditor.close();
  1404. });
  1405. action.addEventListener("click", () => {
  1406. if (this.actionState == "Start Capture")
  1407. this.beginCapture();
  1408. else if (this.actionState == "End Capture")
  1409. this.endCapture();
  1410. else if (this.actionState == "Reset") {
  1411. this.keys.clear();
  1412. this.updateDisplay();
  1413. this.updateAction();
  1414. }
  1415. });
  1416. exclusive.addEventListener("change", () => {
  1417. this.bind.exclusive = exclusive.checked;
  1418. this.syncBind();
  1419. });
  1420. }
  1421. beginCapture() {
  1422. this.capturing = true;
  1423. this.keys.clear();
  1424. this.keybindEditor.querySelector(".keybind_display").innerHTML = "Press any key...";
  1425. document.addEventListener("keydown", this.keybindCapture.bind(this));
  1426. this.updateAction();
  1427. }
  1428. keybindCapture(e) {
  1429. if (!this.capturing)
  1430. return;
  1431. e.preventDefault();
  1432. if (e.key === "Escape" || e.key === "Enter") {
  1433. this.endCapture();
  1434. return;
  1435. }
  1436. this.keys.add(e.key.toLowerCase());
  1437. this.updateDisplay();
  1438. }
  1439. endCapture() {
  1440. this.capturing = false;
  1441. document.removeEventListener("keydown", this.keybindCapture.bind(this));
  1442. this.updateAction();
  1443. this.syncBind();
  1444. }
  1445. updateDisplay() {
  1446. let keybindDisplay = this.keybindEditor.querySelector(".keybind_display");
  1447. let keys = Array.from(this.keys);
  1448. // replace space with "space"
  1449. keys = keys.map((key) => key === " " ? "space" : key);
  1450. keybindDisplay.innerHTML = keys.join(" + ");
  1451. }
  1452. updateAction() {
  1453. let action = this.keybindEditor.querySelector(".action");
  1454. if (this.capturing)
  1455. this.actionState = "End Capture";
  1456. else if (this.keys.size == 0)
  1457. this.actionState = "Start Capture";
  1458. else
  1459. this.actionState = "Reset";
  1460. action.innerHTML = this.actionState;
  1461. }
  1462. attachTo(element) {
  1463. element.appendChild(this.keybindOpener);
  1464. element.appendChild(this.keybindEditor);
  1465. }
  1466. syncBind() {
  1467. if (!this.options.id)
  1468. return;
  1469. window.cheat.hud.updateKeybind(this.options.id, {
  1470. keys: Array.from(this.keys),
  1471. exclusive: this.bind.exclusive
  1472. });
  1473. }
  1474. }
  1475.  
  1476. class Button extends HudElement {
  1477. constructor(group, options) {
  1478. var _a, _b;
  1479. super(group, options);
  1480. this.type = "button";
  1481. let element = document.createElement("div");
  1482. element.classList.add("button_wrapper");
  1483. element.innerHTML = `
  1484. <button class="button">${this.options.text}</button>
  1485. `;
  1486. this.element = element;
  1487. this.button = element.querySelector("button");
  1488. this.button.addEventListener("click", () => {
  1489. var _a;
  1490. this.dispatchEvent(new CustomEvent("click"));
  1491. if (this.options.runFunction)
  1492. (_a = window.cheat.funcs.get(this.options.runFunction)) === null || _a === void 0 ? void 0 : _a.call(this);
  1493. });
  1494. if (this.options.keybind) {
  1495. let keybindEditor = new KeybindEditor({
  1496. title: (_a = options.title) !== null && _a !== void 0 ? _a : `Set keybind for ${this.button.innerText}`,
  1497. keys: (_b = options.defaultKeybind) !== null && _b !== void 0 ? _b : new Set(),
  1498. exclusive: false,
  1499. callback: () => {
  1500. this.dispatchEvent(new CustomEvent("click"));
  1501. }
  1502. });
  1503. keybindEditor.attachTo(element);
  1504. }
  1505. }
  1506. set text(text) {
  1507. this.button.innerText = text;
  1508. }
  1509. get text() {
  1510. return this.button.innerText;
  1511. }
  1512. }
  1513.  
  1514. class TextInput extends HudElement {
  1515. constructor(group, options) {
  1516. var _a;
  1517. super(group, options);
  1518. this.input = null;
  1519. this.type = "textInput";
  1520. let element = document.createElement("div");
  1521. element.innerHTML = `
  1522. <div class="text">${this.options.text}</div>
  1523. <input type="text" class="textinput" placeholder="${(_a = this.options.placeholder) !== null && _a !== void 0 ? _a : ""}">
  1524. `;
  1525. element.classList.add("textinput_wrapper");
  1526. this.element = element;
  1527. this.input = element.querySelector("input");
  1528. this.input.addEventListener("input", () => {
  1529. this.dispatchEvent(new CustomEvent("input", {
  1530. detail: this.text
  1531. }));
  1532. });
  1533. }
  1534. set text(text) {
  1535. this.input.value = text;
  1536. }
  1537. get text() {
  1538. return this.input.value;
  1539. }
  1540. }
  1541.  
  1542. class Toggle extends HudElement {
  1543. constructor(group, options) {
  1544. var _a, _b, _c;
  1545. super(group, options);
  1546. this.type = "toggle";
  1547. // create the element
  1548. let element = document.createElement("div");
  1549. element.innerHTML = `
  1550. <button class="toggle"></button>
  1551. `;
  1552. element.classList.add("toggle_wrapper");
  1553. // add a keybind if needed
  1554. if (options.keybind) {
  1555. let editorOptions = {
  1556. title: (_a = options.title) !== null && _a !== void 0 ? _a : "Set keybind for toggle",
  1557. keys: (_b = options.defaultKeybind) !== null && _b !== void 0 ? _b : new Set(),
  1558. exclusive: false,
  1559. callback: () => {
  1560. this.toggle();
  1561. }
  1562. };
  1563. if (options.keybindId)
  1564. editorOptions.id = options.keybindId;
  1565. let keybindEditor = new KeybindEditor(editorOptions);
  1566. keybindEditor.attachTo(element);
  1567. }
  1568. this.enabled = (_c = this.options.default) !== null && _c !== void 0 ? _c : false;
  1569. this.element = element;
  1570. this.button = element.querySelector("button");
  1571. this._textEnabled = this.options.textEnabled;
  1572. this._textDisabled = this.options.textDisabled;
  1573. this.updateButton();
  1574. // prevent the menu from being activated with enter
  1575. this.button.addEventListener("keydown", (e) => e.preventDefault());
  1576. this.button.addEventListener("click", () => {
  1577. this.toggle();
  1578. });
  1579. }
  1580. updateButton() {
  1581. this.button.innerHTML = this.enabled ? this._textEnabled : this._textDisabled;
  1582. this.button.classList.toggle("enabled", this.enabled);
  1583. }
  1584. toggle() {
  1585. this.enabled = !this.enabled;
  1586. this.updateButton();
  1587. if (this.options.runFunction)
  1588. window.cheat.funcs.get(this.options.runFunction)(this.enabled);
  1589. this.dispatchEvent(new CustomEvent("change", {
  1590. detail: this.enabled
  1591. }));
  1592. }
  1593. get value() {
  1594. var _a;
  1595. return (_a = this.enabled) !== null && _a !== void 0 ? _a : false;
  1596. }
  1597. set value(value) {
  1598. this.enabled = value;
  1599. this.updateButton();
  1600. }
  1601. get textEnabled() {
  1602. return this._textEnabled;
  1603. }
  1604. set textEnabled(text) {
  1605. this._textEnabled = text;
  1606. this.updateButton();
  1607. }
  1608. get textDisabled() {
  1609. return this._textDisabled;
  1610. }
  1611. set textDisabled(text) {
  1612. this._textDisabled = text;
  1613. this.updateButton();
  1614. }
  1615. }
  1616.  
  1617. class Dropdown extends HudElement {
  1618. constructor(group, options) {
  1619. super(group, options);
  1620. this.type = "dropdown";
  1621. // create the element
  1622. this.element = document.createElement("div");
  1623. this.element.classList.add("dropdown_wrapper");
  1624. this.element.innerHTML = `
  1625. <div class="text">${options.text}</div>
  1626. <select class="dropdown">
  1627. ${options.options.map((option) => {
  1628. return `<option value="${option}" ${option === options.default ? "selected" : ""}>
  1629. ${option}
  1630. </option>`;
  1631. }).join("")}
  1632. </select>
  1633. `;
  1634. this.select = this.element.querySelector(".dropdown");
  1635. // prevent accidental navigation with arrows
  1636. this.select.addEventListener("keydown", (e) => e.preventDefault());
  1637. // add the event listener
  1638. this.select.addEventListener("change", () => {
  1639. if (options.runFunction) {
  1640. window.cheat.funcs.get(this.options.runFunction)(this.select.value);
  1641. }
  1642. this.dispatchEvent(new CustomEvent("change", {
  1643. detail: this.select.value
  1644. }));
  1645. });
  1646. }
  1647. addOption(option) {
  1648. let optionElement = document.createElement("option");
  1649. optionElement.value = option;
  1650. optionElement.innerText = option;
  1651. this.select.appendChild(optionElement);
  1652. }
  1653. removeOption(option) {
  1654. let optionElement = this.select.querySelector(`option[value="${option}"]`);
  1655. if (optionElement) {
  1656. this.select.removeChild(optionElement);
  1657. }
  1658. if (this.select.value === option) {
  1659. this.select.value = this.select.options[0].value;
  1660. }
  1661. }
  1662. setOptions(options) {
  1663. this.select.innerHTML = "";
  1664. options.forEach((option) => {
  1665. this.addOption(option);
  1666. });
  1667. }
  1668. get value() {
  1669. return this.select.value;
  1670. }
  1671. set value(value) {
  1672. this.select.value = value;
  1673. }
  1674. }
  1675.  
  1676. class Slider extends HudElement {
  1677. constructor(group, options) {
  1678. var _a;
  1679. super(group, options);
  1680. this.type = "slider";
  1681. let element = document.createElement("div");
  1682. element.classList.add("slider_wrapper");
  1683. element.innerHTML = `
  1684. <div class = "text">${options.text}</div>
  1685. <input type = "range" min = "${options.min}" max = "${options.max}" value = "${(_a = options.default) !== null && _a !== void 0 ? _a : 0}" class = "slider">
  1686. `;
  1687. this.slider = element.querySelector(".slider");
  1688. this.element = element;
  1689. // prevent the slider from dragging the menu when clicked
  1690. this.slider.addEventListener("mousedown", (e) => {
  1691. e.stopPropagation();
  1692. });
  1693. // listen for changes
  1694. this.slider.addEventListener("input", () => {
  1695. if (this.options.runFunction)
  1696. window.cheat.funcs.get(this.options.runFunction)(this.slider.value);
  1697. this.dispatchEvent(new CustomEvent("change", {
  1698. detail: this.slider.value
  1699. }));
  1700. });
  1701. }
  1702. set value(value) {
  1703. this.slider.value = value.toString();
  1704. }
  1705. get value() {
  1706. return Number(this.slider.value);
  1707. }
  1708. }
  1709.  
  1710. class Group {
  1711. constructor(menu, parentGroup, name, isRoot = false) {
  1712. this.name = "";
  1713. this.hideTimeout = null;
  1714. this.element = null;
  1715. this.isRoot = false;
  1716. this.groups = [];
  1717. this.parentGroup = null;
  1718. this.elements = [];
  1719. this.menu = null;
  1720. this.menu = menu;
  1721. this.parentGroup = parentGroup;
  1722. this.name = name;
  1723. this.isRoot = isRoot;
  1724. this.init();
  1725. }
  1726. init() {
  1727. var _a, _b;
  1728. let element = document.createElement("div");
  1729. element.classList.add("group");
  1730. if (!this.isRoot)
  1731. element.style.display = "none";
  1732. this.element = element;
  1733. (_b = (_a = this.menu) === null || _a === void 0 ? void 0 : _a.element) === null || _b === void 0 ? void 0 : _b.appendChild(element);
  1734. // add a back button if this isn't the root group
  1735. if (!this.isRoot) {
  1736. this.addElement("groupopener", {
  1737. text: "Back",
  1738. openGroup: this.parentGroup.name,
  1739. direction: "right"
  1740. });
  1741. }
  1742. }
  1743. addElement(type, options) {
  1744. var _a;
  1745. let element;
  1746. switch (type.toLowerCase()) {
  1747. case "text":
  1748. element = new Text(this, options);
  1749. break;
  1750. case "groupopener":
  1751. element = new GroupOpener(this, options);
  1752. break;
  1753. case "colorpicker":
  1754. element = new ColorPicker(this, options);
  1755. break;
  1756. case "button":
  1757. element = new Button(this, options);
  1758. break;
  1759. case "textinput":
  1760. element = new TextInput(this, options);
  1761. break;
  1762. case "toggle":
  1763. element = new Toggle(this, options);
  1764. break;
  1765. case "dropdown":
  1766. element = new Dropdown(this, options);
  1767. break;
  1768. case "slider":
  1769. element = new Slider(this, options);
  1770. break;
  1771. default:
  1772. console.error(`Unknown element type: ${type}`);
  1773. }
  1774. if (!element)
  1775. return null;
  1776. (_a = this.element) === null || _a === void 0 ? void 0 : _a.appendChild(element.element);
  1777. this.elements.push(element);
  1778. return element;
  1779. }
  1780. slide(mode, direction) {
  1781. if (this.hideTimeout)
  1782. clearTimeout(this.hideTimeout);
  1783. this.element.style.animation = `slide_${mode}_${direction} both 0.5s`;
  1784. if (mode == "in")
  1785. this.element.style.display = "flex";
  1786. else if (mode == "out") {
  1787. this.hideTimeout = setTimeout(() => this.element.style.display = "none", 500);
  1788. }
  1789. }
  1790. createGroup(name) {
  1791. let existingGroup = this.menu.getAnyGroup(name);
  1792. if (existingGroup)
  1793. return existingGroup;
  1794. let group = new Group(this.menu, this, name);
  1795. this.groups.push(group);
  1796. this.menu.groups.push(group);
  1797. // add a button to open the group
  1798. this.addElement("groupopener", {
  1799. text: name,
  1800. openGroup: name,
  1801. direction: "left"
  1802. });
  1803. return group;
  1804. }
  1805. group(name) {
  1806. for (let i = 0; i < this.groups.length; i++) {
  1807. if (this.groups[i].name == name) {
  1808. return this.groups[i];
  1809. }
  1810. }
  1811. return null;
  1812. }
  1813. remove() {
  1814. var _a, _b;
  1815. (_a = this.element) === null || _a === void 0 ? void 0 : _a.remove();
  1816. (_b = this.parentGroup) === null || _b === void 0 ? void 0 : _b.groups.splice(this.parentGroup.groups.indexOf(this), 1);
  1817. this.menu.groups.splice(this.menu.groups.indexOf(this), 1);
  1818. }
  1819. clearElements() {
  1820. for (let i = 0; i < this.elements.length; i++) {
  1821. let element = this.elements[i];
  1822. if (element.type == "groupOpener")
  1823. continue;
  1824. element.remove();
  1825. i--;
  1826. }
  1827. }
  1828. loadFromObject(object) {
  1829. const loadGroups = () => {
  1830. if (object.groups) {
  1831. for (let group of object.groups) {
  1832. let newGroup = this.createGroup(group.name);
  1833. newGroup.loadFromObject(group);
  1834. }
  1835. }
  1836. };
  1837. const loadElements = () => {
  1838. if (object.elements) {
  1839. for (let element of object.elements) {
  1840. this.addElement(element.type, element.options);
  1841. }
  1842. }
  1843. };
  1844. if (object.order == "elementsFirst") {
  1845. loadElements();
  1846. loadGroups();
  1847. }
  1848. else {
  1849. loadGroups();
  1850. loadElements();
  1851. }
  1852. }
  1853. }
  1854.  
  1855. class MenuControls {
  1856. constructor(menu) {
  1857. this.menu = null;
  1858. this.element = null;
  1859. this.menu = menu;
  1860. this.init();
  1861. }
  1862. init() {
  1863. var _a, _b;
  1864. let element = document.createElement("div");
  1865. element.classList.add("menu_controls");
  1866. element.innerHTML = this.menu.name;
  1867. // create the minimizer
  1868. let minimizer = document.createElement("div");
  1869. minimizer.classList.add("menu_minimizer");
  1870. this.element = element;
  1871. this.element.appendChild(minimizer);
  1872. (_b = (_a = this.menu) === null || _a === void 0 ? void 0 : _a.element) === null || _b === void 0 ? void 0 : _b.appendChild(element);
  1873. this.updateMinimizer();
  1874. minimizer.addEventListener("click", () => {
  1875. var _a;
  1876. (_a = this.menu) === null || _a === void 0 ? void 0 : _a.minimize();
  1877. this.updateMinimizer();
  1878. });
  1879. }
  1880. updateMinimizer() {
  1881. var _a;
  1882. if (!this.element)
  1883. return;
  1884. let minimizer = this.element.querySelector(".menu_minimizer");
  1885. if (!minimizer)
  1886. return;
  1887. minimizer.innerHTML = ((_a = this.menu) === null || _a === void 0 ? void 0 : _a.minimized) ? "+" : "-";
  1888. }
  1889. }
  1890.  
  1891. class Menu {
  1892. // any is used to avoid circular dependencies
  1893. constructor(hud, name, transform) {
  1894. this.hud = null;
  1895. this.element = null;
  1896. this.rootGroup = null;
  1897. this.name = "";
  1898. this.groups = [];
  1899. this.minimized = false;
  1900. this.transform = {
  1901. top: 0,
  1902. left: 0,
  1903. width: 300,
  1904. height: 200,
  1905. minimized: false
  1906. };
  1907. this.hud = hud;
  1908. this.name = name;
  1909. if (transform)
  1910. this.transform = transform;
  1911. this.init();
  1912. }
  1913. applyTransform(transform) {
  1914. var _a;
  1915. if (!this.element)
  1916. return;
  1917. if (transform.height < 50)
  1918. transform.height = 50;
  1919. if (transform.width < 50)
  1920. transform.width = 50;
  1921. this.element.style.top = `${transform.top}px`;
  1922. this.element.style.left = `${transform.left}px`;
  1923. this.element.style.width = `${transform.width}px`;
  1924. this.element.style.height = `${transform.height}px`;
  1925. this.minimize((_a = transform.minimized) !== null && _a !== void 0 ? _a : false);
  1926. }
  1927. init() {
  1928. var _a;
  1929. let element = document.createElement("div");
  1930. element.classList.add("menu");
  1931. this.element = element;
  1932. (_a = this.hud) === null || _a === void 0 ? void 0 : _a.element.appendChild(element);
  1933. this.applyTransform(this.transform);
  1934. // create the menu controls
  1935. new MenuControls(this);
  1936. // create the root group
  1937. let rootGroup = new Group(this, null, "root", true);
  1938. this.rootGroup = rootGroup;
  1939. this.groups.push(rootGroup);
  1940. // add the root group to the menu
  1941. if (rootGroup.element) {
  1942. this.element.appendChild(rootGroup.element);
  1943. }
  1944. this.addListeners();
  1945. }
  1946. addListeners() {
  1947. if (!this.element)
  1948. return;
  1949. let dragging = false;
  1950. let dragStart = { x: 0, y: 0 };
  1951. let dragDistance = 0;
  1952. this.element.addEventListener("mousedown", (e) => {
  1953. dragging = true;
  1954. dragStart.x = e.clientX;
  1955. dragStart.y = e.clientY;
  1956. dragDistance = 0;
  1957. });
  1958. // cancel dragging if it's being resized
  1959. window.addEventListener("mouseup", () => { dragging = false; });
  1960. let observer = new ResizeObserver((e) => {
  1961. // if the element is invisible ignore it
  1962. if (e[0].contentRect.width == 0 || e[0].contentRect.height == 0)
  1963. return;
  1964. dragging = false;
  1965. this.transform.width = e[0].contentRect.width;
  1966. if (!this.minimized)
  1967. this.transform.height = e[0].contentRect.height;
  1968. this.syncTransform();
  1969. });
  1970. observer.observe(this.element);
  1971. window.addEventListener("mousemove", (e) => {
  1972. if (!dragging)
  1973. return;
  1974. dragDistance += Math.abs(e.clientX - dragStart.x) + Math.abs(e.clientY - dragStart.y);
  1975. if (dragDistance < 10)
  1976. return;
  1977. let x = e.clientX - dragStart.x;
  1978. let y = e.clientY - dragStart.y;
  1979. this.element.style.left = `${this.element.offsetLeft + x}px`;
  1980. this.element.style.top = `${this.element.offsetTop + y}px`;
  1981. // sync the transform
  1982. this.transform.top = this.element.offsetTop;
  1983. this.transform.left = this.element.offsetLeft;
  1984. this.syncTransform();
  1985. // prevent the menu from going off screen
  1986. if (this.element.offsetLeft < 0)
  1987. this.element.style.left = "0px";
  1988. if (this.element.offsetTop < 0)
  1989. this.element.style.top = "0px";
  1990. if (this.element.offsetLeft + this.element.offsetWidth > window.innerWidth)
  1991. this.element.style.left = `${window.innerWidth - this.element.offsetWidth}px`;
  1992. if (this.element.offsetTop + this.element.offsetHeight > window.innerHeight)
  1993. this.element.style.top = `${window.innerHeight - this.element.offsetHeight}px`;
  1994. dragStart.x = e.clientX;
  1995. dragStart.y = e.clientY;
  1996. });
  1997. }
  1998. syncTransform() {
  1999. this.hud.updateMenuTransform(this.name, this.transform);
  2000. }
  2001. // adding a group to the menu instead places it in the root group
  2002. createGroup(name) {
  2003. return this.rootGroup.createGroup(name);
  2004. }
  2005. group(name) {
  2006. return this.rootGroup.group(name);
  2007. }
  2008. addElement(type, options) {
  2009. return this.rootGroup.addElement(type, options);
  2010. }
  2011. getAnyGroup(name) {
  2012. for (let group of this.groups) {
  2013. if (group.name == name)
  2014. return group;
  2015. }
  2016. return null;
  2017. }
  2018. remove() {
  2019. var _a;
  2020. (_a = this.element) === null || _a === void 0 ? void 0 : _a.remove();
  2021. this.hud.menus.splice(this.hud.menus.indexOf(this), 1);
  2022. }
  2023. minimize(force = null) {
  2024. if (force == null)
  2025. this.minimized = !this.minimized;
  2026. else
  2027. this.minimized = force;
  2028. this.element.classList.toggle("minimized", this.minimized);
  2029. this.transform.minimized = this.minimized;
  2030. this.syncTransform();
  2031. }
  2032. loadFromObject(object) {
  2033. this.rootGroup.loadFromObject(object);
  2034. }
  2035. }
  2036.  
  2037. const DefaultCss = new Map([
  2038. ["menu-bg-color", "rgba(0, 0, 0, 0.5)"],
  2039. ["menu-border-color", "rgba(0, 0, 0, 0)"],
  2040. ["text-color", "rgba(255, 255, 255, 1)"],
  2041. ["button-bg-color", "rgba(0, 0, 0, 0.5)"],
  2042. ["button-border-color", "rgba(255, 255, 255, 1)"],
  2043. ["menu-controls-bg-color", "rgba(0, 0, 255, 0.5)"],
  2044. ["menu-controls-text-color", "rgba(255, 255, 255, 1)"],
  2045. ["textinput-border-color", "rgba(255, 255, 255, 1)"],
  2046. ["textinput-bg-color", "rgba(0, 0, 0, 0.5)"],
  2047. ["toggle-bg-color", "rgba(0, 0, 0, 0.5)"],
  2048. ["toggle-border-color", "rgba(255, 255, 255, 1)"],
  2049. ["dropdown-bg-color", "rgba(0, 0, 0, 0.5)"],
  2050. ["dropdown-border-color", "rgba(255, 255, 255, 1)"],
  2051. ["keybind-editor-bg-color", "rgba(0, 0, 0, 0.75)"],
  2052. ["keybind-editor-border-color", "rgba(255, 255, 255, 1)"]
  2053. ]);
  2054. const DefaultMenuTransforms = new Map([
  2055. ["HUD Customization", {
  2056. top: 10,
  2057. left: 10,
  2058. width: Math.min(window.innerWidth / 4, 350),
  2059. height: window.innerHeight / 2,
  2060. minimized: false
  2061. }],
  2062. ["Devtools", {
  2063. top: window.innerHeight / 2 + 10,
  2064. left: 10,
  2065. width: Math.min(window.innerWidth / 4, 350),
  2066. height: window.innerHeight / 2,
  2067. minimized: true
  2068. }],
  2069. ["General Cheats", {
  2070. top: 10,
  2071. left: window.innerWidth / 3 + 20,
  2072. width: Math.min(window.innerWidth / 4, 350),
  2073. height: window.innerHeight / 2,
  2074. minimized: false
  2075. }],
  2076. ["Cheats for gamemodes", {
  2077. top: 10,
  2078. left: window.innerWidth / 3 * 2 + 30,
  2079. width: Math.min(window.innerWidth / 4, 350),
  2080. height: window.innerHeight / 2,
  2081. minimized: false
  2082. }]
  2083. ]);
  2084. const DefaultKeybinds = new Map([]);
  2085. const HudCustomizerMenu = {
  2086. menus: [
  2087. {
  2088. name: "HUD Customization",
  2089. groups: [
  2090. {
  2091. name: "General",
  2092. order: "elementsFirst",
  2093. elements: [
  2094. {
  2095. type: "colorpicker",
  2096. options: {
  2097. text: "Text Color",
  2098. bindVar: "text-color"
  2099. }
  2100. }
  2101. ],
  2102. groups: [
  2103. {
  2104. name: "Menu Appearance",
  2105. elements: [
  2106. {
  2107. type: "colorpicker",
  2108. options: {
  2109. text: "Menu Background Color",
  2110. bindVar: "menu-bg-color"
  2111. }
  2112. },
  2113. {
  2114. type: "colorpicker",
  2115. options: {
  2116. text: "Menu Border Color",
  2117. bindVar: "menu-border-color"
  2118. }
  2119. }
  2120. ]
  2121. },
  2122. {
  2123. name: "Menu Controls Appearance",
  2124. elements: [
  2125. {
  2126. type: "colorpicker",
  2127. options: {
  2128. text: "Menu Controls Background Color",
  2129. bindVar: "menu-controls-bg-color"
  2130. }
  2131. },
  2132. {
  2133. type: "colorpicker",
  2134. options: {
  2135. text: "Menu Controls Text Color",
  2136. bindVar: "menu-controls-text-color"
  2137. }
  2138. }
  2139. ]
  2140. },
  2141. {
  2142. name: "Keybind Editor Appearance",
  2143. elements: [
  2144. {
  2145. type: "colorpicker",
  2146. options: {
  2147. text: "Keybind Editor Background Color",
  2148. bindVar: "keybind-editor-bg-color"
  2149. }
  2150. },
  2151. {
  2152. type: "colorpicker",
  2153. options: {
  2154. text: "Keybind Editor Border Color",
  2155. bindVar: "keybind-editor-border-color"
  2156. }
  2157. }
  2158. ]
  2159. }
  2160. ]
  2161. },
  2162. {
  2163. name: "Elements",
  2164. groups: [
  2165. {
  2166. name: "Buttons",
  2167. elements: [
  2168. {
  2169. type: "colorpicker",
  2170. options: {
  2171. text: "Button Background Color",
  2172. bindVar: "button-bg-color"
  2173. }
  2174. },
  2175. {
  2176. type: "colorpicker",
  2177. options: {
  2178. text: "Button Border Color",
  2179. bindVar: "button-border-color"
  2180. }
  2181. }
  2182. ]
  2183. },
  2184. {
  2185. name: "Text Inputs",
  2186. elements: [
  2187. {
  2188. type: "colorpicker",
  2189. options: {
  2190. text: "Text Input Background Color",
  2191. bindVar: "textinput-bg-color"
  2192. }
  2193. },
  2194. {
  2195. type: "colorpicker",
  2196. options: {
  2197. text: "Text Input Border Color",
  2198. bindVar: "textinput-border-color"
  2199. }
  2200. }
  2201. ]
  2202. },
  2203. {
  2204. name: "Toggles",
  2205. elements: [
  2206. {
  2207. type: "colorpicker",
  2208. options: {
  2209. text: "Toggle Background Color",
  2210. bindVar: "toggle-bg-color"
  2211. }
  2212. },
  2213. {
  2214. type: "colorpicker",
  2215. options: {
  2216. text: "Toggle Border Color",
  2217. bindVar: "toggle-border-color"
  2218. }
  2219. }
  2220. ]
  2221. },
  2222. {
  2223. name: "Dropdowns",
  2224. elements: [
  2225. {
  2226. type: "colorpicker",
  2227. options: {
  2228. text: "Dropdown Background Color",
  2229. bindVar: "dropdown-bg-color"
  2230. }
  2231. },
  2232. {
  2233. type: "colorpicker",
  2234. options: {
  2235. text: "Dropdown Border Color",
  2236. bindVar: "dropdown-border-color"
  2237. }
  2238. }
  2239. ]
  2240. }
  2241. ]
  2242. }
  2243. ],
  2244. elements: [
  2245. {
  2246. type: "button",
  2247. options: {
  2248. text: "Reset settings",
  2249. runFunction: "resetSettings"
  2250. }
  2251. }
  2252. ]
  2253. }
  2254. ]
  2255. };
  2256.  
  2257. class OverlayCanvas {
  2258. constructor() {
  2259. this.canvas = document.createElement("canvas");
  2260. this.canvas.classList.add("gc_overlay_canvas");
  2261. this.canvas.width = window.innerWidth;
  2262. this.canvas.height = window.innerHeight;
  2263. // keep the canvas scaled to the window size
  2264. window.addEventListener("resize", () => {
  2265. this.canvas.width = window.innerWidth;
  2266. this.canvas.height = window.innerHeight;
  2267. });
  2268. }
  2269. get context() {
  2270. return this.canvas.getContext("2d");
  2271. }
  2272. }
  2273.  
  2274. // @ts-ignore
  2275. class Hud {
  2276. constructor(cheat) {
  2277. this.element = null;
  2278. this.menus = [];
  2279. this.cssVarsSheet = null;
  2280. // so we can access this globally while it's being constructed
  2281. window.cheat.hud = this;
  2282. this.syncedVars = new Map();
  2283. this.cheat = cheat;
  2284. this.cheat.funcs.set("resetSettings", this.resetSettings.bind(this));
  2285. this.loadSyncedVar("cssVars", DefaultCss);
  2286. this.loadSyncedVar("menuTransforms", DefaultMenuTransforms);
  2287. this.loadSyncedVar("keybinds", DefaultKeybinds);
  2288. this.updateCssVars();
  2289. this.init();
  2290. // load the customizer menu by default
  2291. this.loadFromObject(HudCustomizerMenu);
  2292. this.addToggle();
  2293. }
  2294. resetSettings() {
  2295. if (!confirm("Setting updates will only take place after you reload the page, are you sure you want to reset settings?"))
  2296. return;
  2297. GM_deleteValue("cssVars");
  2298. GM_deleteValue("menuTransforms");
  2299. GM_deleteValue("keybinds");
  2300. }
  2301. addToggle() {
  2302. this.cheat.keybindManager.registerBind({
  2303. keys: new Set(["\\"]),
  2304. exclusive: false,
  2305. callback: () => {
  2306. if (this.element) {
  2307. this.element.style.display = this.element.style.display == "none" ? "" : "none";
  2308. }
  2309. }
  2310. });
  2311. }
  2312. createMenu(name) {
  2313. var _a;
  2314. let existingMenu = this.menu(name);
  2315. if (existingMenu)
  2316. return existingMenu;
  2317. let menuTransform = (_a = this.syncedVars.get("menuTransforms")) === null || _a === void 0 ? void 0 : _a.get(name);
  2318. let menu = new Menu(this, name, menuTransform);
  2319. this.menus.push(menu);
  2320. return menu;
  2321. }
  2322. menu(name) {
  2323. for (let i = 0; i < this.menus.length; i++) {
  2324. if (this.menus[i].name == name) {
  2325. return this.menus[i];
  2326. }
  2327. }
  2328. return null;
  2329. }
  2330. loadSyncedVar(name, defaultValue) {
  2331. let loadedValue = GM_getValue(name, "{}");
  2332. let storedValue = JSON.parse(loadedValue);
  2333. for (let [key, value] of defaultValue) {
  2334. if (!storedValue[key])
  2335. storedValue[key] = value;
  2336. }
  2337. this.syncedVars.set(name, new Map(Object.entries(storedValue)));
  2338. }
  2339. updateCssVar(key, value) {
  2340. var _a, _b;
  2341. (_a = this.syncedVars.get("cssVars")) === null || _a === void 0 ? void 0 : _a.set(key, value);
  2342. this.updateCssVars();
  2343. // save the css vars
  2344. let cssVars = JSON.stringify(Object.fromEntries((_b = this.syncedVars.get("cssVars")) !== null && _b !== void 0 ? _b : []));
  2345. GM_setValue("cssVars", cssVars);
  2346. }
  2347. updateMenuTransform(name, transform) {
  2348. var _a, _b;
  2349. (_a = this.syncedVars.get("menuTransforms")) === null || _a === void 0 ? void 0 : _a.set(name, transform);
  2350. // save the menu transforms
  2351. let menuTransforms = JSON.stringify(Object.fromEntries((_b = this.syncedVars.get("menuTransforms")) !== null && _b !== void 0 ? _b : []));
  2352. GM_setValue("menuTransforms", menuTransforms);
  2353. }
  2354. updateKeybind(id, value) {
  2355. var _a, _b;
  2356. console.log(id, value);
  2357. (_a = this.syncedVars.get("keybinds")) === null || _a === void 0 ? void 0 : _a.set(id, value);
  2358. // save the keybinds
  2359. let keybinds = JSON.stringify(Object.fromEntries((_b = this.syncedVars.get("keybinds")) !== null && _b !== void 0 ? _b : []));
  2360. GM_setValue("keybinds", keybinds);
  2361. }
  2362. updateCssVars() {
  2363. var _a;
  2364. if (!this.cssVarsSheet) {
  2365. this.cssVarsSheet = new CSSStyleSheet();
  2366. document.adoptedStyleSheets = [...document.adoptedStyleSheets, this.cssVarsSheet];
  2367. }
  2368. let cssVars = ":root {\n";
  2369. for (let [key, value] of (_a = this.syncedVars.get("cssVars")) !== null && _a !== void 0 ? _a : []) {
  2370. cssVars += `\t--${key}: ${value};\n`;
  2371. }
  2372. cssVars += "}";
  2373. this.cssVarsSheet.replaceSync(cssVars);
  2374. }
  2375. init() {
  2376. let style = new CSSStyleSheet();
  2377. style.replaceSync(css);
  2378. document.adoptedStyleSheets = [...document.adoptedStyleSheets, style];
  2379. let hud = document.createElement("div");
  2380. hud.id = "gc_hud";
  2381. this.element = hud;
  2382. // the body is not loaded yet, so we have to wait
  2383. document.addEventListener("DOMContentLoaded", () => {
  2384. document.body.appendChild(hud);
  2385. });
  2386. this.updateCssVars();
  2387. }
  2388. loadFromObject(obj) {
  2389. for (let menu of obj.menus) {
  2390. let newMenu = this.createMenu(menu.name);
  2391. newMenu.loadFromObject(menu);
  2392. }
  2393. }
  2394. createOverlayCanvas() {
  2395. var _a;
  2396. let canvas = new OverlayCanvas();
  2397. (_a = document.body) === null || _a === void 0 ? void 0 : _a.appendChild(canvas.canvas);
  2398. return canvas;
  2399. }
  2400. }
  2401.  
  2402. const hudAddition$7 = {
  2403. menus: [
  2404. {
  2405. name: "Devtools",
  2406. elements: [
  2407. {
  2408. type: "toggle",
  2409. options: {
  2410. textEnabled: "Stop logging incoming messages",
  2411. textDisabled: "Log incoming messages",
  2412. default: false,
  2413. runFunction: "logIncomingMessages"
  2414. }
  2415. },
  2416. {
  2417. type: "button",
  2418. options: {
  2419. text: "Log closest device",
  2420. runFunction: "logClosestDevice"
  2421. }
  2422. }
  2423. ]
  2424. }
  2425. ]
  2426. };
  2427. class DevtoolsClass {
  2428. constructor() {
  2429. this.name = "Gimkit Cheat Devtools";
  2430. this.hudAddition = hudAddition$7;
  2431. this.loggingIncomingMessages = false;
  2432. this.funcs = new Map([
  2433. ["logIncomingMessages", (enabled) => {
  2434. this.loggingIncomingMessages = enabled;
  2435. }],
  2436. ["logClosestDevice", () => {
  2437. this.logClosestDevice();
  2438. }]
  2439. ]);
  2440. }
  2441. init(cheat) {
  2442. cheat.socketHandler.addEventListener("recieveMessage", (e) => {
  2443. if (!this.loggingIncomingMessages)
  2444. return;
  2445. cheat.log("Incoming message", e.detail);
  2446. });
  2447. }
  2448. logClosestDevice() {
  2449. var _a, _b, _c, _d, _e, _f, _g, _h;
  2450. let devices = (_e = (_d = (_c = (_b = (_a = unsafeWindow === null || unsafeWindow === void 0 ? void 0 : unsafeWindow.stores) === null || _a === void 0 ? void 0 : _a.phaser) === null || _b === void 0 ? void 0 : _b.scene) === null || _c === void 0 ? void 0 : _c.worldManager) === null || _d === void 0 ? void 0 : _d.devices) === null || _e === void 0 ? void 0 : _e.devicesInView;
  2451. let body = (_h = (_g = (_f = unsafeWindow === null || unsafeWindow === void 0 ? void 0 : unsafeWindow.stores) === null || _f === void 0 ? void 0 : _f.phaser) === null || _g === void 0 ? void 0 : _g.mainCharacter) === null || _h === void 0 ? void 0 : _h.body;
  2452. let closest = null;
  2453. let closestDistance = Infinity;
  2454. for (let device of devices) {
  2455. if (device.interactiveZones.zones.length == 0)
  2456. continue;
  2457. let distance = Math.sqrt(Math.pow(device.x - body.x, 2) + Math.pow(device.y - body.y, 2));
  2458. if (distance < closestDistance) {
  2459. closest = device;
  2460. closestDistance = distance;
  2461. }
  2462. }
  2463. console.log(closest);
  2464. }
  2465. }
  2466. function Devtools() {
  2467. return new DevtoolsClass();
  2468. }
  2469.  
  2470. const hudAddition$6 = {
  2471. menus: [
  2472. {
  2473. name: "General Cheats",
  2474. elements: [
  2475. {
  2476. type: "toggle",
  2477. options: {
  2478. textEnabled: "Stop auto answering",
  2479. textDisabled: "Auto answer",
  2480. default: false,
  2481. runFunction: "setAutoAnswer",
  2482. keybind: true,
  2483. keybindId: "autoAnswer"
  2484. }
  2485. }
  2486. ]
  2487. }
  2488. ]
  2489. };
  2490. class AutoanswerClass {
  2491. constructor() {
  2492. this.name = "Autoanswer";
  2493. this.hudAddition = hudAddition$6;
  2494. this.autoAnswering = false;
  2495. this.funcs = new Map([
  2496. ["setAutoAnswer", (enabled) => {
  2497. this.autoAnswering = enabled;
  2498. }]
  2499. ]);
  2500. this.currentQuestionId = "";
  2501. this.answerDeviceId = "";
  2502. this.questions = [];
  2503. // blueboat specific
  2504. this.questionIdList = [];
  2505. this.currentQuestionIndex = 0;
  2506. }
  2507. init(cheat) {
  2508. cheat.socketHandler.addEventListener("recieveMessage", (e) => {
  2509. var _a;
  2510. if (cheat.socketHandler.transportType == "colyseus")
  2511. return;
  2512. // get the questions and question list
  2513. if (((_a = e.detail) === null || _a === void 0 ? void 0 : _a.key) != "STATE_UPDATE")
  2514. return;
  2515. switch (e.detail.data.type) {
  2516. case "GAME_QUESTIONS":
  2517. this.questions = e.detail.data.value;
  2518. break;
  2519. case "PLAYER_QUESTION_LIST":
  2520. this.questionIdList = e.detail.data.value.questionList;
  2521. this.currentQuestionIndex = e.detail.data.value.questionIndex;
  2522. break;
  2523. case "PLAYER_QUESTION_LIST_INDEX":
  2524. this.currentQuestionIndex = e.detail.data.value;
  2525. break;
  2526. }
  2527. });
  2528. cheat.socketHandler.addEventListener("recieveChanges", (e) => {
  2529. var _a, _b, _c;
  2530. let changes = e.detail;
  2531. for (let change of changes) {
  2532. // try to get the device ID of the answer device
  2533. for (let [key, value] of Object.entries(change.data)) {
  2534. if (key != "GLOBAL_questions")
  2535. continue;
  2536. this.questions = JSON.parse(value);
  2537. this.answerDeviceId = change.id;
  2538. }
  2539. // check whether it includes the new question ID
  2540. for (let [key, value] of Object.entries(change.data)) {
  2541. if (key.includes("currentQuestionId") && key.includes((_c = (_b = (_a = unsafeWindow.stores) === null || _a === void 0 ? void 0 : _a.phaser) === null || _b === void 0 ? void 0 : _b.mainCharacter) === null || _c === void 0 ? void 0 : _c.id)) {
  2542. this.currentQuestionId = value;
  2543. }
  2544. }
  2545. }
  2546. });
  2547. setInterval(() => {
  2548. var _a;
  2549. if (!this.autoAnswering)
  2550. return;
  2551. if (cheat.socketHandler.transportType == "colyseus") {
  2552. if (this.currentQuestionId == "")
  2553. return;
  2554. let correctQuestion = (_a = this.questions) === null || _a === void 0 ? void 0 : _a.find(q => q._id == this.currentQuestionId);
  2555. if (!correctQuestion)
  2556. return;
  2557. let correctAnswerId = correctQuestion.answers.find((a) => a.correct)._id;
  2558. let packet = {
  2559. key: 'answered',
  2560. deviceId: this.answerDeviceId,
  2561. data: {
  2562. answer: correctAnswerId
  2563. }
  2564. };
  2565. cheat.socketHandler.sendData("MESSAGE_FOR_DEVICE", packet);
  2566. }
  2567. else {
  2568. let questionId = this.questionIdList[this.currentQuestionIndex];
  2569. let answerId = this.questions.find(q => q._id == questionId).answers.find((a) => a.correct)._id;
  2570. cheat.socketHandler.sendData("QUESTION_ANSWERED", {
  2571. answer: answerId,
  2572. questionId: questionId
  2573. });
  2574. }
  2575. }, 1000);
  2576. }
  2577. }
  2578. function Autoanswer() {
  2579. return new AutoanswerClass();
  2580. }
  2581.  
  2582. let skins = ["Unchanged", "default_browngreen", "default_cyan", "default_darkblue", "default_darkgreen", "default_darkpurple", "default_gray", "default_grayblue", "default_graybrown", "default_hotpink", "default_lightbrown", "default_lightgreen", "default_lightpink", "default_lightpurple", "default_lightyellow", "default_lime", "default_maroon", "default_orange", "default_pink", "default_red", "default_yellow", "sunny", "glassHalfFull", "stripeDoubleGreen", "sprinklesRed", "dayOne", "vortexAgent", "echoAgent", "grayGradient", "mustache", "clown", "redNinja", "redDeliciousApple", "polkaDotBlueAndYellow", "fadedBlueGradient", "whiteAndBlueVerticalStripes", "volcanoCracks", "pinkPaste", "yellowCracksPurple", "glyphsYellowBrown", "camoBlue", "glyphsOrangeBlue", "purplePaste", "mustacheBrown", "mustachePink", "polkaDotWhiteAndRed", "camoTan", "camoGreen", "stripeDoublePurple", "stripeDoubleRed", "stripeDoubleYellow", "sprinklesChocolate", "coolRedBlueGradient", "mountainAndSun", "redDinoCostume", "pencilPack", "corn", "luchador", "fox", "burger", "galaxy", "cellBlue", "cellGold", "rockyWest", "puzzleRedGreen", "puzzleOrangeBlue", "puzzleGrayWhite", "puzzleGreenBlue", "puzzleYellowPurple", "pumpkin", "ghostCostume", "mummy", "fifthBirthday", "pumpkinPie", "feast", "frostBuddy", "festiveOnesieTan", "festiveOnesieRed", "festiveOnesieGreen", "festiveOnesieBlue", "hotChocolate", "snowglobe", "polkaDotFestive", "polkaDotFestiveReverse", "mustacheSanta", "firework", "gift", "snowman", "detective", "yinYang", "astroHelmet", "hamster", "pirate", "rockstar", "circuitGray", "circuitBlue", "circuitGreen", "roses", "heart", "zebra", "constellationBlackWhite", "constellationBlackGreen", "constellationPurpleYellow", "constellationPinkGreen", "constellationYellowPink", "squiggles", "frozenMummy", "leprechaun", "evilPlantGreen", "evilPlantPink", "fisher", "rainbowWave", "sketch", "sketchBlue", "bananaSplit", "eightBit", "gamerGreen", "gamerPink", "gamerPurple", "gamerYellow", "graduate", "graduateBlue", "arcticFox", "coffee", "partyPineapple", "sentryRobot", "construction", "clock", "crashTestDummy"];
  2583. let trails = ["None", "origin_token"];
  2584. skins = skins.sort();
  2585. trails = trails.sort();
  2586. const hudAddition$5 = {
  2587. menus: [
  2588. {
  2589. name: "General Cheats",
  2590. groups: [
  2591. {
  2592. name: "Cosmetic Picker",
  2593. elements: [
  2594. {
  2595. type: "text",
  2596. options: {
  2597. text: "Select cosmetics to apply to your character. These changes are only visible to you."
  2598. }
  2599. },
  2600. {
  2601. type: "dropdown",
  2602. options: {
  2603. text: "Selected Skin",
  2604. options: skins,
  2605. runFunction: "setSkin",
  2606. default: "Unchanged"
  2607. }
  2608. },
  2609. {
  2610. type: "dropdown",
  2611. options: {
  2612. text: "Selected Trail",
  2613. options: trails,
  2614. runFunction: "setTrail",
  2615. default: "None"
  2616. }
  2617. }
  2618. ]
  2619. }
  2620. ]
  2621. }
  2622. ]
  2623. };
  2624. class CosmeticpickerClass {
  2625. constructor() {
  2626. this.name = "Cosmetic Picker";
  2627. this.hudAddition = hudAddition$5;
  2628. this.funcs = new Map([
  2629. ["setSkin", (skin) => {
  2630. this.setSkin(skin);
  2631. }],
  2632. ["setTrail", (trail) => {
  2633. this.setTrail(trail);
  2634. }]
  2635. ]);
  2636. this.skinWaiting = false;
  2637. this.trailWaiting = false;
  2638. }
  2639. setSkin(skin) {
  2640. var _a, _b, _c, _d, _e, _f;
  2641. if (skin == "Unchanged")
  2642. return;
  2643. if (!("stores" in unsafeWindow)) {
  2644. if (this.skinWaiting)
  2645. return;
  2646. let checkInterval = setInterval(() => {
  2647. if ("stores" in unsafeWindow) {
  2648. if (this.hasSkinApplied(skin))
  2649. clearInterval(checkInterval);
  2650. this.setSkin(skin);
  2651. }
  2652. }, 100);
  2653. this.skinWaiting = true;
  2654. return;
  2655. }
  2656. let phaser = unsafeWindow.stores.phaser;
  2657. let userId = (_a = phaser.mainCharacter) === null || _a === void 0 ? void 0 : _a.id;
  2658. if (!userId)
  2659. return;
  2660. let skinId = `character_${skin}`;
  2661. (_f = (_e = (_d = (_c = (_b = phaser.scene) === null || _b === void 0 ? void 0 : _b.characterManager) === null || _c === void 0 ? void 0 : _c.characters) === null || _d === void 0 ? void 0 : _d.get(userId)) === null || _e === void 0 ? void 0 : _e.skin) === null || _f === void 0 ? void 0 : _f.updateSkin(skinId);
  2662. }
  2663. hasSkinApplied(skin) {
  2664. var _a, _b, _c, _d, _e;
  2665. let phaser = unsafeWindow.stores.phaser;
  2666. let userId = (_a = phaser.mainCharacter) === null || _a === void 0 ? void 0 : _a.id;
  2667. if (!userId)
  2668. return;
  2669. let skinId = `character_${skin}`;
  2670. return ((_e = (_d = (_c = (_b = phaser.scene) === null || _b === void 0 ? void 0 : _b.characterManager) === null || _c === void 0 ? void 0 : _c.characters) === null || _d === void 0 ? void 0 : _d.get(userId)) === null || _e === void 0 ? void 0 : _e.skin.skinId) == skinId;
  2671. }
  2672. setTrail(trail) {
  2673. var _a, _b, _c, _d, _e, _f;
  2674. if (!("stores" in unsafeWindow)) {
  2675. if (this.trailWaiting)
  2676. return;
  2677. let checkInterval = setInterval(() => {
  2678. if ("stores" in unsafeWindow) {
  2679. if (this.hasSkinApplied(trail))
  2680. clearInterval(checkInterval);
  2681. this.setTrail(trail);
  2682. }
  2683. }, 100);
  2684. this.trailWaiting = true;
  2685. return;
  2686. }
  2687. let phaser = unsafeWindow.stores.phaser;
  2688. let userId = (_a = phaser.mainCharacter) === null || _a === void 0 ? void 0 : _a.id;
  2689. if (!userId)
  2690. return;
  2691. // blank trail is "None"
  2692. if (trail == "None")
  2693. trail = "";
  2694. let trailId = `trail_${trail}`;
  2695. (_f = (_e = (_d = (_c = (_b = phaser.scene) === null || _b === void 0 ? void 0 : _b.characterManager) === null || _c === void 0 ? void 0 : _c.characters) === null || _d === void 0 ? void 0 : _d.get(userId)) === null || _e === void 0 ? void 0 : _e.characterTrail) === null || _f === void 0 ? void 0 : _f.updateAppearance(trailId);
  2696. }
  2697. }
  2698. function Cosmeticpicker() {
  2699. return new CosmeticpickerClass();
  2700. }
  2701.  
  2702. const hudAddition$4 = {
  2703. menus: [
  2704. {
  2705. name: "General Cheats",
  2706. groups: [
  2707. {
  2708. name: "Player Highlighter",
  2709. elements: [
  2710. {
  2711. type: "toggle",
  2712. options: {
  2713. textEnabled: "Stop Highlighting Teammates",
  2714. textDisabled: "Highlight Teammates",
  2715. runFunction: "highlightTeammates",
  2716. keybind: true,
  2717. keybindId: "highlightTeammates"
  2718. }
  2719. },
  2720. {
  2721. type: "toggle",
  2722. options: {
  2723. textEnabled: "Stop Highlighting Enemies",
  2724. textDisabled: "Highlight Enemies",
  2725. runFunction: "highlightEnemies",
  2726. keybind: true,
  2727. keybindId: "highlightEnemies"
  2728. }
  2729. },
  2730. {
  2731. type: "slider",
  2732. options: {
  2733. text: "Arrow Distance",
  2734. min: 20,
  2735. max: 750,
  2736. default: 200,
  2737. runFunction: "setArrowDistance"
  2738. }
  2739. }
  2740. ]
  2741. }
  2742. ]
  2743. }
  2744. ]
  2745. };
  2746. class PlayerhighlighterClass {
  2747. constructor() {
  2748. this.name = "Player Highlighter";
  2749. this.hudAddition = hudAddition$4;
  2750. this.funcs = new Map([
  2751. ["highlightTeammates", (value) => {
  2752. this.highlightingTeammates = value;
  2753. }],
  2754. ["highlightEnemies", (value) => {
  2755. this.highlightingEnemies = value;
  2756. }],
  2757. ["setArrowDistance", (value) => {
  2758. this.arrowDistance = value;
  2759. }]
  2760. ]);
  2761. this.highlightingTeammates = false;
  2762. this.highlightingEnemies = false;
  2763. this.ctx = null;
  2764. this.canvas = null;
  2765. this.arrowDistance = 200;
  2766. }
  2767. init(cheat) {
  2768. setInterval(() => {
  2769. var _a, _b;
  2770. if (!((_b = (_a = unsafeWindow === null || unsafeWindow === void 0 ? void 0 : unsafeWindow.stores) === null || _a === void 0 ? void 0 : _a.phaser) === null || _b === void 0 ? void 0 : _b.scene))
  2771. return;
  2772. if (this.canvas == null) {
  2773. this.canvas = cheat.hud.createOverlayCanvas();
  2774. this.ctx = this.canvas.context;
  2775. }
  2776. this.render();
  2777. }, 100);
  2778. }
  2779. render() {
  2780. var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
  2781. (_a = this.ctx) === null || _a === void 0 ? void 0 : _a.clearRect(0, 0, (_c = (_b = this.canvas) === null || _b === void 0 ? void 0 : _b.canvas.width) !== null && _c !== void 0 ? _c : 1920, (_e = (_d = this.canvas) === null || _d === void 0 ? void 0 : _d.canvas.height) !== null && _e !== void 0 ? _e : 1080);
  2782. let phaser = unsafeWindow.stores.phaser;
  2783. let characters = phaser.scene.characterManager.characters;
  2784. let user = phaser.mainCharacter;
  2785. for (let [id, data] of characters) {
  2786. if (id == user.id)
  2787. continue;
  2788. let isEnemy = data.teamId != user.teamId;
  2789. if (isEnemy && !this.highlightingEnemies)
  2790. continue;
  2791. if (!isEnemy && !this.highlightingTeammates)
  2792. continue;
  2793. this.ctx.strokeStyle = isEnemy ? "red" : "green";
  2794. this.ctx.lineWidth = 5;
  2795. // render an arrow pointing to the player
  2796. let angle = Math.atan2(data.body.y - user.body.y, data.body.x - user.body.x);
  2797. let distance = Math.sqrt(Math.pow(data.body.x - user.body.x, 2) + Math.pow(data.body.y - user.body.y, 2));
  2798. let arrowDistance = Math.min(distance, this.arrowDistance);
  2799. let arrowTip = {
  2800. x: Math.cos(angle) * arrowDistance + this.canvas.canvas.width / 2,
  2801. y: Math.sin(angle) * arrowDistance + this.canvas.canvas.height / 2
  2802. };
  2803. let leftTipAngle = angle - Math.PI / 4 * 3;
  2804. let rightTipAngle = angle + Math.PI / 4 * 3;
  2805. // draw a line from the center to both tips
  2806. (_f = this.ctx) === null || _f === void 0 ? void 0 : _f.beginPath();
  2807. (_g = this.ctx) === null || _g === void 0 ? void 0 : _g.moveTo(arrowTip.x, arrowTip.y);
  2808. (_h = this.ctx) === null || _h === void 0 ? void 0 : _h.lineTo(Math.cos(leftTipAngle) * 50 + arrowTip.x, Math.sin(leftTipAngle) * 50 + arrowTip.y);
  2809. (_j = this.ctx) === null || _j === void 0 ? void 0 : _j.moveTo(arrowTip.x, arrowTip.y);
  2810. (_k = this.ctx) === null || _k === void 0 ? void 0 : _k.lineTo(Math.cos(rightTipAngle) * 50 + arrowTip.x, Math.sin(rightTipAngle) * 50 + arrowTip.y);
  2811. (_l = this.ctx) === null || _l === void 0 ? void 0 : _l.stroke();
  2812. // write the user's name and distance
  2813. this.ctx.fillStyle = "black";
  2814. this.ctx.font = "20px Verdana";
  2815. this.ctx.textAlign = "center";
  2816. this.ctx.textBaseline = "middle";
  2817. this.ctx.fillText(`${data.nametag.name} (${Math.round(distance)})`, arrowTip.x, arrowTip.y);
  2818. }
  2819. }
  2820. }
  2821. function Playerhighlighter() {
  2822. return new PlayerhighlighterClass();
  2823. }
  2824.  
  2825. class FreecamClass {
  2826. constructor() {
  2827. this.name = "Cosmetic Picker";
  2828. this.freecamming = false;
  2829. this.freeCamPos = { x: 0, y: 0 };
  2830. this.toggleFreecam = null;
  2831. this.spectateMenu = null;
  2832. this.keys = new Set();
  2833. this.lastPlayers = [];
  2834. }
  2835. init(cheat) {
  2836. let camGroup = cheat.hud.createMenu("General Cheats").createGroup("Freecam");
  2837. // initialize all the elements
  2838. let toggleFreecam = camGroup.addElement("toggle", {
  2839. textEnabled: "Stop Freecamming",
  2840. textDisabled: "Unbind Camera",
  2841. keybind: true,
  2842. keybindId: "toggleFreecam"
  2843. });
  2844. toggleFreecam.addEventListener("change", (e) => {
  2845. if (!this.camHelper) {
  2846. toggleFreecam.value = false;
  2847. return;
  2848. }
  2849. this.enableFreecam(e.detail);
  2850. });
  2851. let dropdown = camGroup.addElement("dropdown", {
  2852. text: "Spectate Player",
  2853. options: ["None"]
  2854. });
  2855. dropdown.addEventListener("change", (e) => {
  2856. this.spectatePlayer(e.detail);
  2857. });
  2858. this.toggleFreecam = toggleFreecam;
  2859. this.spectateMenu = dropdown;
  2860. cheat.addEventListener('gameLoaded', () => {
  2861. this.camHelper = unsafeWindow.stores.phaser.scene.cameraHelper;
  2862. // add in the update loop
  2863. setInterval(() => {
  2864. this.update();
  2865. }, 1000 / 60);
  2866. });
  2867. window.addEventListener("keydown", (e) => {
  2868. if (!this.freecamming)
  2869. return;
  2870. if (!e.key.includes("Arrow"))
  2871. return;
  2872. e.stopImmediatePropagation();
  2873. this.keys.add(e.key);
  2874. });
  2875. window.addEventListener("keyup", (e) => {
  2876. this.keys.delete(e.key);
  2877. });
  2878. }
  2879. enableFreecam(value) {
  2880. let phaser = unsafeWindow.stores.phaser;
  2881. let camera = phaser.scene.cameras.cameras[0];
  2882. if (value) {
  2883. this.camHelper.stopFollow();
  2884. this.freeCamPos.x = camera.midPoint.x;
  2885. this.freeCamPos.y = camera.midPoint.y;
  2886. camera.useBounds = false;
  2887. }
  2888. else {
  2889. let charObj = phaser.scene.characterManager.characters.get(phaser.mainCharacter.id).body;
  2890. this.camHelper.startFollowingObject({ object: charObj });
  2891. camera.useBounds = true;
  2892. }
  2893. this.freecamming = value;
  2894. }
  2895. spectatePlayer(name) {
  2896. // prevent freecamming if we already are
  2897. this.enableFreecam(false);
  2898. if (name == "None")
  2899. return;
  2900. this.toggleFreecam.value = true;
  2901. let phaser = unsafeWindow.stores.phaser;
  2902. let players = phaser.scene.characterManager.characters;
  2903. for (let [id, player] of players) {
  2904. if (player.nametag.name == name) {
  2905. this.camHelper.startFollowingObject({ object: player.body });
  2906. break;
  2907. }
  2908. }
  2909. }
  2910. update() {
  2911. this.updateSpectatablePlayers();
  2912. if (!this.freecamming)
  2913. return;
  2914. // move the camera
  2915. if (this.keys.has("ArrowUp"))
  2916. this.freeCamPos.y -= 20;
  2917. if (this.keys.has("ArrowDown"))
  2918. this.freeCamPos.y += 20;
  2919. if (this.keys.has("ArrowLeft"))
  2920. this.freeCamPos.x -= 20;
  2921. if (this.keys.has("ArrowRight"))
  2922. this.freeCamPos.x += 20;
  2923. this.camHelper.goTo(this.freeCamPos);
  2924. }
  2925. updateSpectatablePlayers() {
  2926. var _a;
  2927. let phaser = unsafeWindow.stores.phaser;
  2928. let players = phaser.scene.characterManager.characters;
  2929. let options = ["None"];
  2930. for (let [id, player] of players) {
  2931. if (id == phaser.mainCharacter.id)
  2932. continue;
  2933. options.push(player.nametag.name);
  2934. }
  2935. // make sure the list of players has changed
  2936. let same = true;
  2937. if (this.lastPlayers.length != options.length)
  2938. same = false;
  2939. else {
  2940. for (let i = 0; i < this.lastPlayers.length; i++) {
  2941. if (this.lastPlayers[i] != options[i]) {
  2942. same = false;
  2943. break;
  2944. }
  2945. }
  2946. }
  2947. if (same)
  2948. return;
  2949. this.lastPlayers = options;
  2950. (_a = this.spectateMenu) === null || _a === void 0 ? void 0 : _a.setOptions(options);
  2951. }
  2952. }
  2953. function Freecam() {
  2954. return new FreecamClass();
  2955. }
  2956.  
  2957. var UpgradeType;
  2958. (function (UpgradeType) {
  2959. UpgradeType["Insurance"] = "insurance";
  2960. UpgradeType["Money Per Question"] = "moneyPerQuestion";
  2961. UpgradeType["Multiplier"] = "multiplier";
  2962. UpgradeType["Streak Bonus"] = "streakBonus";
  2963. })(UpgradeType || (UpgradeType = {}));
  2964. const hudAddition$3 = {
  2965. menus: [
  2966. {
  2967. name: "Cheats for gamemodes",
  2968. groups: [
  2969. {
  2970. name: "Classic",
  2971. elements: [
  2972. {
  2973. type: "toggle",
  2974. options: {
  2975. textEnabled: "Stop Auto Purchasing",
  2976. textDisabled: "Start Auto Purchasing",
  2977. default: false,
  2978. runFunction: "setAutoPurchasingClassic",
  2979. keybind: true,
  2980. keybindId: "autoPurchasingClassic"
  2981. }
  2982. }
  2983. ]
  2984. }
  2985. ]
  2986. }
  2987. ]
  2988. };
  2989. class ClassicClass {
  2990. constructor() {
  2991. this.name = "Classic Script";
  2992. this.money = 0;
  2993. this.upgradeLevels = {
  2994. insurance: 1,
  2995. moneyPerQuestion: 1,
  2996. multiplier: 1,
  2997. streakBonus: 1
  2998. };
  2999. this.hudAddition = hudAddition$3;
  3000. this.autoPurchasing = false;
  3001. this.funcs = new Map([
  3002. ["setAutoPurchasingClassic", (enabled) => {
  3003. this.autoPurchasing = enabled;
  3004. if (this.autoPurchasing)
  3005. this.checkAutoBuy();
  3006. }]
  3007. ]);
  3008. this.upgradesToGet = [
  3009. ["Streak Bonus", 2, 20],
  3010. ["Money Per Question", 3, 100],
  3011. ["Streak Bonus", 3, 200],
  3012. ["Multiplier", 3, 300],
  3013. ["Streak Bonus", 4, 2000],
  3014. ["Multiplier", 4, 2000],
  3015. ["Money Per Question", 5, 10000],
  3016. ["Streak Bonus", 5, 20000],
  3017. ["Multiplier", 5, 12000],
  3018. ["Money Per Question", 6, 75000],
  3019. ["Multiplier", 6, 85000],
  3020. ["Streak Bonus", 6, 200000],
  3021. ["Streak Bonus", 7, 2000000],
  3022. ["Streak Bonus", 8, 20000000],
  3023. ["Multiplier", 7, 700000],
  3024. ["Money Per Question", 9, 10000000],
  3025. ["Multiplier", 8, 6500000],
  3026. ["Streak Bonus", 9, 200000000],
  3027. ["Multiplier", 9, 65000000],
  3028. ["Streak Bonus", 10, 2000000000],
  3029. ["Money Per Question", 10, 100000000],
  3030. ["Multiplier", 10, 1000000000]
  3031. ];
  3032. }
  3033. init(cheat) {
  3034. this.cheat = cheat;
  3035. // get the amount of money
  3036. this.cheat.socketHandler.addEventListener("recieveMessage", (e) => {
  3037. var _a, _b;
  3038. if (this.cheat.socketHandler.transportType != "blueboat")
  3039. return;
  3040. if (((_a = e.detail.data) === null || _a === void 0 ? void 0 : _a.type) == "UPGRADE_LEVELS") {
  3041. this.upgradeLevels = e.detail.data.value;
  3042. // delete any upgrades that we already have
  3043. for (let i = 0; i < this.upgradesToGet.length; i++) {
  3044. let upgrade = this.upgradesToGet[i];
  3045. // check if we have the upgrade
  3046. let upgradeAmount = this.upgradeLevels[UpgradeType[upgrade[0]]];
  3047. if (upgradeAmount >= upgrade[1]) {
  3048. this.upgradesToGet.splice(i, 1);
  3049. i--;
  3050. }
  3051. }
  3052. }
  3053. if (((_b = e.detail.data) === null || _b === void 0 ? void 0 : _b.type) == "BALANCE") {
  3054. this.money = e.detail.data.value;
  3055. this.checkAutoBuy();
  3056. }
  3057. });
  3058. }
  3059. checkAutoBuy() {
  3060. if (!this.autoPurchasing)
  3061. return;
  3062. let upgrade = this.upgradesToGet[0];
  3063. if (!upgrade)
  3064. return;
  3065. if (this.money >= upgrade[2]) {
  3066. this.purchaseUpgrade(upgrade[0], upgrade[1]);
  3067. }
  3068. }
  3069. purchaseUpgrade(name, level) {
  3070. this.cheat.log("Purchasing upgrade", name, level);
  3071. this.cheat.socketHandler.sendData("UPGRADE_PURCHASED", {
  3072. upgradeName: name,
  3073. level
  3074. });
  3075. }
  3076. }
  3077. function Classic() {
  3078. return new ClassicClass();
  3079. }
  3080.  
  3081. const hudAddition$2 = {
  3082. menus: [
  3083. {
  3084. name: "Cheats for gamemodes",
  3085. groups: [
  3086. {
  3087. name: "Super Rich Mode",
  3088. elements: [
  3089. {
  3090. type: "toggle",
  3091. options: {
  3092. textEnabled: "Stop Auto Purchasing",
  3093. textDisabled: "Start Auto Purchasing",
  3094. default: false,
  3095. runFunction: "setAutoPurchasingRichMode",
  3096. keybind: true,
  3097. keybindId: "autoPurchasingRichMode"
  3098. }
  3099. }
  3100. ]
  3101. }
  3102. ]
  3103. }
  3104. ]
  3105. };
  3106. class RichModeClass extends ClassicClass {
  3107. constructor() {
  3108. super(...arguments);
  3109. this.name = "Rich Mode Script";
  3110. this.hudAddition = hudAddition$2;
  3111. this.funcs = new Map([
  3112. ["setAutoPurchasingRichMode", (enabled) => {
  3113. this.autoPurchasing = enabled;
  3114. if (this.autoPurchasing)
  3115. this.checkAutoBuy();
  3116. }]
  3117. ]);
  3118. this.upgradesToGet = [
  3119. ["Streak Bonus", 2, 10000],
  3120. ["Money Per Question", 3, 5000],
  3121. ["Streak Bonus", 3, 100000],
  3122. ["Multiplier", 3, 150000],
  3123. ["Streak Bonus", 4, 1000000],
  3124. ["Multiplier", 4, 1000000],
  3125. ["Money Per Question", 5, 5000000],
  3126. ["Streak Bonus", 5, 10000000],
  3127. ["Multiplier", 5, 6000000],
  3128. ["Money Per Question", 6, 37500000],
  3129. ["Multiplier", 6, 42500000],
  3130. ["Streak Bonus", 6, 100000000],
  3131. ["Streak Bonus", 7, 1000000000],
  3132. ["Streak Bonus", 8, 10000000000],
  3133. ["Multiplier", 7, 350000000],
  3134. ["Money Per Question", 9, 5000000000],
  3135. ["Multiplier", 8, 3250000000],
  3136. ["Streak Bonus", 9, 100000000000],
  3137. ["Multiplier", 9, 32500000000],
  3138. ["Streak Bonus", 10, 1000000000000],
  3139. ["Money Per Question", 10, 50000000000],
  3140. ["Multiplier", 10, 500000000000]
  3141. ];
  3142. }
  3143. }
  3144. function RichMode() {
  3145. return new RichModeClass();
  3146. }
  3147.  
  3148. class TrustNoOneClass {
  3149. constructor() {
  3150. this.name = "Trust No One Script";
  3151. this.people = [];
  3152. }
  3153. init(cheat) {
  3154. this.cheat = cheat;
  3155. // add the imposter display
  3156. let group = cheat.hud.createMenu("Cheats for gamemodes").createGroup("Trust No One");
  3157. let text = group.addElement("text", {
  3158. text: "Imposters: Waiting... (only works if you don't join mid-game)"
  3159. });
  3160. cheat.socketHandler.addEventListener("recieveMessage", (e) => {
  3161. if (this.cheat.socketHandler.transportType != "blueboat")
  3162. return;
  3163. if (e.detail.key == "IMPOSTER_MODE_PEOPLE") {
  3164. this.people = e.detail.data;
  3165. let imposters = this.people.filter((person) => person.role == "imposter");
  3166. text.text = `Imposter(s): ${imposters.map((person) => person.name).join(", ")}`;
  3167. }
  3168. });
  3169. }
  3170. }
  3171. function TrustNoOne() {
  3172. return new TrustNoOneClass();
  3173. }
  3174.  
  3175. const hudAddition$1 = {
  3176. menus: [
  3177. {
  3178. name: "General Cheats",
  3179. elements: [
  3180. {
  3181. type: "toggle",
  3182. options: {
  3183. textEnabled: "Stop instant use",
  3184. textDisabled: "Instant use",
  3185. default: true,
  3186. runFunction: "setInstantUse",
  3187. keybind: true,
  3188. keybindId: "instantUse"
  3189. }
  3190. }
  3191. ]
  3192. }
  3193. ]
  3194. };
  3195. class InstantuseClass {
  3196. constructor() {
  3197. this.name = "Instantuse";
  3198. this.hudAddition = hudAddition$1;
  3199. this.instantUseEnabled = true;
  3200. this.funcs = new Map([
  3201. ["setInstantUse", (enabled) => {
  3202. this.instantUseEnabled = enabled;
  3203. }]
  3204. ]);
  3205. }
  3206. init(cheat) {
  3207. let self = this;
  3208. cheat.keybindManager.registerBind({
  3209. keys: new Set(["enter"]),
  3210. exclusive: false,
  3211. callback() {
  3212. self.useNearest();
  3213. }
  3214. });
  3215. }
  3216. useNearest() {
  3217. var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
  3218. let devices = (_e = (_d = (_c = (_b = (_a = unsafeWindow === null || unsafeWindow === void 0 ? void 0 : unsafeWindow.stores) === null || _a === void 0 ? void 0 : _a.phaser) === null || _b === void 0 ? void 0 : _b.scene) === null || _c === void 0 ? void 0 : _c.worldManager) === null || _d === void 0 ? void 0 : _d.devices) === null || _e === void 0 ? void 0 : _e.devicesInView;
  3219. let body = (_h = (_g = (_f = unsafeWindow === null || unsafeWindow === void 0 ? void 0 : unsafeWindow.stores) === null || _f === void 0 ? void 0 : _f.phaser) === null || _g === void 0 ? void 0 : _g.mainCharacter) === null || _h === void 0 ? void 0 : _h.body;
  3220. if (!devices || !body)
  3221. return;
  3222. let closest = null;
  3223. let closestDistance = Infinity;
  3224. for (let device of devices) {
  3225. if (device.interactiveZones.zones.length == 0)
  3226. continue;
  3227. let distance = Math.sqrt(Math.pow(device.x - body.x, 2) + Math.pow(device.y - body.y, 2));
  3228. if (distance < closestDistance) {
  3229. closest = device;
  3230. closestDistance = distance;
  3231. }
  3232. }
  3233. if (!closest)
  3234. return;
  3235. (_k = (_j = closest === null || closest === void 0 ? void 0 : closest.interactiveZones) === null || _j === void 0 ? void 0 : _j.onInteraction) === null || _k === void 0 ? void 0 : _k.call(_j);
  3236. }
  3237. }
  3238. function Instantuse() {
  3239. return new InstantuseClass();
  3240. }
  3241.  
  3242. /******************************************************************************
  3243. Copyright (c) Microsoft Corporation.
  3244.  
  3245. Permission to use, copy, modify, and/or distribute this software for any
  3246. purpose with or without fee is hereby granted.
  3247.  
  3248. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
  3249. REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  3250. AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
  3251. INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  3252. LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  3253. OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  3254. PERFORMANCE OF THIS SOFTWARE.
  3255. ***************************************************************************** */
  3256.  
  3257. function __awaiter(thisArg, _arguments, P, generator) {
  3258. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  3259. return new (P || (P = Promise))(function (resolve, reject) {
  3260. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  3261. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  3262. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  3263. step((generator = generator.apply(thisArg, _arguments || [])).next());
  3264. });
  3265. }
  3266.  
  3267. const purchases = {
  3268. "Capture The Flag": [
  3269. {
  3270. displayName: "Speed Upgrade",
  3271. selector: {
  3272. grantedItemName: "Speed Upgrade",
  3273. },
  3274. reusable: false
  3275. },
  3276. {
  3277. displayName: "Efficiency Upgrade",
  3278. selector: {
  3279. grantedItemName: "Efficiency Upgrade",
  3280. },
  3281. reusable: false
  3282. },
  3283. {
  3284. displayName: "Energy Per Question Upgrade",
  3285. selector: {
  3286. grantedItemName: "Energy Per Question Upgrade",
  3287. },
  3288. reusable: false
  3289. },
  3290. {
  3291. displayName: "InvisaBits",
  3292. selector: {
  3293. grantedItemId: "silver-ore"
  3294. },
  3295. reusable: true
  3296. }
  3297. ],
  3298. "Tag": [
  3299. {
  3300. displayName: "Speed Upgrade",
  3301. selector: {
  3302. grantedItemName: "Speed Upgrade"
  3303. },
  3304. reusable: false
  3305. },
  3306. {
  3307. displayName: "Efficiency Upgrade",
  3308. selector: {
  3309. grantedItemName: "Efficiency Upgrade"
  3310. },
  3311. reusable: false
  3312. },
  3313. {
  3314. displayName: "Energy Per Question Upgrade",
  3315. selector: {
  3316. grantedItemName: "Energy Per Question Upgrade"
  3317. },
  3318. reusable: false
  3319. },
  3320. {
  3321. displayName: "Endurance Upgrade",
  3322. selector: {
  3323. grantedItemName: "Endurance Upgrade"
  3324. },
  3325. reusable: false
  3326. }
  3327. ],
  3328. "Snowbrawl": [
  3329. {
  3330. displayName: "Med Pack",
  3331. selector: {
  3332. grantedItemId: "medpack"
  3333. },
  3334. reusable: true
  3335. },
  3336. {
  3337. displayName: "Shield Can",
  3338. selector: {
  3339. grantedItemId: "shield-can"
  3340. },
  3341. reusable: true
  3342. }
  3343. ],
  3344. "One Way Out": [
  3345. {
  3346. displayName: "Med Pack",
  3347. selector: {
  3348. grantedItemId: "medpack"
  3349. },
  3350. reusable: true
  3351. },
  3352. {
  3353. displayName: "Shield Can",
  3354. selector: {
  3355. grantedItemId: "shield-can"
  3356. },
  3357. reusable: true
  3358. }
  3359. ],
  3360. "Farmchain": {
  3361. "Seeds": [
  3362. {
  3363. displayName: "Corn Seed",
  3364. selector: {
  3365. grantedItemId: "yellow-seed"
  3366. },
  3367. reusable: true
  3368. },
  3369. {
  3370. displayName: "Wheat Seed",
  3371. selector: {
  3372. grantedItemId: "tan-seed",
  3373. grantAction: "Grant Item"
  3374. },
  3375. reusable: true
  3376. },
  3377. {
  3378. displayName: "Potato Seed",
  3379. selector: {
  3380. grantedItemId: "brown-seed"
  3381. },
  3382. reusable: true
  3383. },
  3384. {
  3385. displayName: "Grape Seed",
  3386. selector: {
  3387. grantedItemId: "purple-seed"
  3388. },
  3389. reusable: true
  3390. },
  3391. {
  3392. displayName: "Raspberry Seed",
  3393. selector: {
  3394. grantedItemId: "magenta-seed"
  3395. },
  3396. reusable: true
  3397. },
  3398. {
  3399. displayName: "Watermelon Seed",
  3400. selector: {
  3401. grantedItemId: "green-seed"
  3402. },
  3403. reusable: true
  3404. },
  3405. {
  3406. displayName: "Coffee Bean",
  3407. selector: {
  3408. grantedItemId: "bronze-seed"
  3409. },
  3410. reusable: true
  3411. },
  3412. {
  3413. displayName: "Orange Seed",
  3414. selector: {
  3415. grantedItemId: "orange-seed"
  3416. },
  3417. reusable: true
  3418. },
  3419. {
  3420. displayName: "Gimberry Seed",
  3421. selector: {
  3422. grantedItemId: "gold-seed"
  3423. },
  3424. reusable: true
  3425. },
  3426. {
  3427. displayName: "Cash Berry Seed",
  3428. selector: {
  3429. grantedItemId: "dark-green-seed"
  3430. },
  3431. reusable: true
  3432. },
  3433. {
  3434. displayName: "Pepper Seed",
  3435. selector: {
  3436. grantedItemId: "red-seed"
  3437. },
  3438. reusable: true
  3439. },
  3440. {
  3441. displayName: "Energy Bar Seed",
  3442. selector: {
  3443. grantedItemId: "blue-seed"
  3444. },
  3445. reusable: true
  3446. },
  3447. {
  3448. displayName: "Lottery Ticket Seed",
  3449. selector: {
  3450. grantedItemId: "teal-seed"
  3451. },
  3452. reusable: true
  3453. }
  3454. ],
  3455. "Seed Unlocks": [
  3456. {
  3457. displayName: "Wheat Seed Unlock",
  3458. selector: {
  3459. grantedItemName: "Wheat Seed Unlock"
  3460. },
  3461. reusable: false
  3462. },
  3463. {
  3464. displayName: "Potato Seed Unlock",
  3465. selector: {
  3466. grantedItemName: "Potato Seed Unlock"
  3467. },
  3468. reusable: false
  3469. },
  3470. {
  3471. displayName: "Grape Seed Unlock",
  3472. selector: {
  3473. grantedItemName: "Grape Seed Unlock"
  3474. },
  3475. reusable: false
  3476. },
  3477. {
  3478. displayName: "Raspberry Seed Unlock",
  3479. selector: {
  3480. grantedItemName: "Raspberry Seed Unlock"
  3481. },
  3482. reusable: false
  3483. },
  3484. {
  3485. displayName: "Watermelon Seed Unlock",
  3486. selector: {
  3487. grantedItemName: "Watermelon Seed Unlock"
  3488. },
  3489. reusable: false
  3490. },
  3491. {
  3492. displayName: "Coffee Bean Seed Unlock",
  3493. selector: {
  3494. grantedItemName: "Coffee Bean Seed Unlock"
  3495. },
  3496. reusable: false
  3497. },
  3498. {
  3499. displayName: "Orange Seed Unlock",
  3500. selector: {
  3501. grantedItemName: "Orange Seed Unlock"
  3502. },
  3503. reusable: false
  3504. },
  3505. {
  3506. displayName: "Gimberry Seed Unlock",
  3507. selector: {
  3508. grantedItemName: "Gimberry Seed Unlock"
  3509. },
  3510. reusable: false
  3511. }
  3512. ]
  3513. }
  3514. };
  3515.  
  3516. class InstapurchasersClass {
  3517. constructor() {
  3518. this.name = "Purchasers";
  3519. }
  3520. init(cheat) {
  3521. cheat.addEventListener("gameLoaded", () => {
  3522. this.createButtons(cheat);
  3523. });
  3524. }
  3525. createButtons(cheat) {
  3526. var _a, _b, _c, _d, _e;
  3527. let devices = (_e = (_d = (_c = (_b = (_a = unsafeWindow === null || unsafeWindow === void 0 ? void 0 : unsafeWindow.stores) === null || _a === void 0 ? void 0 : _a.phaser) === null || _b === void 0 ? void 0 : _b.scene) === null || _c === void 0 ? void 0 : _c.worldManager) === null || _d === void 0 ? void 0 : _d.devices) === null || _e === void 0 ? void 0 : _e.allDevices;
  3528. if (!devices) {
  3529. setTimeout(() => this.createButtons(cheat), 1000); // try again in case something went wrong
  3530. return;
  3531. }
  3532. for (let gamemode in purchases) {
  3533. this.createGamemodeButtons(gamemode, purchases[gamemode], cheat.hud.createMenu("Cheats for gamemodes"));
  3534. }
  3535. }
  3536. createGamemodeButtons(gamemode, content, rootGroup) {
  3537. var _a, _b, _c, _d, _e, _f, _g;
  3538. let devices = (_e = (_d = (_c = (_b = (_a = unsafeWindow === null || unsafeWindow === void 0 ? void 0 : unsafeWindow.stores) === null || _a === void 0 ? void 0 : _a.phaser) === null || _b === void 0 ? void 0 : _b.scene) === null || _c === void 0 ? void 0 : _c.worldManager) === null || _d === void 0 ? void 0 : _d.devices) === null || _e === void 0 ? void 0 : _e.allDevices;
  3539. let group = rootGroup.createGroup(gamemode);
  3540. if (!Array.isArray(content)) {
  3541. for (let [name, menu] of Object.entries(content)) {
  3542. this.createGamemodeButtons(name, menu, group);
  3543. }
  3544. return;
  3545. }
  3546. for (let purchase of content) {
  3547. let { selector, displayName, reusable } = purchase;
  3548. // filter devices by selector
  3549. let purchaseDevices = devices.filter((device) => {
  3550. var _a;
  3551. let matches = true;
  3552. for (let [key, value] of Object.entries(selector)) {
  3553. if (((_a = device.options) === null || _a === void 0 ? void 0 : _a[key]) != value) {
  3554. matches = false;
  3555. break;
  3556. }
  3557. }
  3558. return matches;
  3559. });
  3560. if (purchaseDevices.length == 0)
  3561. continue;
  3562. // sort them by price
  3563. purchaseDevices.sort((a, b) => { var _a, _b; return ((_a = a === null || a === void 0 ? void 0 : a.options) === null || _a === void 0 ? void 0 : _a.amountOfRequiredItem) - ((_b = b === null || b === void 0 ? void 0 : b.options) === null || _b === void 0 ? void 0 : _b.amountOfRequiredItem); });
  3564. let buttonText = `Purchase ${displayName} (${(_g = (_f = purchaseDevices[0]) === null || _f === void 0 ? void 0 : _f.options) === null || _g === void 0 ? void 0 : _g.amountOfRequiredItem})`;
  3565. let button = group.addElement('button', {
  3566. text: buttonText
  3567. });
  3568. button.addEventListener('click', () => __awaiter(this, void 0, void 0, function* () {
  3569. var _h, _j, _k, _l, _m, _o, _p;
  3570. if (!((_j = (_h = purchaseDevices[0]) === null || _h === void 0 ? void 0 : _h.interactiveZones) === null || _j === void 0 ? void 0 : _j.onInteraction)) {
  3571. // this happened to me a few times and I don't know why, just re-get the devices
  3572. purchaseDevices = purchaseDevices.map((device) => {
  3573. return devices.find((d) => d.id == device.id);
  3574. });
  3575. return;
  3576. }
  3577. (_m = (_l = (_k = purchaseDevices[0]) === null || _k === void 0 ? void 0 : _k.interactiveZones) === null || _l === void 0 ? void 0 : _l.onInteraction) === null || _m === void 0 ? void 0 : _m.call(_l);
  3578. if (reusable)
  3579. return;
  3580. // check whether it was successfully purchased
  3581. // wait 500ms for the purchase to go through
  3582. yield new Promise((resolve) => setTimeout(resolve, 500));
  3583. if (purchaseDevices[0].state.active)
  3584. return; // it wasn't purchased
  3585. purchaseDevices.shift();
  3586. if (purchaseDevices.length == 0) {
  3587. button.remove();
  3588. return;
  3589. }
  3590. // update the button text
  3591. buttonText = `Purchase ${displayName} (${(_p = (_o = purchaseDevices[0]) === null || _o === void 0 ? void 0 : _o.options) === null || _p === void 0 ? void 0 : _p.amountOfRequiredItem})`;
  3592. button.text = buttonText;
  3593. }));
  3594. }
  3595. }
  3596. }
  3597. function Instapurchasers() {
  3598. return new InstapurchasersClass();
  3599. }
  3600.  
  3601. const hudAddition = {
  3602. menus: [
  3603. {
  3604. name: "Cheats for gamemodes",
  3605. groups: [
  3606. {
  3607. name: "Farmchain",
  3608. elements: [
  3609. {
  3610. type: "toggle",
  3611. options: {
  3612. textEnabled: "Stop auto harvesting",
  3613. textDisabled: "Start auto harvesting",
  3614. keybind: true,
  3615. keybindId: "autoHarvesting",
  3616. default: true,
  3617. runFunction: "setAutoHarvest"
  3618. }
  3619. },
  3620. {
  3621. type: "toggle",
  3622. options: {
  3623. textEnabled: "Stop auto planting",
  3624. textDisabled: "Start auto planting",
  3625. keybind: true,
  3626. keybindId: "autoPlanting",
  3627. default: false,
  3628. runFunction: "setAutoPlant"
  3629. }
  3630. }
  3631. ]
  3632. }
  3633. ]
  3634. }
  3635. ]
  3636. };
  3637. const seedRanking = [
  3638. 'yellow-seed',
  3639. 'tan-seed',
  3640. 'brown-seed',
  3641. 'purple-seed',
  3642. 'magenta-seed',
  3643. 'green-seed',
  3644. 'bronze-seed',
  3645. 'orange-seed',
  3646. 'gold-seed',
  3647. 'dark-green-seed',
  3648. 'red-seed',
  3649. 'blue-seed',
  3650. 'teal-seed'
  3651. ];
  3652. class FarmchainClass {
  3653. constructor() {
  3654. this.name = "Farmchain";
  3655. this.hudAddition = hudAddition;
  3656. this.autoHarvesting = true;
  3657. this.autoPlanting = false;
  3658. this.funcs = new Map([
  3659. ["setAutoHarvest", (enabled) => {
  3660. this.autoHarvesting = enabled;
  3661. }],
  3662. ["setAutoPlant", (enabled) => {
  3663. this.autoPlanting = enabled;
  3664. }]
  3665. ]);
  3666. }
  3667. init(cheat) {
  3668. // set up auto harvest
  3669. cheat.socketHandler.addEventListener("recieveChanges", (e) => {
  3670. let changes = e.detail;
  3671. for (let change of changes) {
  3672. for (let key in change.data) {
  3673. if (!key.endsWith("status") || change.data[key] != "availableForCollection")
  3674. continue;
  3675. // harvest it
  3676. let packet = {
  3677. key: "collect",
  3678. deviceId: change.id,
  3679. data: undefined
  3680. };
  3681. cheat.socketHandler.sendData("MESSAGE_FOR_DEVICE", packet);
  3682. }
  3683. }
  3684. });
  3685. cheat.addEventListener("gameLoaded", () => {
  3686. var _a, _b, _c, _d, _e, _f, _g;
  3687. let devices = (_e = (_d = (_c = (_b = (_a = unsafeWindow === null || unsafeWindow === void 0 ? void 0 : unsafeWindow.stores) === null || _a === void 0 ? void 0 : _a.phaser) === null || _b === void 0 ? void 0 : _b.scene) === null || _c === void 0 ? void 0 : _c.worldManager) === null || _d === void 0 ? void 0 : _d.devices) === null || _e === void 0 ? void 0 : _e.allDevices;
  3688. let plots = devices.filter((device) => device.options.style == "plant");
  3689. let recipieDevices = {};
  3690. for (let device of devices) {
  3691. if (!seedRanking.includes((_f = device.options) === null || _f === void 0 ? void 0 : _f.ingredient1Item))
  3692. continue;
  3693. recipieDevices[(_g = device.options) === null || _g === void 0 ? void 0 : _g.ingredient1Item] = device;
  3694. }
  3695. // set up auto plant
  3696. setInterval(() => {
  3697. var _a, _b, _c;
  3698. if (!this.autoPlanting)
  3699. return;
  3700. let inventory = (_c = (_b = (_a = unsafeWindow === null || unsafeWindow === void 0 ? void 0 : unsafeWindow.stores) === null || _a === void 0 ? void 0 : _a.me) === null || _b === void 0 ? void 0 : _b.inventory) === null || _c === void 0 ? void 0 : _c.slots;
  3701. if (!inventory)
  3702. return;
  3703. // find the most valuable seed in the inventory
  3704. let mostValuableSeed = undefined;
  3705. for (let seed of seedRanking) {
  3706. if (inventory.has(seed)) {
  3707. mostValuableSeed = seed;
  3708. break;
  3709. }
  3710. }
  3711. if (!mostValuableSeed)
  3712. return;
  3713. // plant the seed in the last idle plot
  3714. let plantPlot = plots.findLast((plot) => plot.state.status == "idle");
  3715. cheat.socketHandler.sendData("MESSAGE_FOR_DEVICE", {
  3716. key: "craft",
  3717. deviceId: plantPlot.id,
  3718. data: {
  3719. recipe: recipieDevices[mostValuableSeed].id
  3720. }
  3721. });
  3722. }, 50);
  3723. });
  3724. }
  3725. }
  3726. function Farmchain() {
  3727. return new FarmchainClass();
  3728. }
  3729.  
  3730. // import { BotCreator } from './scripts/general/botcreator';
  3731. class Cheat extends EventTarget {
  3732. constructor() {
  3733. super();
  3734. this.keybindManager = new KeybindManager();
  3735. this.funcs = new Map();
  3736. this.scripts = [];
  3737. // add cheat to the global scope
  3738. window.cheat = this;
  3739. this.socketHandler = new SocketHandler(this);
  3740. this.socketHandler.addEventListener("socket", (e) => {
  3741. cheat.log("Socket connected", e);
  3742. });
  3743. this.socketHandler.getSocket();
  3744. this.hud = new Hud(this);
  3745. // initialize any scripts
  3746. this.scripts = [
  3747. Devtools(),
  3748. Instantuse(),
  3749. Autoanswer(),
  3750. Cosmeticpicker(),
  3751. Playerhighlighter(),
  3752. Freecam(),
  3753. Classic(),
  3754. RichMode(),
  3755. TrustNoOne(),
  3756. Farmchain(),
  3757. Instapurchasers(),
  3758. // BotCreator()
  3759. ];
  3760. this.initScripts();
  3761. this.waitForLoad();
  3762. }
  3763. waitForLoad() {
  3764. // colyseus exclusive
  3765. let loadInterval = setInterval(() => {
  3766. var _a, _b, _c, _d;
  3767. let loadedData = (_a = unsafeWindow === null || unsafeWindow === void 0 ? void 0 : unsafeWindow.stores) === null || _a === void 0 ? void 0 : _a.loading;
  3768. let loaded = (loadedData === null || loadedData === void 0 ? void 0 : loadedData.percentageAssetsLoaded) >= 100 && (loadedData === null || loadedData === void 0 ? void 0 : loadedData.completedInitialLoad)
  3769. && (loadedData === null || loadedData === void 0 ? void 0 : loadedData.loadedInitialDevices) && (loadedData === null || loadedData === void 0 ? void 0 : loadedData.loadedInitialTerrain);
  3770. if (!loaded)
  3771. return;
  3772. // check whether we've been assigned to a team
  3773. let team = (_d = (_c = (_b = unsafeWindow === null || unsafeWindow === void 0 ? void 0 : unsafeWindow.stores) === null || _b === void 0 ? void 0 : _b.phaser) === null || _c === void 0 ? void 0 : _c.mainCharacter) === null || _d === void 0 ? void 0 : _d.teamId;
  3774. if (team == "__NO_TEAM_ID")
  3775. return;
  3776. clearInterval(loadInterval);
  3777. this.log("Game Loaded");
  3778. this.dispatchEvent(new CustomEvent("gameLoaded"));
  3779. }, 1000 / 60);
  3780. // TODO: Add blueboat load detection
  3781. }
  3782. initScripts() {
  3783. for (let script of this.scripts) {
  3784. // add functions
  3785. if (script.funcs) {
  3786. for (let [name, func] of script.funcs) {
  3787. this.funcs.set(name, func);
  3788. }
  3789. }
  3790. // add hud additions
  3791. if (script.hudAddition) {
  3792. this.hud.loadFromObject(script.hudAddition);
  3793. }
  3794. // initialize the script
  3795. if (script.init) {
  3796. script.init(this);
  3797. }
  3798. }
  3799. }
  3800. antifreeze() {
  3801. let nativeFreeze = Object.freeze;
  3802. Object.freeze = (obj) => {
  3803. var _a;
  3804. if (((_a = obj.constructor) === null || _a === void 0 ? void 0 : _a.name) == "WebSocket" || obj.name == "WebSocket")
  3805. return obj;
  3806. return nativeFreeze(obj);
  3807. };
  3808. // ignore any attempts to modify WebSocket.prototype.send
  3809. var originalSend = WebSocket.prototype.send;
  3810. Object.defineProperty(WebSocket.prototype, 'send', {
  3811. configurable: false,
  3812. enumerable: false,
  3813. get: function () {
  3814. return originalSend;
  3815. },
  3816. set: function (value) {
  3817. if (value === originalSend) {
  3818. return; // allow setting to the original value
  3819. }
  3820. console.log("Attempted to modify WebSocket.prototype.send");
  3821. }
  3822. });
  3823. }
  3824. log(...args) {
  3825. console.log("[GC]", ...args);
  3826. }
  3827. getScript(name) {
  3828. for (let script of this.scripts) {
  3829. if (script.name == name)
  3830. return script;
  3831. }
  3832. return null;
  3833. }
  3834. }
  3835. const cheat = new Cheat();
  3836.  
  3837. cheat.log("Loaded Gimkit Cheat version: " + version);
  3838. cheat.antifreeze();
  3839. // make sure the cheat is running
  3840. if (Object.isFrozen(WebSocket)) {
  3841. alert("WebSocket object is still frozen. Please try refreshing the page. If this persists, open an issue on GitHub.");
  3842. }
  3843.  
  3844. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址