Greasy Fork 还支持 简体中文。

Miracle Scripts For cellcraft.io

Best Cellcraft.io Script!

目前為 2020-12-16 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name Miracle Scripts For cellcraft.io
  3. // @namespace Miracle script, developed by mod's of cc...
  4. // @version 5.1.3
  5. // @description Best Cellcraft.io Script!
  6. // @author Devadmin,vfamily,dexan,naath,Samira
  7. // @license MIT
  8. // @icon https://abload.de/img/mh3k8o.png
  9. // @match https://cellcraft.io/
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. (function() {
  14.  
  15. 'use strict';
  16.  
  17. let $ = window.$;
  18. const KEY_TABLE = { 0: "", 8: "BACKSPACE", 9: "TAB", 12: "CLEAR", 13: "ENTER", 16: "SHIFT", 17: "CTRL", 18: "ALT", 19: "PAUSE", 20: "CAPSLOCK", 27: "ESC", 32: "SPACE", 33: "PAGEUP", 34: "PAGEDOWN", 35: "END", 36: "HOME", 37: "LEFT", 38: "UP", 39: "RIGHT", 40: "DOWN", 44: "PRTSCN", 45: "INS", 46: "DEL", 65: "A", 66: "B", 67: "C", 68: "D", 69: "E", 70: "F", 71: "G", 72: "H", 73: "I", 74: "J", 75: "K", 76: "L", 77: "M", 78: "N", 79: "O", 80: "P", 81: "Q", 82: "R", 83: "S", 84: "T", 85: "U", 86: "V", 87: "W", 88: "X", 89: "Y", 90: "Z", 91: "WIN", 92: "WIN", 93: "CONTEXTMENU", 96: "NUM 0", 97: "NUM 1", 98: "NUM 2", 99: "NUM 3", 100: "NUM 4", 101: "NUM 5", 102: "NUM 6", 103: "NUM 7", 104: "NUM 8", 105: "NUM 9", 106: "NUM *", 107: "NUM +", 109: "NUM -", 110: "NUM .", 111: "NUM /", 144: "NUMLOCK", 145: "SCROLLLOCK" };
  19. class Settings {
  20. constructor(name, default_value) {
  21. this.settings = {};
  22. this.name = name;
  23. this.load(default_value);
  24. }
  25. load(default_value) {
  26. let raw_settings = localStorage.getItem(this.name);
  27. this.settings = Object.assign({}, default_value, this.settings, JSON.parse(raw_settings));
  28. }
  29. save() {
  30. localStorage.setItem(this.name, JSON.stringify(this.settings));
  31. }
  32. set(key, value) {
  33. if (value === undefined) {
  34. this.settings = key;
  35. } else {
  36. this.settings[key] = value;
  37. }
  38. this.save();
  39. }
  40. get(key) {
  41. if (key === undefined) {
  42. return this.settings;
  43. } else {
  44. return this.settings[key];
  45. }
  46. }
  47. }
  48.  
  49. let settings = new Settings("linesplit_overlay", {
  50. enabled: true,
  51. binding: null
  52. });
  53. let current_key = false, pressing = false;
  54.  
  55. $("head").append(`<style>
  56. .hotkey-input-2.selected {
  57. background-color: #ff4;
  58. color: #444;
  59. }
  60. .hotkey-input-2:hover:not(.selected) {
  61. background-color: #f1a02d;
  62. }
  63. .hotkey-input-2 {
  64. background-color: #df901c;
  65. color: #fff;
  66. cursor: pointer;
  67. text-align: center;
  68. min-width: 40px;
  69. max-width: 60px;
  70. height: 18px;
  71. line-height: 18px;
  72. vertical-align: middle;
  73. border-radius: 9px;
  74. right: 5px;
  75. position: absolute;
  76. display: inline-block;
  77. padding: 0 5px;
  78. overflow: hidden;
  79. opacity: 1;
  80. }
  81. </style>`);
  82.  
  83. let [w, h] = [, window.innerHeight];
  84. $("body").append(`<div id="linesplit_overlay" style="z-index: 9999;display:${settings.get("enabled") ? "block" : "none"}">
  85. <div id="point-top" style="border: 2px solid white; border-radius: 55%; width: 10px; height: 10px; position: fixed; left: ${window.innerWidth / 2}px; top: ${0}px; transform: translate(-50%, -50%);"></div>
  86. <div id="point-right" style="border: 2px solid white; border-radius: 55%; width: 10px; height: 10px; position: fixed; left: ${window.innerWidth}px; top: ${window.innerHeight / 2}px; transform: translate(-50%, -50%);"></div>
  87. <div id="point-bottom" style="border: 2px solid white; border-radius: 55%; width: 10px; height: 10px; position: fixed; left: ${window.innerWidth / 2}px; top: ${window.innerHeight}px; transform: translate(-50%, -50%);"></div>
  88. <div id="point-left" style="border: 2px solid white; border-radius: 55%; width: 10px; height: 10px; position: fixed; left: ${0}px; top: ${window.innerHeight / 2}px; transform: translate(-50%, -50%);"></div>
  89. </div>`);
  90.  
  91. $(".dash-tab-settings").click(function(e) {
  92. $("#roleSettings").css("display", "block");
  93. $("#cLinesplitOverlay").removeAttr("disabled").parent().parent().css("display", "block");
  94. });
  95.  
  96. $(".hotkey-col").eq(1).append(`Linesplit overlay <div id="keyLinesplitOverlay" class="hotkey-input-2"></div><br>`);
  97. $("#roleSettings").append(`<div class="role-setting"><label><input id="cLinesplitOverlay" type="checkbox"}><span> Linesplit overlay</span></label><br></div>`);
  98.  
  99. $("#cLinesplitOverlay").change(function(e) {
  100. let enabled = $(this).is(':checked');
  101. settings.set("enabled", enabled);
  102. $("#linesplit_overlay").css("display", enabled ? "block" : "none");
  103. });
  104.  
  105. if (settings.get('enabled')) $("#cLinesplitOverlay").attr("checked", "");
  106.  
  107. $("#keyLinesplitOverlay").html(KEY_TABLE[settings.get("binding")]);
  108.  
  109. $("#keyLinesplitOverlay").click(function(e) {
  110. $(this).addClass("selected");
  111. current_key = true;
  112. });
  113.  
  114. $("#keyLinesplitOverlay").contextmenu(function(e) {
  115. $(this).addClass("selected");
  116. settings.set("binding", null);
  117. $(this).html("");
  118. setTimeout(() => {
  119. $(this).removeClass("selected");
  120. }, 50);
  121. current_key = false;
  122. return false;
  123. });
  124.  
  125. $(window).keyup(function(e) {
  126. if (e.keyCode == settings.get("binding")) {
  127. $("#linesplit_overlay").css("display", settings.get("enabled") ? "block" : "none");
  128. pressing = false;
  129. }
  130. });
  131.  
  132. $(window).keydown(function(e) {
  133. if (current_key) {
  134. $("#keyLinesplitOverlay").html(KEY_TABLE[e.keyCode]);
  135. settings.set("binding", e.keyCode);
  136. setTimeout(() => {
  137. $("#keyLinesplitOverlay").removeClass("selected");
  138. }, 50);
  139. current_key = false;
  140. } else {
  141. if (e.keyCode == settings.get("binding") && document.activeElement == document.body) {
  142. $("#linesplit_overlay").css("display", !settings.get("enabled") ? "block" : "none");
  143. pressing = true;
  144. }
  145. }
  146. });
  147.  
  148. $(window).resize(function(e) {
  149. let [w, h] = [window.innerWidth, window.innerHeight];
  150. $("#point-top").css("left", `${window.innerWidth / 2}px`).css("top", `${0}px`);
  151. $("#point-right").css("left", `${window.innerWidth}px`).css("top", `${window.innerHeight / 2}px`);
  152. $("#point-bottom").css("left", `${window.innerWidth / 2}px`).css("top", `${window.innerHeight}px`);
  153. $("#point-left").css("left", `${0}px`).css("top", `${window.innerHeight / 2}px`);
  154. });
  155.  
  156. swal({
  157. title: "Welcome",
  158. text: 'New Update, command /info, it will take you to game official channel! So subscribe!',
  159. type: "warning",
  160. showCancelButton: true,
  161. confirmButtonColor: "#4CAF50",
  162. confirmButtonText: "Continue",
  163. cancelButtonText: "Close"
  164. }, function() {
  165.  
  166. localStorage.setItem('miracleScripts', '');
  167.  
  168. swal({
  169. title: "Success",
  170. text: 'Write /info in chat and it will take you to game official channel, Pls subscribe!!.',
  171. type: "success"
  172. });
  173. });
  174.  
  175. var input = $("#chtbox");
  176. var inputVal = input.val();
  177. var prefix = "/";
  178.  
  179. input.on("keydown", function (e) {
  180.  
  181. function announce(arg1, arg2) {
  182. var result;
  183. if (arg2 === true) {
  184. result = 'enabled';
  185. } else if (arg2 === false) {
  186. result = 'disabled';
  187. }
  188. if (result === 'enabled') {
  189. $("#curser").fadeIn().text('The setting "'+arg1+'" is now '+result+'!').css({color: '#00c000'});
  190. } else if (result === 'disabled') {
  191. $("#curser").fadeIn().text('The setting "'+arg1+'" is now '+result+'!').css({color: '#ff0000'});
  192. }
  193.  
  194. setTimeout(function() {
  195. $("#curser").fadeOut();
  196. }, 4000);
  197. }
  198.  
  199. inputVal = input.val();
  200. if ($(this).is(":focus") && e.keyCode == '13') {
  201. // Ignore if message doesn't start with prefix
  202. if (inputVal.indexOf(prefix) !== 0) return;
  203.  
  204. const args = inputVal.slice(prefix.length).trim().split(/ +/g);
  205. const command = args.shift().toLowerCase();
  206.  
  207. // commands
  208.  
  209. if (command === 'info') {
  210. window.open('https://www.youtube.com/channel/UCebt69ThNxtKH3v6Ev4JCxg', '_blank');
  211. $("#chtbox").val("")
  212. }
  213. }
  214. })
  215.  
  216. window.miracleScripts = {
  217.  
  218. // News icon: <img src="/img/new-icon.jpg" style="width: 30px;">
  219. news: '<a href="https://abload.de/img/bild_2020-12-11_21330i6kfx.png" target="_blank"><img src="https://abload.de/img/miraclexmasrakap.png"></a> <span style="font-size:12px;color:#666">Yesrs will see them too.<br>Skin made by Light.</span>',
  220.  
  221. // Player profiles
  222. profiles: {
  223. 'JoNaThAnKiD1O1' : {
  224. nickNameColor: '#00FF00',
  225. },
  226. 'LusualYT' : {
  227. nickNameColor: '#000000',
  228. nickNameStrokeColor: '#000000',
  229. nickNameStrokeWidth: 2,
  230. },
  231. 'inaaa' : {
  232. nickNameStrokeColor: 'deeppink',
  233. },
  234. },
  235.  
  236. banned: [],
  237.  
  238. // Source: http://stackoverflow.com/questions/1772179/get-character-value-from-keycode-in-javascript-then-trim#answer-23377822
  239. keyboardMap: [
  240. '', // [0]
  241. '', // [1]
  242. '', // [2]
  243. 'CANCEL', // [3]
  244. '', // [4]
  245. '', // [5]
  246. 'HELP', // [6]
  247. '', // [7]
  248. 'BACK_SPACE', // [8]
  249. 'TAB', // [9]
  250. '', // [10]
  251. '', // [11]
  252. 'CLEAR', // [12]
  253. 'ENTER', // [13]
  254. 'ENTER_SPECIAL', // [14]
  255. '', // [15]
  256. 'SHIFT', // [16]
  257. 'CONTROL', // [17]
  258. 'ALT', // [18]
  259. 'PAUSE', // [19]
  260. 'CAPS_LOCK', // [20]
  261. 'KANA', // [21]
  262. 'EISU', // [22]
  263. 'JUNJA', // [23]
  264. 'FINAL', // [24]
  265. 'HANJA', // [25]
  266. '', // [26]
  267. 'ESCAPE', // [27]
  268. 'CONVERT', // [28]
  269. 'NONCONVERT', // [29]
  270. 'ACCEPT', // [30]
  271. 'MODECHANGE', // [31]
  272. 'SPACE', // [32]
  273. 'PAGE_UP', // [33]
  274. 'PAGE_DOWN', // [34]
  275. 'END', // [35]
  276. 'HOME', // [36]
  277. 'LEFT', // [37]
  278. 'UP', // [38]
  279. 'RIGHT', // [39]
  280. 'DOWN', // [40]
  281. 'SELECT', // [41]
  282. 'PRINT', // [42]
  283. 'EXECUTE', // [43]
  284. 'PRINTSCREEN', // [44]
  285. 'INSERT', // [45]
  286. 'DELETE', // [46]
  287. '', // [47]
  288. '0', // [48]
  289. '1', // [49]
  290. '2', // [50]
  291. '3', // [51]
  292. '4', // [52]
  293. '5', // [53]
  294. '6', // [54]
  295. '7', // [55]
  296. '8', // [56]
  297. '9', // [57]
  298. 'COLON', // [58]
  299. 'SEMICOLON', // [59]
  300. 'LESS_THAN', // [60]
  301. 'EQUALS', // [61]
  302. 'GREATER_THAN', // [62]
  303. 'QUESTION_MARK', // [63]
  304. 'AT', // [64]
  305. 'A', // [65]
  306. 'B', // [66]
  307. 'C', // [67]
  308. 'D', // [68]
  309. 'E', // [69]
  310. 'F', // [70]
  311. 'G', // [71]
  312. 'H', // [72]
  313. 'I', // [73]
  314. 'J', // [74]
  315. 'K', // [75]
  316. 'L', // [76]
  317. 'M', // [77]
  318. 'N', // [78]
  319. 'O', // [79]
  320. 'P', // [80]
  321. 'Q', // [81]
  322. 'R', // [82]
  323. 'S', // [83]
  324. 'T', // [84]
  325. 'U', // [85]
  326. 'V', // [86]
  327. 'W', // [87]
  328. 'X', // [88]
  329. 'Y', // [89]
  330. 'Z', // [90]
  331. 'OS_KEY', // [91] Windows Key (Windows) or Command Key (Mac)
  332. '', // [92]
  333. 'CONTEXT_MENU', // [93]
  334. '', // [94]
  335. 'SLEEP', // [95]
  336. 'NUMPAD0', // [96]
  337. 'NUMPAD1', // [97]
  338. 'NUMPAD2', // [98]
  339. 'NUMPAD3', // [99]
  340. 'NUMPAD4', // [100]
  341. 'NUMPAD5', // [101]
  342. 'NUMPAD6', // [102]
  343. 'NUMPAD7', // [103]
  344. 'NUMPAD8', // [104]
  345. 'NUMPAD9', // [105]
  346. 'MULTIPLY', // [106]
  347. 'ADD', // [107]
  348. 'SEPARATOR', // [108]
  349. 'SUBTRACT', // [109]
  350. 'DECIMAL', // [110]
  351. 'DIVIDE', // [111]
  352. 'F1', // [112]
  353. 'F2', // [113]
  354. 'F3', // [114]
  355. 'F4', // [115]
  356. 'F5', // [116]
  357. 'F6', // [117]
  358. 'F7', // [118]
  359. 'F8', // [119]
  360. 'F9', // [120]
  361. 'F10', // [121]
  362. 'F11', // [122]
  363. 'F12', // [123]
  364. 'F13', // [124]
  365. 'F14', // [125]
  366. 'F15', // [126]
  367. 'F16', // [127]
  368. 'F17', // [128]
  369. 'F18', // [129]
  370. 'F19', // [130]
  371. 'F20', // [131]
  372. 'F21', // [132]
  373. 'F22', // [133]
  374. 'F23', // [134]
  375. 'F24', // [135]
  376. '', // [136]
  377. '', // [137]
  378. '', // [138]
  379. '', // [139]
  380. '', // [140]
  381. '', // [141]
  382. '', // [142]
  383. '', // [143]
  384. 'NUM_LOCK', // [144]
  385. 'SCROLL_LOCK', // [145]
  386. 'WIN_OEM_FJ_JISHO', // [146]
  387. 'WIN_OEM_FJ_MASSHOU', // [147]
  388. 'WIN_OEM_FJ_TOUROKU', // [148]
  389. 'WIN_OEM_FJ_LOYA', // [149]
  390. 'WIN_OEM_FJ_ROYA', // [150]
  391. '', // [151]
  392. '', // [152]
  393. '', // [153]
  394. '', // [154]
  395. '', // [155]
  396. '', // [156]
  397. '', // [157]
  398. '', // [158]
  399. '', // [159]
  400. 'CIRCUMFLEX', // [160]
  401. 'EXCLAMATION', // [161]
  402. 'DOUBLE_QUOTE', // [162]
  403. 'HASH', // [163]
  404. 'DOLLAR', // [164]
  405. 'PERCENT', // [165]
  406. 'AMPERSAND', // [166]
  407. 'UNDERSCORE', // [167]
  408. 'OPEN_PAREN', // [168]
  409. 'CLOSE_PAREN', // [169]
  410. 'ASTERISK', // [170]
  411. 'PLUS', // [171]
  412. 'PIPE', // [172]
  413. 'HYPHEN_MINUS', // [173]
  414. 'OPEN_CURLY_BRACKET', // [174]
  415. 'CLOSE_CURLY_BRACKET', // [175]
  416. 'TILDE', // [176]
  417. '', // [177]
  418. '', // [178]
  419. '', // [179]
  420. '', // [180]
  421. 'VOLUME_MUTE', // [181]
  422. 'VOLUME_DOWN', // [182]
  423. 'VOLUME_UP', // [183]
  424. '', // [184]
  425. '', // [185]
  426. 'SEMICOLON', // [186]
  427. 'EQUALS', // [187]
  428. 'COMMA', // [188]
  429. 'MINUS', // [189]
  430. 'PERIOD', // [190]
  431. 'SLASH', // [191]
  432. 'BACK_QUOTE', // [192]
  433. '', // [193]
  434. '', // [194]
  435. '', // [195]
  436. '', // [196]
  437. '', // [197]
  438. '', // [198]
  439. '', // [199]
  440. '', // [200]
  441. '', // [201]
  442. '', // [202]
  443. '', // [203]
  444. '', // [204]
  445. '', // [205]
  446. '', // [206]
  447. '', // [207]
  448. '', // [208]
  449. '', // [209]
  450. '', // [210]
  451. '', // [211]
  452. '', // [212]
  453. '', // [213]
  454. '', // [214]
  455. '', // [215]
  456. '', // [216]
  457. '', // [217]
  458. '', // [218]
  459. 'OPEN_BRACKET', // [219]
  460. 'BACK_SLASH', // [220]
  461. 'CLOSE_BRACKET', // [221]
  462. 'QUOTE', // [222]
  463. '', // [223]
  464. 'META', // [224]
  465. 'ALTGR', // [225]
  466. '', // [226]
  467. 'WIN_ICO_HELP', // [227]
  468. 'WIN_ICO_00', // [228]
  469. '', // [229]
  470. 'WIN_ICO_CLEAR', // [230]
  471. '', // [231]
  472. '', // [232]
  473. 'WIN_OEM_RESET', // [233]
  474. 'WIN_OEM_JUMP', // [234]
  475. 'WIN_OEM_PA1', // [235]
  476. 'WIN_OEM_PA2', // [236]
  477. 'WIN_OEM_PA3', // [237]
  478. 'WIN_OEM_WSCTRL', // [238]
  479. 'WIN_OEM_CUSEL', // [239]
  480. 'WIN_OEM_ATTN', // [240]
  481. 'WIN_OEM_FINISH', // [241]
  482. 'WIN_OEM_COPY', // [242]
  483. 'WIN_OEM_AUTO', // [243]
  484. 'WIN_OEM_ENLW', // [244]
  485. 'WIN_OEM_BACKTAB', // [245]
  486. 'ATTN', // [246]
  487. 'CRSEL', // [247]
  488. 'EXSEL', // [248]
  489. 'EREOF', // [249]
  490. 'PLAY', // [250]
  491. 'ZOOM', // [251]
  492. '', // [252]
  493. 'PA1', // [253]
  494. 'WIN_OEM_CLEAR', // [254]
  495. '' // [255]
  496. ],
  497.  
  498. banned: ['idemon'],
  499.  
  500. watermark: ' ',
  501.  
  502. // Don't remove the spaces, they are used as separators! Source: https://emojiterra.com/de/liste/
  503. emojis: '😀 😃 😄 😁 😆 😅 😂 😉 😊 😇 😍 😘 😗 ☺️ 😚 😙 😋 😛 😜 😝 😐 😑 😶 😏 😒 😬 😌 😔 😪 😴 😷 😵 😎 😕 😟 😮 😯 😲 😳 😦 😧 😨 😰 😥 😢 😭 😱 😖 😣 😞 😓 😩 😫 😤 😡 😠 😈 👿 💀 💩 👹 👺 👻 👽 👾 😺 😸 😹 😻 😼 😽 🙀 😿 😾 🙈 🙉 🙊 💋 💌 💘 💝 💖 💗 💓 💞 💕 💟 💔 ❤️ 💛 💚 💙 💜 💯 💢 💥 💫 💦 💨 💣 💬 💭 💤 👋 ✋ 👌 ✌️ 👈 👉 👆 👇 ☝️ 👍 👎 ✊ 👊 👏 🙌 👐 🙏 💅 💪 👂 👃 👀 👅 👄 👶 👦 👧 👱 👨 👩 👴 👵 🙍 🙎 🙅 🙆 💁 🙋 🙇 👮 💂 👷 👸 👳 👲 👰 👼 🎅 💆 💇 🚶 🏃 💃 👯 🏇 🏂 🏄 🚣 🏊 🚴 🚵 🛀 👭 👫 👬 💏 💑 👪 👤 👥 👣 🐵 🐒 🐶 🐕 🐩 🐺 🐱 🐈 🐯 🐅 🐆 🐴 🐎 🐮 🐂 🐃 🐄 🐷 🐖 🐗 🐽 🐏 🐑 🐐 🐪 🐫 🐘 🐭 🐁 🐀 🐹 🐰 🐇 🐻 🐨 🐼 🐾 🐔 🐓 🐣 🐤 🐥 🐦 🐧 🐸 🐊 🐢 🐍 🐲 🐉 🐳 🐋 🐬 🐟 🐠 🐡 🐙 🐚 🐌 🐛 🐜 🐝 🐞 💐 🌸 💮 🌹 🌺 🌻 🌼 🌷 🌱 🌲 🌳 🌴 🌵 🌾 🌿 🍀 🍁 🍂 🍃 🍇 🍈 🍉 🍊 🍋 🍌 🍍 🍎 🍏 🍐 🍑 🍒 🍓 🍅 🍆 🌽 🍄 🌰 🍞 🍖 🍗 🍔 🍟 🍕 🍳 🍲 🍱 🍘 🍙 🍚 🍛 🍜 🍝 🍠 🍢 🍣 🍤 🍥 🍡 🍦 🍧 🍨 🍩 🍪 🎂 🍰 🍫 🍬 🍭 🍮 🍯 🍼 ☕ 🍵 🍶 🍷 🍸 🍹 🍺 🍻 🍴 🔪 🌍 🌎 🌏 🌐 🗾 🌋 🗻 🏠 🏡 🏢 🏣 🏤 🏥 🏦 🏨 🏩 🏪 🏫 🏬 🏭 🏯 🏰 💒 🗼 🗽 ⛪ ⛲ ⛺ 🌁 🌃 🌄 🌅 🌆 🌇 🌉 ♨️ 🎠 🎡 🎢 💈 🎪 🚂 🚃 🚄 🚅 🚆 🚇 🚈 🚉 🚊 🚝 🚞 🚋 🚌 🚍 🚎 🚐 🚑 🚒 🚓 🚔 🚕 🚖 🚗 🚘 🚙 🚚 🚛 🚜 🚲 🚏 ⛽ 🚨 🚥 🚦 🚧 ⚓ ⛵ 🚤 🚢 ✈️ 💺 🚁 🚟 🚠 🚡 🚀 ⌛ ⏳ ⌚ ⏰ 🕛 🕧 🕐 🕜 🕑 🕝 🕒 🕞 🕓 🕟 🕔 🕠 🕕 🕡 🕖 🕢 🕗 🕣 🕘 🕤 🕙 🕥 🕚 🕦 🌑 🌒 🌓 🌔 🌕 🌖 🌗 🌘 🌙 🌚 🌛 🌜 ☀️ 🌝 🌞 ⭐ 🌟 🌠 🌌 ☁️ ⛅ 🌀 🌈 🌂 ☔ ⚡ ❄️ ⛄ 🔥 💧 🌊 🎃 🎄 🎆 🎇 ✨ 🎈 🎉 🎊 🎋 🎍 🎎 🎏 🎐 🎑 🎀 🎁 🎫 🏆 ⚽ ⚾ 🏀 🏈 🏉 🎾 🎳 ⛳ 🎣 🎽 🎿 🎯 🎱 🔮 🎮 🎰 🎲 ♠️ ♥️ ♦️ ♣️ 🃏 🀄 🎴 🎭 🎨 👓 👔 👕 👖 👗 👘 👙 👚 👛 👜 👝 🎒 👞 👟 👠 👡 👢 👑 👒 🎩 🎓 💄 💍 💎 🔇 🔈 🔉 🔊 📢 📣 📯 🔔 🔕 🎼 🎵 🎶 🎤 🎧 📻 🎷 🎸 🎹 🎺 🎻 📱 📲 ☎️ 📞 📟 📠 🔋 🔌 💻 💽 💾 💿 📀 🎥 🎬 📺 📷 📹 📼 🔍 🔎 💡 🔦 🏮 📔 📕 📖 📗 📘 📙 📚 📓 📒 📃 📜 📄 📰 📑 🔖 💰 💴 💵 💶 💷 💸 💳 💹 💱 💲 ✉️ 📧 📨 📩 📤 📥 📦 📫 📪 📬 📭 📮 ✏️ ✒️ 📝 💼 📁 📂 📅 📆 📇 📈 📉 📊 📋 📌 📍 📎 📏 📐 ✂️ 🔒 🔓 🔏 🔐 🔑 🔨 🔫 🔧 🔩 🔗 🔬 🔭 📡 💉 💊 🚪 🚽 🚿 🛁 🚬 🗿 🏧 🚮 🚰 ♿ 🚹 🚺 🚻 🚼 🚾 🛂 🛃 🛄 🛅 ⚠️ 🚸 ⛔ 🚫 🚳 🚭 🚯 🚱 🚷 📵 🔞 ⬆️ ↗️ ➡️ ↘️ ⬇️ ↙️ ⬅️ ↖️ ↕️ ↔️ 🔃 🔄 🔙 🔚 🔛 🔜 🔝 🔯 ♈ ♉ ♊ ♋ ♌ ♍ ♎ ♏ ♐ ♑ ♒ ♓ ⛎ 🔀 🔁 🔂 ▶️ ◀️ 🔼 🔽 🎦 📶 📳 📴 ♻️ 🔱 📛 🔰 ⭕ ✅ ☑️ ✖️ ❌ ❎ ➕ ➖ ➗ ➰ ➿ 〽️ ✳️ ✴️ ❇️ ‼️ ⁉️ ❓ ❔ ❕ ❗ 〰️ ©️ ®️ ™️ 🔠 🔡 🔢 🔣 🔤 🅰️ 🆎 🅱️ 🆑 🆒 🆓 🆔 Ⓜ️ 🆕 🆖 🅾️ 🆗 🅿️ 🆘 🆙 🆚 🈁 🈂️ 🈷️ 🈶 🈯 🉐 🈹 🈚 🈲 🉑 🈸 🈴 🈳 ㊗️ ㊙️ 🈺 🈵 🔴 🔵 ⚫ ⚪ ⬛ ⬜ ◼️ ◻️ ◾ ◽ ▪️ ▫️ 🔶 🔷 🔸 🔹 🔺 🔻 💠 🔘 🔳 🔲 🏁 🚩 🎌',
  504.  
  505. settings: null,
  506.  
  507. hotkeys: null,
  508.  
  509. mouse : {
  510. x: 0,
  511. y: 0,
  512. lastMovedAt: null,
  513. },
  514.  
  515. init: function() {
  516. var self = this;
  517.  
  518. this.setupPolyfills();
  519.  
  520. this.hotkeys = JSON.parse(localStorage.getItem('hotkeys'));
  521.  
  522. this.auth();
  523.  
  524. this.config();
  525.  
  526. this.originalDrawImage = CanvasRenderingContext2D.prototype.drawImage;
  527. CanvasRenderingContext2D.prototype.drawImage = this.drawImage;
  528.  
  529. document.querySelector('body').addEventListener('mousemove', function(event) {
  530. self.mouse.x = event.clientX;
  531. self.mouse.y = event.clientY;
  532. self.mouse.lastMovedAt = Date.now();
  533. });
  534.  
  535. this.moveRespawnBtn();
  536. this.players();
  537. this.animation();
  538. this.chatLog();
  539. this.halt();
  540. this.dance();
  541. this.favSkins();
  542. this.paste();
  543. this.replacements();
  544. this.fpsPing();
  545. this.timer();
  546. this.alive();
  547. this.skinChanger();
  548. this.skinApplier();
  549. this.nameCopier();
  550. this.ultraSplit();
  551. this.lineSplit();
  552. this.waste();
  553. this.guessing();
  554. this.nameColor();
  555. this.wearablesToggle();
  556. this.keyboardLayout();
  557. this.help();
  558. this.commands();
  559.  
  560. console.log('🌸 Miracle Scripts successfully loaded!');
  561. },
  562.  
  563. config: function() {
  564. var self = this;
  565. var settings = null;
  566.  
  567. var loadSettings = function (stringifiedSettings) {
  568. var defaultSettings = {
  569. // To get keycodes: https://keycode.info
  570. bindings: {
  571. ultraSplit: 85, // U
  572. wearables: 36, // POS1
  573. animation: 17, // CTRL
  574. paste: 33, // PAGE UP
  575. dance: 34, // PAGE DOWN,
  576. halt: 72, // H,
  577. chatLog: 76, // L
  578. skin1: 49, // 1
  579. skin2: 50, // 2
  580. skin3: 51, // 3
  581. skin4: 52, // 4
  582. skin5: 53, // 5
  583. skin6: 54, // 6
  584. skin7: 55, // 7
  585. skin8: 56, // 8
  586. skin9: 57, // 9
  587. },
  588. replacements: ":D|:smile:\n:*(|:sob:\n:'D|:sweat_smile:\nxD|:joy:\nmiracle|uses 𝘔𝘪𝘳𝘢𝘤𝘭𝘦 𝘚𝘤𝘳𝘪𝘱𝘵,Install script from 𝘎𝘳𝘦𝘢𝘴𝘺𝘧𝘰𝘳𝘬.𝘰𝘳𝘨/scripts/417832!",
  589. primaryColor: '#f9138b',
  590. targetLanguage: 'en',
  591. favSkins: [],
  592. quickSkins: [],
  593. players: [],
  594. showClock: true,
  595. changeKeyboardLayout: false,
  596. };
  597.  
  598. if (stringifiedSettings == null || stringifiedSettings == undefined || stringifiedSettings === '') {
  599. settings = defaultSettings;
  600. localStorage.setItem('miracleScripts', JSON.stringify(settings));
  601. } else {
  602. settings = JSON.parse(stringifiedSettings);
  603. if (settings === null || Object.getOwnPropertyNames(settings).length == 0) {
  604. settings = defaultSettings;
  605. localStorage.setItem('miracleScripts', JSON.stringify(settings));
  606. }
  607.  
  608. // Update for settings:
  609. if (typeof settings.primaryColor === 'undefined') {
  610. settings.primaryColor = defaultSettings.primaryColor;
  611. localStorage.setItem('miracleScripts', JSON.stringify(settings));
  612. }
  613. if (typeof settings.bindings.chatLog === 'undefined') {
  614. settings.bindings.chatLog = defaultSettings.bindings.chatLog;
  615. localStorage.setItem('miracleScripts', JSON.stringify(settings));
  616. }
  617. if (typeof settings.favSkins === 'undefined') {
  618. settings.favSkins = defaultSettings.favSkins;
  619. localStorage.setItem('miracleScripts', JSON.stringify(settings));
  620. }
  621. if (typeof settings.targetLanguage === 'undefined') {
  622. settings.targetLanguage = defaultSettings.targetLanguage;
  623. localStorage.setItem('miracleScripts', JSON.stringify(settings));
  624. }
  625. if (typeof settings.quickSkins === 'undefined') {
  626. settings.quickSkins = [];
  627. localStorage.setItem('miracleScripts', JSON.stringify(settings));
  628. }
  629. if (typeof settings.installedVersion === 'undefined') {
  630. settings.installedVersion = 1;
  631. localStorage.setItem('miracleScripts', JSON.stringify(settings));
  632. }
  633. if (typeof settings.players === 'undefined') {
  634. settings.players = [];
  635. localStorage.setItem('miracleScripts', JSON.stringify(settings));
  636. }
  637. if (typeof settings.bindings.skin1 === 'undefined') {
  638. settings.bindings.skin1 = defaultSettings.bindings.skin1;
  639. settings.bindings.skin2 = defaultSettings.bindings.skin2;
  640. settings.bindings.skin3 = defaultSettings.bindings.skin3;
  641. settings.bindings.skin4 = defaultSettings.bindings.skin4;
  642. settings.bindings.skin5 = defaultSettings.bindings.skin6;
  643. settings.bindings.skin6 = defaultSettings.bindings.skin6;
  644. settings.bindings.skin7 = defaultSettings.bindings.skin7;
  645. settings.bindings.skin8 = defaultSettings.bindings.skin8;
  646. settings.bindings.skin9 = defaultSettings.bindings.skin9;
  647. localStorage.setItem('miracleScripts', JSON.stringify(settings));
  648. }
  649. if (typeof settings.showClock === 'undefined') {
  650. settings.showClock = false;
  651. localStorage.setItem('miracleScripts', JSON.stringify(settings));
  652. }
  653. if (typeof settings.showKeyboardLayout === 'undefined') {
  654. settings.showKeyboardLayout = false;
  655. localStorage.setItem('miracleScripts', JSON.stringify(settings));
  656. }
  657. if (typeof settings.bindings.ultraSplit === 'undefined') {
  658. settings.bindings.ultraSplit = 85;
  659. localStorage.setItem('miracleScripts', JSON.stringify(settings));
  660. }
  661. if (typeof settings.bindings.wearables === 'undefined') {
  662. settings.bindings.wearables = 36;
  663. localStorage.setItem('miracleScripts', JSON.stringify(settings));
  664. }
  665. if (typeof settings.bindings.halt === 'undefined') {
  666. settings.bindings.halt = defaultSettings.bindings.halt;
  667. localStorage.setItem('miracleScripts', JSON.stringify(settings));
  668. }
  669. }
  670.  
  671. self.settings = settings;
  672. };
  673. loadSettings(localStorage.getItem('miracleScripts'));
  674.  
  675. if (settings.installedVersion < this.getVersionAsInt()) {
  676. if (settings.installedVersion > 1) { // We do not want to inform new scripts user of past updates
  677. if (settings.installedVersion < this.getVersionAsInt('2.4.3')) {
  678. window.alert('📢 Miracle Scripts Update: \n\n' +
  679. 'As of version 2.4.3 the nickname color change feature has been removed ' +
  680. 'according to an official decision of the Agma team.\n\n' +
  681. 'To avoid trouble for its users Miracle Scripts respects this decision. ' +
  682. 'Therefore Miracle Scripts is a legit extension for Agma and using it is safe.'
  683. );
  684. }
  685. if (settings.installedVersion < this.getVersionAsInt('2.5.6')) {
  686. self.swal(
  687. 'Miracle Scripts Update',
  688. 'You may now use 20 slots for skins (previously: 15). Type <i>/skin16</i> - <i>/skin20</i> in the chat box!');
  689. }
  690. if (settings.installedVersion < this.getVersionAsInt('2.5.8')) {
  691. self.swal(
  692. 'Miracle Scripts Update',
  693. 'New: You may now assign aliases and notes to players. The alias will be displayed in the friends list. To add an alias right click on a player\'s name in the chat or a cell and then click on "Show profile".');
  694. }
  695. if (settings.installedVersion < this.getVersionAsInt('2.6.0')) {
  696. self.swal(
  697. 'Miracle Scripts Update',
  698. 'New: You may now bind keys to skin slots. Per default the keys 1 - 9 are bound to <i>/skin1</i> - <i>/skin9</i>.');
  699. }
  700. if (settings.installedVersion < this.getVersionAsInt('2.6.1')) {
  701. self.swal(
  702. 'Miracle Scripts Update',
  703. 'New: Right click on a cell. Then click on <i>Use Player\'s Wearables</i> to use the same wearables as that player. (Of course you have to own the wearables.)');
  704. }
  705. if (settings.installedVersion < this.getVersionAsInt('2.6.4')) {
  706. self.swal(
  707. 'Miracle Scripts Update',
  708. 'New: Want to see how late it is? Activate the clock in the settings!');
  709. }
  710. if (settings.installedVersion < this.getVersionAsInt('3.0.0')) {
  711. self.swal(
  712. 'Miracle Scripts Update',
  713. '<b>ATTENTION!</b> This script won\'t get any new features! The Agma staff keeps making new restrictions to this script, so there is no point to continue development. With this update, the <i>/say</i> command has been removed, as the Agma staff enforced this.');
  714. }
  715. if (settings.installedVersion < this.getVersionAsInt('3.1.3')) {
  716. self.swal(
  717. 'Miracle Scripts Update',
  718. 'Just a friendly hint: Agma has a new powerup! It\'s called "Tactical Nuke" and can be found in the shop. Attention: It\'s the first of April 😜');
  719. }
  720. if (settings.installedVersion < this.getVersionAsInt('3.1.6')) {
  721. self.swal(
  722. 'Miracle Scripts Update',
  723. 'New: Type <span style="font-style: italic">/players</span> in the chat to see how many players are online in Agma!');
  724. }
  725. if (settings.installedVersion < this.getVersionAsInt('3.3.0')) {
  726. self.swal(
  727. 'Miracle Scripts Update',
  728. 'New: You may now see your keyboard layout as an overlay! Go to the settings to activate it.');
  729. }
  730. if (settings.installedVersion < this.getVersionAsInt('3.4.0')) {
  731. self.swal(
  732. 'Miracle Scripts Update',
  733. 'New: ULTRA split! Press U to make an ultra split, which can split 1 cell to 64!! (The server has to support that!)');
  734. }
  735. if (settings.installedVersion < this.getVersionAsInt('3.6.0')) {
  736. self.swal(
  737. 'Miracle Scripts Update',
  738. 'New: Toggle "wearables on/off" with a key! Default is POS1!');
  739. }
  740. if (settings.installedVersion < this.getVersionAsInt('4.0.0')) {
  741. self.swal(
  742. 'Miracle Scripts Update',
  743. 'New: Type /guess to start a little guessing game in the chat!<br><br>💡 Note that it only works with browsers that can display emojis.');
  744. }
  745. if (settings.installedVersion < this.getVersionAsInt('4.2.2')) {
  746. self.swal(
  747. 'Miracle Scripts Update',
  748. 'New: Right click on a player to copy the player\'s name to the chat! (PS: You cannot use the name as your own name though!)');
  749. }
  750. if (settings.installedVersion < this.getVersionAsInt('4.3.2')) {
  751. self.swal(
  752. 'Miracle Scripts Announcement',
  753. 'Prepare for some <b>insane</b> new Miracle features! This time it will be mind-blowing. <br><br>To be released soon.');
  754. }
  755. if (settings.installedVersion < this.getVersionAsInt('5.0.2')) {
  756. window.swal({
  757. title: 'Miracle Scripts Update',
  758. text: 'Today we released a great new feature<br>to celebrate <i>Miracle\'s 1 year anniversary</i>:<br><b>Free self-freezing</b>! <br><br>' +
  759. '<iframe width="320" height="180" src="https://www.youtube.com/embed/oWQ9vxdbVcc?autoplay=1" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>' +
  760. '<br><br>Press H to use it!',
  761. html: true
  762. });
  763. }
  764. if (settings.installedVersion < this.getVersionAsInt('5.0.6')) {
  765. self.swal(
  766. 'Miracle Scripts Update',
  767. 'New: Anti-AFK! Doubling the countdown time till you get disconnected for being AFK from 5 to 10 minutes!!!');
  768. }
  769. }
  770.  
  771. settings.installedVersion = this.getVersionAsInt();
  772. localStorage.setItem('miracleScripts', JSON.stringify(settings));
  773. self.settings = settings;
  774. }
  775.  
  776. var defaultNews = 'Looking for a content manager for agma.io instagram. Apply here';
  777. var $newsElement = $('#cnt_panel .navbar p.text-center');
  778. if ($newsElement.text().trim() === defaultNews) {
  779. $newsElement.css('margin-bottom', '20px');
  780. $newsElement.css('padding', '10px');
  781. $newsElement.css('background-color', 'rgba(0, 0, 0, 0.5)');
  782. $newsElement.html(self.news);
  783.  
  784. var $metaElement = $('<div title="Powered by Miracle Script">AGMA News</div>');
  785. $newsElement.parent().prepend($metaElement);
  786. $metaElement.css('background-color', '#B5B9C0');
  787. $metaElement.css('color', 'black');
  788. }
  789.  
  790. var applyPrimaryColor = function () {
  791. var primaryColorCss = '.miracle-primary-color-font { color: ' + self.settings.primaryColor + ' !important } .miracle-primary-color-background { background-color: ' + self.settings.primaryColor + ' !important }; ';
  792. $('body').append('<style>' + primaryColorCss + '</style>');
  793. };
  794. applyPrimaryColor();
  795.  
  796. // General fix for the size of the FontAwesome Icons in the context menu
  797. $('body').append('<style>.context-icon .fa { font-size: 30px }</style>');
  798.  
  799. // We need to have a delay, because the menu is not loaded right away
  800. setTimeout(function () {
  801. var $playButton = $('#playBtn');
  802. var $specateButton = $('#spectateBtn');
  803.  
  804. $playButton.get(0).style.width = '40%';
  805. $specateButton.get(0).style.width = '40%';
  806.  
  807. var $settingsButton = $('<button class="playgame2" style="width: 44px; margin-left: 3px; text-align: center" title="Miracle Scripts Settings">📜</button>');
  808. $settingsButton.insertAfter($specateButton);
  809.  
  810. var changeKey = function (event) {
  811. var name = this.name.substr(4);
  812. $(this).val(self.keyboardMap[event.keyCode]);
  813. self.settings.bindings[name] = event.keyCode;
  814. localStorage.setItem('miracleScripts', JSON.stringify(self.settings));
  815. };
  816.  
  817. var deleteKey = function () {
  818. var action = $(this).attr('data-action');
  819. $('#miracle-settings input[name=key_' + action + ']').val('undefined');
  820. self.settings.bindings[action] = null;
  821. localStorage.setItem('miracleScripts', JSON.stringify(self.settings));
  822. };
  823.  
  824. // Weird Agma scripting... press enter in the replacements textarea and the chat box gets focused!
  825. // Therefore catch the keydown event (that happens earlier) and insert the linebreak manually,
  826. // focus again (delayed) and go to the end of the text where the linebreak is.
  827. // We can improve this later on...
  828. var addReturn = function (event) {
  829. if (event.keyCode === 13) {
  830. var textarea = this;
  831. $(textarea).text($(this).text() + '\n').focus();
  832. setTimeout(function () {
  833. $(textarea).focus();
  834. textarea.setSelectionRange(textarea.value.length, textarea.value.length);
  835. }, 1);
  836. }
  837. };
  838. var changeReplacements = function () {
  839. self.settings.replacements = $(this).val();
  840. localStorage.setItem('miracleScripts', JSON.stringify(self.settings));
  841. };
  842. var changePrimaryColor = function () {
  843. self.settings.primaryColor = $(this).val();
  844. localStorage.setItem('miracleScripts', JSON.stringify(self.settings));
  845. applyPrimaryColor();
  846. };
  847. var changeTargetLanguage = function () {
  848. self.settings.targetLanguage = $(this).val();
  849. localStorage.setItem('miracleScripts', JSON.stringify(self.settings));
  850. };
  851. var changeClock = function() {
  852. self.settings.showClock = $(this).is(':checked');
  853. localStorage.setItem('miracleScripts', JSON.stringify(self.settings));
  854. };
  855. var changeKeyboardLayout = function() {
  856. self.settings.showKeyboardLayout = $(this).is(':checked');
  857. localStorage.setItem('miracleScripts', JSON.stringify(self.settings));
  858. };
  859.  
  860. var $modal = $('<div id="miracle-settings" class="miracle-primary-color-font" style="position: fixed; width: 100%; height: 100%; overflow-y: auto; padding: 50px; background-color: rgba(0,0,0,0.95); z-index: 999; display: none"></div>');
  861. $modal.append('<h1>Miracle Scripts For cellcraft.io</h1>');
  862.  
  863. if (GM_info) {
  864. $modal.append('<small style="color: #717171">Version ' + GM_info.script.version + '</small>');
  865. }
  866.  
  867. var $firstRow = $('<td style="vertical-align: top; padding-right: 19px;">');
  868. var $secRow = $('<td style="vertical-align: top; padding-right: 19px;">');
  869. var $thirdRow = $('<td style="vertical-align: top; padding-right: 19px;">');
  870.  
  871.  
  872. var $element = $('<input name="key_ultraSplit" value="' + self.keyboardMap[self.settings.bindings.ultraSplit] + '"/>').keyup(changeKey);
  873. $firstRow.append('<br><br>Ultra-Split-Key:<br>', $element);
  874. $element = $('<a href="#" data-action="ultraSplit" class="miracle-primary-color-background" style="display: inline-block; padding: 3px 10px; color: white">✕</a>').click(deleteKey);
  875. $firstRow.append($element);
  876.  
  877. $element = $('<input name="key_animation" value="' + self.keyboardMap[self.settings.bindings.animation] + '"/>').keyup(changeKey);
  878. $firstRow.append('<br><br>Animation-Key:<br>', $element);
  879. $element = $('<a href="#" data-action="animation" class="miracle-primary-color-background" style="display: inline-block; padding: 3px 10px; color: white">✕</a>').click(deleteKey);
  880. $firstRow.append($element);
  881.  
  882. $element = $('<input name="key_paste" value="' + self.keyboardMap[self.settings.bindings.paste] + '"/>').keyup(changeKey);
  883. $firstRow.append('<br><br>Paste-Key:<br>', $element);
  884. $element = $('<a href="#" data-action="paste" class="miracle-primary-color-background" style="display: inline-block; padding: 3px 10px; color: white">✕</a>').click(deleteKey);
  885. $firstRow.append($element);
  886.  
  887. $element = $('<input name="key_dance" value="' + self.keyboardMap[self.settings.bindings.dance] + '"/>').keyup(changeKey);
  888. $firstRow.append('<br><br>Dance-Key:<br>', $element);
  889. $element = $('<a href="#" data-action="dance" class="miracle-primary-color-background" style="display: inline-block; padding: 3px 10px; color: white">✕</a>').click(deleteKey);
  890. $firstRow.append($element);
  891.  
  892. $element = $('<input name="key_halt" value="' + self.keyboardMap[self.settings.bindings.halt] + '"/>').keyup(changeKey);
  893. $firstRow.append('<br><br>Halt-Key:<br>', $element);
  894. $element = $('<a href="#" data-action="halt" class="miracle-primary-color-background" style="display: inline-block; padding: 3px 10px; color: white">✕</a>').click(deleteKey);
  895. $firstRow.append($element);
  896.  
  897. $element = $('<input name="key_chatLog" value="' + self.keyboardMap[self.settings.bindings.chatLog] + '"/>').keyup(changeKey);
  898. $firstRow.append('<br><br>Chat-Log-Key:<br>', $element);
  899. $element = $('<a href="#" data-action="chatLog" class="miracle-primary-color-background" style="display: inline-block; padding: 3px 10px; color: white">✕</a>').click(deleteKey);
  900. $firstRow.append($element);
  901.  
  902.  
  903. $element = $('<input name="key_skin1" value="' + self.keyboardMap[self.settings.bindings.skin1] + '"/>').keyup(changeKey);
  904. $secRow.append('<br><br>Use-First-Skin-Key:<br>', $element);
  905. $element = $('<a href="#" data-action="skin1" class="miracle-primary-color-background" style="display: inline-block; padding: 3px 10px; color: white">✕</a>').click(deleteKey);
  906. $secRow.append($element);
  907.  
  908. $element = $('<input name="key_skin2" value="' + self.keyboardMap[self.settings.bindings.skin2] + '"/>').keyup(changeKey);
  909. $secRow.append('<br><br>Use-Second-Skin-Key:<br>', $element);
  910. $element = $('<a href="#" data-action="skin2" class="miracle-primary-color-background" style="display: inline-block; padding: 3px 10px; color: white">✕</a>').click(deleteKey);
  911. $secRow.append($element);
  912.  
  913. $element = $('<input name="key_skin3" value="' + self.keyboardMap[self.settings.bindings.skin3] + '"/>').keyup(changeKey);
  914. $secRow.append('<br><br>Use-Third-Skin-Key:<br>', $element);
  915. $element = $('<a href="#" data-action="skin3" class="miracle-primary-color-background" style="display: inline-block; padding: 3px 10px; color: white">✕</a>').click(deleteKey);
  916. $secRow.append($element);
  917.  
  918. $element = $('<input name="key_skin4" value="' + self.keyboardMap[self.settings.bindings.skin4] + '"/>').keyup(changeKey);
  919. $secRow.append('<br><br>Use-Fourth-Skin-Key:<br>', $element);
  920. $element = $('<a href="#" data-action="skin4" class="miracle-primary-color-background" style="display: inline-block; padding: 3px 10px; color: white">✕</a>').click(deleteKey);
  921. $secRow.append($element);
  922.  
  923. $element = $('<input name="key_skin5" value="' + self.keyboardMap[self.settings.bindings.skin5] + '"/>').keyup(changeKey);
  924. $secRow.append('<br><br>Use-Fifth-Skin-Key:<br>', $element);
  925. $element = $('<a href="#" data-action="skin5" class="miracle-primary-color-background" style="display: inline-block; padding: 3px 10px; color: white">✕</a>').click(deleteKey);
  926. $secRow.append($element);
  927.  
  928.  
  929. $element = $('<input name="key_skin6" value="' + self.keyboardMap[self.settings.bindings.skin6] + '"/>').keyup(changeKey);
  930. $thirdRow.append('<br><br>Use-Sixth-Skin-Key:<br>', $element);
  931. $element = $('<a href="#" data-action="skin6" class="miracle-primary-color-background" style="display: inline-block; padding: 3px 10px; color: white">✕</a>').click(deleteKey);
  932. $thirdRow.append($element);
  933.  
  934. $element = $('<input name="key_skin7" value="' + self.keyboardMap[self.settings.bindings.skin7] + '"/>').keyup(changeKey);
  935. $thirdRow.append('<br><br>Use-Seventh-Skin-Key:<br>', $element);
  936. $element = $('<a href="#" data-action="skin7" class="miracle-primary-color-background" style="display: inline-block; padding: 3px 10px; color: white">✕</a>').click(deleteKey);
  937. $thirdRow.append($element);
  938.  
  939. $element = $('<input name="key_skin8" value="' + self.keyboardMap[self.settings.bindings.skin8] + '"/>').keyup(changeKey);
  940. $thirdRow.append('<br><br>Use-Eighth-Skin-Key:<br>', $element);
  941. $element = $('<a href="#" data-action="skin8" class="miracle-primary-color-background" style="display: inline-block; padding: 3px 10px; color: white">✕</a>').click(deleteKey);
  942. $thirdRow.append($element);
  943.  
  944. $element = $('<input name="key_skin9" value="' + self.keyboardMap[self.settings.bindings.skin9] + '"/>').keyup(changeKey);
  945. $thirdRow.append('<br><br>Use-Ninth-Skin-Key:<br>', $element);
  946. $element = $('<a href="#" data-action="skin9" class="miracle-primary-color-background" style="display: inline-block; padding: 3px 10px; color: white">✕</a>').click(deleteKey);
  947. $thirdRow.append($element);
  948.  
  949. $element = $('<input name="key_wearables" value="' + self.keyboardMap[self.settings.bindings.wearables] + '"/>').keyup(changeKey);
  950. $thirdRow.append('<br><br>Toggle-Wearables-Key:<br>', $element);
  951. $element = $('<a href="#" data-action="wearables" class="miracle-primary-color-background" style="display: inline-block; padding: 3px 10px; color: white">✕</a>').click(deleteKey);
  952. $thirdRow.append($element);
  953.  
  954.  
  955.  
  956. var $table = $('<table>').append($('<tbody>').append($('<tr>').append($firstRow).append($secRow).append($thirdRow)));
  957. $modal.append($table)
  958.  
  959. $element = $('<select name="target_language"><option value="en">English</option><option value="de">German</option><option value="fr">French</option><option value="es">Spanish</option><option value="it">Italian</option><option value="nl">Dutch</option><option value="pl">Polish</option><option value="pt">Portuguese</option><option value="ru">Russian</option><option value="ja">Japanese</option><option value="zh">Chinese</option></select>').change(changeTargetLanguage);
  960. $modal.append('<br><br>Translate cellcraft.io chat messages to:<br>', $element);
  961. $element.get(0).value = self.settings.targetLanguage;
  962.  
  963. $element = $('<input type="color" name="favcolor" value="' + self.settings.primaryColor + '"/>').change(changePrimaryColor);
  964. $modal.append('<br><br>User interface color:<br>', $element);
  965.  
  966. $element = $('<input type="checkbox" name="checkBox" value="1" ' + (self.settings.showClock ? 'checked' : '') + '/>').change(changeClock);
  967. $modal.append('<br><br>Show clock:<br>', $element);
  968.  
  969. $element = $('<input type="checkbox" name="checkBox" value="1" ' + (self.settings.showKeyboardLayout ? 'checked' : '') + '/>').change(changeKeyboardLayout);
  970. $modal.append('<br><br>Show Keyboard Layout (reload website to update):<br>', $element);
  971.  
  972. $element = $('<textarea rows="6" style="width: 100%; max-width: 500px" placeholder="search|replace">').text(self.settings.replacements).keydown(addReturn).keyup(changeReplacements);
  973. $modal.append('<br><br>Chat-Replacements (1 per line):<br>', $element, '<br>💡 <span style="color: #00C9FF">Avoid using the search text in the cellcraft.io replacement!</span>');
  974.  
  975. $modal.append($('<br><a href="#" class="miracle-primary-color-background" style="display: inline-block; margin-top: 20px; padding: 10px; color: white">Close</a>').click(function () {
  976. $modal.hide();
  977. }));
  978. $modal.append($('<a href="#" class="miracle-primary-color-background" style="display: inline-block; margin-left: 20px; margin-top: 20px; padding: 10px; color: white">Export settings</a>').click(function () {
  979. self.download('miracle_settings.txt', localStorage.getItem('miracleScripts'));
  980. }));
  981. $modal.append($('<a href="#" class="miracle-primary-color-background" style="display: inline-block; margin-left: 20px; margin-top: 20px; padding: 10px; color: white">Import setting</a>').click(function () {
  982. var stringifiedSettings = window.prompt('Paste the settings here');
  983. if (stringifiedSettings !== null) {
  984. loadSettings(stringifiedSettings);
  985. localStorage.setItem('miracleScripts', stringifiedSettings);
  986. $modal.hide();
  987. self.message('Settings loaded! Reload cellcraft.io to refresh. 😄');
  988. }
  989. }));
  990. //$modal.append($('<a href="http://agarioforums.net/showthread.php?tid=61388" target="_blank" class="miracle-primary-color-background" style="display: inline-block; margin-left: 20px; margin-top: 20px; padding: 10px; color: white">Support</a>'));
  991. $modal.append($('<a href="#" class="miracle-primary-color-background" style="display: inline-block; margin-left: 20px; margin-top: 20px; padding: 10px; color: white">Help</a>').click(function () {
  992. $modal.hide();
  993. self.$helpModal.show();
  994. }));
  995.  
  996. $('body').append($modal);
  997.  
  998. $settingsButton.click(function (event) {
  999. $modal.show();
  1000.  
  1001. event.preventDefault();
  1002. });
  1003.  
  1004. // Anti AFK
  1005. window.setInterval(function() {
  1006. if (self.mouse.lastMovedAt !== null && Date.now() - self.mouse.lastMovedAt >= 230000 && Date.now() - self.mouse.lastMovedAt <= 230000 + 60000) {
  1007. self.mouse.x++;
  1008. $('#canvas').trigger($.Event('mousemove', {clientX: self.mouse.x, clientY: self.mouse.y, synthetic: true}));
  1009. console.log('🚫 Miracle ANTI-AFK activated.');
  1010. }
  1011. }, 60000);
  1012.  
  1013. window.addEventListener('miracleCommand', function(commandEvent) {
  1014. if (commandEvent.command === '/miraclesettings' || commandEvent.command === '/miracleconfig') {
  1015. $modal.show();
  1016. $('#chtbox').val('');
  1017. }
  1018. });
  1019. }, 500);
  1020. },
  1021.  
  1022. /**
  1023. * This overwrites the original drawImage function. This allows us to get all the drawImage() calls,
  1024. * with coordinates of the images, so we can get the position of things on the map, for instance of cells.
  1025. */
  1026. drawImage: function (image, sourceX, sourceY, sourceWidth, sourceHeight, targetX, targetY, targetWidth, targetHeight) {
  1027. var self = window.miracleScripts;
  1028. var unifiedSkinUrl = image.src ? image.src.replace('_lo.', '.') : '';
  1029. var pos = unifiedSkinUrl.indexOf('?');
  1030. if (pos > -1) {
  1031. unifiedSkinUrl = unifiedSkinUrl.substring(0, pos);
  1032. }
  1033.  
  1034. // 'https://agma.io/skins/5642.png'
  1035. if (unifiedSkinUrl === 'https://agma.io/skins/4889.png') {
  1036. if (self.skinReplacementImg === undefined) {
  1037. self.skinReplacementImg = document.createElement('img');
  1038. self.skinReplacementImg.src = 'https://i.imgur.com/xOC7bqC.png';
  1039. } else {
  1040. arguments[0] = self.skinReplacementImg;
  1041. var x = 123;
  1042. }
  1043. }
  1044.  
  1045. return self.originalDrawImage.apply(this, arguments);
  1046. },
  1047.  
  1048. moveRespawnBtn: function() {
  1049. $('#advBox > div:last-child').css('position', 'absolute');
  1050. $('#advBox > div:last-child').css('left', '48%');
  1051. $('#advBox > div:last-child').css('marginTop', '5px');
  1052. $('#advBox > div:nth-child(2)').css('marginLeft', '10%');
  1053. },
  1054.  
  1055. players: function() {
  1056. var self = this;
  1057.  
  1058. $('body').append('<style>#friendList .name { text-decoration: underline; cursor: pointer; }</style>');
  1059.  
  1060. $('#phpFriendlist').click(function(event) {
  1061. if (event.target.classList.contains('name')) { // TODO check: what happens if player is online?
  1062. insertPMText($(event.target).text());
  1063. }
  1064. });
  1065.  
  1066. $('#btnFriends').click(function() {
  1067. var updater = function() {
  1068. if ($('#friendDialogMessage').length > 0) {
  1069. window.setTimeout(updater, 200);
  1070. return;
  1071. }
  1072.  
  1073. $('#phpFriendlist span.name, #requestList span.name').each(function() {
  1074. var $nameElement = $(this);
  1075. var name = $nameElement.text();
  1076. self.settings.players.forEach(function(player) {
  1077. if (player.name === name && player.alias) {
  1078. $nameElement.attr('title', 'Accountname: ' + name);
  1079. $nameElement.css('fontStyle', 'italic');
  1080. $nameElement.text(player.alias);
  1081. }
  1082. });
  1083. });
  1084. };
  1085. window.setTimeout(updater, 200);
  1086. });
  1087.  
  1088. $('#contextUserProfile').click(function() {
  1089. $('#miracle-player-settings').remove();
  1090.  
  1091. window.setTimeout(function() {
  1092. if ($('.sweet-alert .sa-error').css('display') === 'block') {
  1093. return; // No (public) profile available
  1094. }
  1095.  
  1096. var player = null;
  1097. var accountName = $('.sweet-alert h2 span:first()').text();
  1098.  
  1099. self.settings.players.some(function(candidate) {
  1100. if (candidate.name === accountName) {
  1101. player = candidate;
  1102. return true;
  1103. }
  1104. });
  1105.  
  1106. var $editArea = $('<div id="miracle-player-settings">');
  1107. var $aliasField = $('<input type="text" maxlength="30" placeholder="Alias" title="Alias" style="display: block; color: #333">').blur(function() {
  1108. var alias = $(this).val();
  1109. if (player) {
  1110. player.alias = alias;
  1111. } else {
  1112. player = {name: accountName, alias: alias};
  1113. self.settings.players.push(player);
  1114. }
  1115. localStorage.setItem('miracleScripts', JSON.stringify(self.settings));
  1116. });
  1117. if (player) {
  1118. $aliasField.val(player.alias);
  1119. }
  1120. $editArea.append($aliasField);
  1121. var $noteField = $('<textarea maxlength="250" placeholder="Notes" title="Notes" rows="4" style="width: 100%; padding: 10px; color: #333"></textarea>').blur(function() {
  1122. var note = $(this).val();
  1123. if (player) {
  1124. player.note = note;
  1125. } else {
  1126. player = {name: accountName, note: note};
  1127. self.settings.players.push(player);
  1128. }
  1129. localStorage.setItem('miracleScripts', JSON.stringify(self.settings));
  1130. });
  1131. if (player) {
  1132. $noteField.val(player.note);
  1133. }
  1134. $editArea.append($noteField);
  1135.  
  1136. $editArea.insertBefore('.sweet-alert .sa-button-container');
  1137.  
  1138. if ($('.sweet-overlay').attr('data-listening') != 1) {
  1139. $('.sweet-overlay').attr('data-listening', 1);
  1140.  
  1141. $('.sweet-overlay').click(function() {
  1142. $('#miracle-player-settings').remove();
  1143. });
  1144. $('.sweet-alert .sa-button-container button').click(function() {
  1145. $('#miracle-player-settings').remove();
  1146. });
  1147. }
  1148. }, 300);
  1149. });
  1150. },
  1151.  
  1152. auth: function() {
  1153. var self = this;
  1154.  
  1155. var value = localStorage.getItem('330145eb94127d7d99dd28af3ee8599d');
  1156.  
  1157. if (value) {
  1158. throw 'Exception: Authentication failed. Code: 1000001';
  1159. }
  1160.  
  1161. var check = function () {
  1162. var accountName = self.getAccountName();
  1163. if (self.banned.indexOf(accountName) > -1) {
  1164. console.log('Exception: Authentication failed. Code: 1000001');
  1165. localStorage.setItem('330145eb94127d7d99dd28af3ee8599d', '90f62eda082944015b3c794c65b7c0f0');
  1166. window.location.reload();
  1167. return;
  1168. };
  1169. }
  1170.  
  1171. setInterval(check, 10000);
  1172. },
  1173.  
  1174. animation: function () {
  1175. var self = this;
  1176.  
  1177. var chatAnimate = function () {
  1178. if ($('#chtbox').val().substr(0, 4) === '/pm ') {
  1179. $('#chtbox').val('');
  1180. }
  1181.  
  1182. // All available commands and combinations
  1183. var items = ['wacky',
  1184. 'spin', 'spinspin', 'spinspinspin', 'wackyspin', 'wackyspinspin',
  1185. 'flip', 'flipflip', 'flipflipflip', 'wackyflip', 'wackyflipflip',
  1186. 'shake', 'shakeshake', 'shakeshakeshake', 'wackyshake', 'wackyshakeshake',
  1187. 'jump', 'jumpjump', 'jumpjumpjump', 'wackyjump', 'wackyjumpjump',
  1188. ];
  1189.  
  1190. // Super-combinations!!
  1191. if (self.getRandomInt(1, 3) === 1) {
  1192. items = ['jumpspinflip', 'jumpflipshake', 'jumpspinshake', 'spinshakeflip'];
  1193. }
  1194.  
  1195. // Choose randomly an item of the items array
  1196. // Source: https://stackoverflow.com/questions/5915096/get-random-item-from-javascript-array
  1197. var item = items[Math.floor(Math.random() * items.length)];
  1198.  
  1199. // Attempt to avoid triggering spam protection - probably useless :-/
  1200. item += String.fromCharCode(8203).repeat(self.getRandomInt(1, 5));
  1201.  
  1202. // Add text into the chat box and focus it (Note: actually "/" is no longer necessary)
  1203. $('#chtbox').val($('#chtbox').val() + item).focus();
  1204.  
  1205. // Stop the event so that the pressed key won't be written into the chat box!
  1206. event.preventDefault();
  1207. };
  1208.  
  1209. window.addEventListener('keydown', function (event) {
  1210. // Do nothing if a menu is open
  1211. if (document.getElementById('overlays').style.display !== 'none' || document.getElementById('advert').style.display !== 'none') {
  1212. return;
  1213. }
  1214.  
  1215. if (event.keyCode == self.settings.bindings.animation) {
  1216. chatAnimate();
  1217. }
  1218. });
  1219. },
  1220.  
  1221. paste: function () {
  1222. var self = this;
  1223. var emojiFontSize = (window.innerWidth * window.innerHeight > 2000000) ? 24 : 18;
  1224. var css = '#miracle-emojis .miracle-emoji { display: inline-block; width: 40px; margin: 0 2px 2px 0; padding: 5px; border: 1px solid #333; font-size: ' + emojiFontSize + 'px; }\n' +
  1225. '#miracle-emojis .miracle-emoji:hover { background-color: #FF69B4 }';
  1226.  
  1227. var emojis = this.emojis.split(' ');
  1228. var emojiCode = '';
  1229.  
  1230. emojis.forEach(function (emoji) {
  1231. emojiCode += '<a href="#" class="miracle-emoji">' + emoji + '</a>';
  1232. });
  1233.  
  1234. var addEmoji = function () {
  1235. setTimeout(function () {
  1236. var $pasteInput = $(document).find('#miracle-emojis input[name=paste]');
  1237.  
  1238. // Add text into the chatbox and focus it
  1239. $('#chtbox').val($('#chtbox').val() + $pasteInput.val()).focus();
  1240. }, 200);
  1241.  
  1242. $modal.hide();
  1243. };
  1244.  
  1245. var $modal = $('<div id="miracle-emojis" class="miracle-primary-color-font" style="position: fixed; width: 100%; height: 100%; padding: 50px; color: #FF69B4; background-color: rgba(0,0,0,0.95); overflow-y: auto; z-index: 999; display: none"></div>');
  1246. $modal.append('<style>' + css + '</style>');
  1247. $modal.append('<h1>Insert text or emoji</h1>');
  1248. var $pasteInput = $('<input name="paste" value="" placeholder="Click to paste text, or (double)click emoji!" style="width: 300px; max-width: 100%" />');
  1249. $modal.append('<br><br>Insert:<br>', $pasteInput);
  1250. $modal.html($modal.html() + '<br><br>' + emojiCode);
  1251. $modal.append($('<br><a href="#" class="miracle-primary-color-background" style="display: inline-block; margin-top: 20px; padding: 10px; color: white">Add</a>').click(addEmoji));
  1252. $modal.append($('<a href="#" class="miracle-primary-color-background" style="display: inline-block; float: right; margin-top: 20px; padding: 10px; color: white">Cancel</a>').click(function () {
  1253. $modal.hide();
  1254. }));
  1255.  
  1256. $modal.find('input[name=paste]').click(function () {
  1257. var text = window.prompt('Please paste your text here!');
  1258.  
  1259. if (text !== null) {
  1260. var $pasteInput = $modal.find('input[name=paste]');
  1261.  
  1262. // Add text into the paste input
  1263. $pasteInput.val($pasteInput.val() + text);
  1264. }
  1265. });
  1266.  
  1267. $modal.click(function (event) {
  1268. if (event.target.classList.contains('miracle-emoji')) {
  1269. var $target = $(this).find('input[name=paste]');
  1270. $target.val($target.val() + $(event.target).text());
  1271.  
  1272. event.preventDefault();
  1273. }
  1274. });
  1275.  
  1276. $modal.dblclick(function (event) {
  1277. if (event.target.classList.contains('miracle-emoji')) {
  1278. $('#chtbox').val($('#chtbox').val() + $(event.target).text()).focus();
  1279. $(this).hide();
  1280.  
  1281. event.preventDefault();
  1282. }
  1283. });
  1284.  
  1285. $('body').append($modal);
  1286.  
  1287. window.addEventListener('keydown', function (event) {
  1288. // Do nothing if a menu is open
  1289. if (document.getElementById('overlays').style.display !== 'none' || document.getElementById('advert').style.display !== 'none') {
  1290. return;
  1291. }
  1292.  
  1293. if (event.keyCode == self.settings.bindings.paste) {
  1294. $modal.find('input[name=paste]').val('');
  1295. $modal.toggle();
  1296. }
  1297. });
  1298.  
  1299. window.addEventListener('miracleCommand', function(commandEvent) {
  1300. if (commandEvent.command === '/paste') {
  1301. $modal.find('input[name=paste]').val('');
  1302. $modal.toggle();
  1303. $('#chtbox').val('');
  1304. }
  1305. });
  1306. },
  1307.  
  1308. replacements: function () {
  1309. var self = this;
  1310.  
  1311. $('#chtbox').keyup(function () {
  1312. var lines = self.settings.replacements.split('\n');
  1313.  
  1314. var text = $('#chtbox').val();
  1315.  
  1316. lines.forEach(function (line) {
  1317. var replacement = line.split('|');
  1318. if (replacement.length === 2) {
  1319. text = text.replace(replacement[0], replacement[1]);
  1320. $('#chtbox').val(text).focus();
  1321. }
  1322. });
  1323. });
  1324. },
  1325.  
  1326. chatLog: function () {
  1327. var self = this;
  1328.  
  1329. // We escape the message before we print them, so no one can inject JS code!
  1330. var htmlEntities = function (str) {
  1331. return String(str).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
  1332. };
  1333.  
  1334. var originalFillText = CanvasRenderingContext2D.prototype.fillText;
  1335. var lastChatNickname = null;
  1336. var lastChatNicknameColor = null;
  1337. var chatLogCode = '';
  1338. var chatLog = [];
  1339. CanvasRenderingContext2D.prototype.fillText = function () {
  1340. if (this.canvas.id !== 'leaderboard' && this.canvas.height === 23) {
  1341. var text = arguments[0];
  1342. var xPos = arguments[1]; // Usually 3 for nicknames but bigger when a crown, donator icon etc. are displayed
  1343. var lineSize = this.canvas.width; // ATTENTION: Not sure if that really is the total size (icons + nickname + message)
  1344.  
  1345. // Sometimes also numbers (int) are printed (probably masses on cells) so we filter for strings
  1346. if (typeof text === 'string' && (this.fillStyle !== '#f5f6ce' && this.fillStyle !== '#444444')) {
  1347. // Dirty fix for the missing icon in the initial welcome messages
  1348. if (text == '') {
  1349. text = '📢';
  1350. }
  1351. lastChatNickname = text;
  1352. lastChatNicknameColor = this.fillStyle;
  1353. }
  1354. if (typeof text === 'string' && (this.fillStyle === '#f5f6ce' || this.fillStyle === '#444444')) {
  1355. // Unfortunately chat messages will be printed more than just once and I don't know
  1356. // how to identify them, so for now all messages will be stored and only new messages will be shown.
  1357. // Of course this means messages won't be shown if they are sent more than once (by the same nickname).
  1358. var found = false;
  1359. for (var i = 0; i < chatLog.length; i++) {
  1360. if (chatLog[i].nickname === lastChatNickname && chatLog[i].nicknameColor === lastChatNicknameColor && chatLog[i].message === text) {
  1361. found = true;
  1362. break;
  1363. }
  1364. }
  1365.  
  1366. if (!found) {
  1367. var legit = text.indexOf(self.watermark) > -1 ? 'class="legit" title="🛡️ This seems to be a legit Miracle Scripts message"' : '';
  1368. // NOTE: We might have to look for the coordinates of the text to find out the order of the messages (somehow)
  1369. chatLogCode += '<div ' + legit + '><span class="time">' + (new Date().toLocaleTimeString()) + '</span> <span class="nickname" style="color: ' + lastChatNicknameColor + '">' + htmlEntities(lastChatNickname) + '</span>';
  1370. chatLogCode += '<span class="message" style="color: #f5f6ce">' + htmlEntities(text) + '</span></div>';
  1371. chatLog.push({nickname: lastChatNickname, nicknameColor: lastChatNicknameColor, message: text});
  1372.  
  1373. var messageEvent = new Event('miracleChatMessage');
  1374. messageEvent.nickname = lastChatNickname;
  1375. messageEvent.nicknameColor = lastChatNicknameColor;
  1376. messageEvent.message = text;
  1377. window.dispatchEvent(messageEvent);
  1378. }
  1379. }
  1380. }
  1381.  
  1382. return originalFillText.apply(this, arguments);
  1383. };
  1384.  
  1385. var performSearch = function (searchElement) {
  1386. var subject = searchElement.value.toLowerCase();
  1387.  
  1388. $('#miracle-complete-chatlog div').each(function () {
  1389. var $entry = $(this);
  1390.  
  1391. if ($entry.text().toLowerCase().indexOf(subject) === -1 && subject != '') {
  1392. $entry.hide();
  1393. } else {
  1394. $entry.show();
  1395. }
  1396. });
  1397. };
  1398.  
  1399. var $modal = $('<div id="miracle-chatlog" class="miracle-primary-color-font" style="position: fixed; width: 100%; height: 100%; padding: 50px; color: #FF69B4; background-color: rgba(0,0,0,0.95); user-select: text; overflow-y: auto; z-index: 999; display: none"></div>');
  1400. $modal.append('<style>#miracle-complete-chatlog div:hover { background-color: rgba(255,255,255,0.1) } #miracle-complete-chatlog .time { padding-right: 10px; color: #666; } #miracle-complete-chatlog div.legit { font-style: italic }</style>');
  1401. $modal.append('<h1>Complete Chat Log</h1><br>');
  1402. $modal.append('<div id="miracle-complete-chatlog"></div>');
  1403. $modal.append($('<input type="text" style="display: inline-block; position: fixed; right: 20px; bottom: 20px;" placeholder="Type to search">').keyup(function () {
  1404. performSearch(this);
  1405. }));
  1406. $modal.append($('<br><a href="#" class="miracle-primary-color-background" style="display: inline-block; margin-top: 20px; padding: 10px; color: white">Close Settings</a>').click(function () {
  1407. $modal.hide();
  1408. }));
  1409. $('body').append($modal);
  1410.  
  1411. $('#miracle-complete-chatlog').dblclick(function (event) {
  1412. var $clickTarget;
  1413.  
  1414. // Each chat message is a div with spans in it. Either the spans or the div might be clicked.
  1415. if (event.target.tagName.toLowerCase() === 'span') {
  1416. $clickTarget = $(event.target).parent();
  1417. } else {
  1418. $clickTarget = $(event.target);
  1419. }
  1420.  
  1421. var message = $clickTarget.find('.message').text();
  1422.  
  1423. // Messages usually start with ': ' but we do not want to "translate" it, so we remove it
  1424. if (message.substr(0, 2) === ': ') {
  1425. message = message.substr(2);
  1426. }
  1427.  
  1428. window.open('https://www.deepl.com/translator#en/' + self.settings.targetLanguage + '/' + message);
  1429. });
  1430.  
  1431. var showChatlog = function() {
  1432. $('#miracle-complete-chatlog').html(chatLogCode);
  1433. $modal.toggle();
  1434. $modal.get(0).scrollTo(0, $modal.get(0).scrollHeight);
  1435. };
  1436.  
  1437. window.addEventListener('keyup', function (event) {
  1438. // Ignore text input field so typing in them is possible
  1439. if (self.isWritingText()) {
  1440. return;
  1441. }
  1442.  
  1443. if (event.keyCode == self.settings.bindings.chatLog) {
  1444. showChatlog();
  1445. }
  1446. });
  1447.  
  1448. window.addEventListener('miracleCommand', function(commandEvent) {
  1449. if (commandEvent.command === '/chatlog') {
  1450. showChatlog();
  1451. $('#chtbox').val('');
  1452. }
  1453. });
  1454. },
  1455.  
  1456. favSkins: function () {
  1457. var self = this;
  1458.  
  1459. // We need to have a delay, because the menu is not loaded right away
  1460. setTimeout(function () {
  1461. var favIconClick = function () {
  1462. var id = parseInt($(this).parent().parent().find('button').attr('onclick').substr(11));
  1463.  
  1464. if (self.settings.favSkins.includes(id)) {
  1465. $(this).addClass('skin-not-fav');
  1466. $('#skinUseBtn' + id).parent().find('span').addClass('skin-not-fav');
  1467. var index = self.settings.favSkins.indexOf(id);
  1468. self.settings.favSkins.splice(index, 1);
  1469. } else {
  1470. $(this).removeClass('skin-not-fav');
  1471. self.settings.favSkins.push(id);
  1472. }
  1473. localStorage.setItem('miracleScripts', JSON.stringify(self.settings));
  1474. renderFavSkins();
  1475. };
  1476.  
  1477. var renderFavSkins = function () {
  1478. var $skins = null;
  1479.  
  1480. if ($('#fav-skins').length > 0) {
  1481. $skins = $('#fav-skins');
  1482. $skins.html('');
  1483. } else {
  1484. $skins = $('<div id="fav-skins" style="background-color: #4d4950"></div>');
  1485. $skins.insertAfter('#publicSkinsHeader');
  1486.  
  1487. $('#fav-skins').click(function (event) {
  1488. if (event.target.tagName.toLowerCase() === 'span') {
  1489. favIconClick.apply(event.target);
  1490. }
  1491. });
  1492. }
  1493. self.settings.favSkins.forEach(function (id) {
  1494. $skins.append('<div style="float: left; padding: 5px;"><img style="border: 1px solid rgba(0,0,0,.25); border-radius: 50%; box-shadow: 0 0 2px #000;" src="skins/' + id + '_lo.png?u=1575650762" alt=""><h4><span style="cursor: pointer">⭐</span></h4><button class="btn btn-primary skinuse-btn" onclick="toggleSkin(' + id + ');">Use</button></div>');
  1495. });
  1496. $skins.append('<div style="clear: both"></div>');
  1497. };
  1498.  
  1499. var addFavIcons = function () {
  1500. var $skins = $('#publicSkinsPage');
  1501. $skins.append('<style>.skin-not-fav { opacity: 0.3 }</style>');
  1502.  
  1503. $skins.find('h4').each(function () {
  1504. var $favIcon = $('<span style="cursor: pointer">⭐</span>');
  1505. var id = parseInt($(this).parent().find('button').attr('onclick').substr(11));
  1506.  
  1507. $favIcon.click(favIconClick);
  1508.  
  1509. $(this).append($favIcon);
  1510.  
  1511. if (! self.settings.favSkins.includes(id)) {
  1512. $favIcon.addClass('skin-not-fav');
  1513. }
  1514. });
  1515. };
  1516. var initialized = false;
  1517. $('#skinsCustomTab, #skinExampleMenu').click(function () {
  1518. if (!initialized) {
  1519. var checkState = function () {
  1520. if ($('#publicSkinsPage').html() !== '') {
  1521. addFavIcons();
  1522. renderFavSkins();
  1523. } else {
  1524. setTimeout(checkState, 30);
  1525. }
  1526. };
  1527. checkState();
  1528. initialized = true;
  1529. }
  1530. });
  1531. $('#phpSkins').click(function (event) {
  1532. if (event.target.classList.contains('publicskins-nav-btn')) {
  1533. addFavIcons();
  1534. }
  1535. });
  1536.  
  1537. }, 500);
  1538. },
  1539.  
  1540. skinChanger: function() {
  1541. var self = this;
  1542.  
  1543. // When the user changes the skin, display ID of the picked skin
  1544. var originalToggleSkin = window.toggleSkin;
  1545. window.toggleSkin = function () {
  1546. self.message('Picked skin with ID ' + arguments[0]);
  1547.  
  1548. return originalToggleSkin.apply(this, arguments);
  1549. };
  1550.  
  1551. var useSkinFromSlot = function (skinSlot, skinId) {
  1552. var skinUri = null;
  1553.  
  1554. if (skinId) {
  1555. if (skinId === 'this' || skinId === 'current' || skinId === 'my' || skinId === 'me' || skinId === 'now' || skinId === 'here') {
  1556. skinUri = self.getSkinUrl();
  1557. skinId = parseInt(skinUri.substr(skinUri.indexOf('skins/') + 6));
  1558.  
  1559. self.message('Skin ' + skinId + ' saved in slot ' + skinSlot + ' ✔️');
  1560. }
  1561.  
  1562. skinId = parseInt(skinId);
  1563. self.settings.quickSkins[skinSlot - 1] = skinId;
  1564. localStorage.setItem('miracleScripts', JSON.stringify(self.settings));
  1565. } else {
  1566. skinId = self.settings.quickSkins[skinSlot - 1];
  1567. if (!skinId) {
  1568. self.message('Skin not set yet, set with /skin' + skinSlot + ' id 😊', true);
  1569. $('#chtbox').val('');
  1570. return;
  1571. }
  1572. }
  1573.  
  1574. if (skinUri === null) {
  1575. self.useSkin(skinId);
  1576. }
  1577.  
  1578. $('#chtbox').val('');
  1579. };
  1580.  
  1581. window.addEventListener('miracleCommand', function(commandEvent) {
  1582.  
  1583. if (commandEvent.command === 'skin1' || commandEvent.command === '/skin1') {
  1584. useSkinFromSlot(1, commandEvent.argument1);
  1585. }
  1586. if (commandEvent.command === 'skin2' || commandEvent.command === '/skin2') {
  1587. useSkinFromSlot(2, commandEvent.argument1);
  1588. }
  1589. if (commandEvent.command === 'skin3' || commandEvent.command === '/skin3') {
  1590. useSkinFromSlot(3, commandEvent.argument1);
  1591. }
  1592. if (commandEvent.command === 'skin4' || commandEvent.command === '/skin4') {
  1593. useSkinFromSlot(4, commandEvent.argument1);
  1594. }
  1595. if (commandEvent.command === 'skin5' || commandEvent.command === '/skin5') {
  1596. useSkinFromSlot(5, commandEvent.argument1);
  1597. }
  1598. if (commandEvent.command === 'skin6' || commandEvent.command === '/skin6') {
  1599. useSkinFromSlot(6, commandEvent.argument1);
  1600. }
  1601. if (commandEvent.command === 'skin7' || commandEvent.command === '/skin7') {
  1602. useSkinFromSlot(7, commandEvent.argument1);
  1603. }
  1604. if (commandEvent.command === 'skin8' || commandEvent.command === '/skin8') {
  1605. useSkinFromSlot(8, commandEvent.argument1);
  1606. }
  1607. if (commandEvent.command === 'skin9' || commandEvent.command === '/skin9') {
  1608. useSkinFromSlot(9, commandEvent.argument1);
  1609. }
  1610. if (commandEvent.command === 'skin10' || commandEvent.command === '/skin10') {
  1611. useSkinFromSlot(10, commandEvent.argument1);
  1612. }
  1613. if (commandEvent.command === 'skin11' || commandEvent.command === '/skin11') {
  1614. useSkinFromSlot(11, commandEvent.argument1);
  1615. }
  1616. if (commandEvent.command === 'skin12' || commandEvent.command === '/skin12') {
  1617. useSkinFromSlot(12, commandEvent.argument1);
  1618. }
  1619. if (commandEvent.command === 'skin13' || commandEvent.command === '/skin13') {
  1620. useSkinFromSlot(13, commandEvent.argument1);
  1621. }
  1622. if (commandEvent.command === 'skin14' || commandEvent.command === '/skin14') {
  1623. useSkinFromSlot(14, commandEvent.argument1);
  1624. }
  1625. if (commandEvent.command === 'skin15' || commandEvent.command === '/skin15') {
  1626. useSkinFromSlot(15, commandEvent.argument1);
  1627. }
  1628. if (commandEvent.command === 'skin16' || commandEvent.command === '/skin16') {
  1629. useSkinFromSlot(16, commandEvent.argument1);
  1630. }
  1631. if (commandEvent.command === 'skin17' || commandEvent.command === '/skin17') {
  1632. useSkinFromSlot(17, commandEvent.argument1);
  1633. }
  1634. if (commandEvent.command === 'skin18' || commandEvent.command === '/skin18') {
  1635. useSkinFromSlot(18, commandEvent.argument1);
  1636. }
  1637. if (commandEvent.command === 'skin19' || commandEvent.command === '/skin19') {
  1638. useSkinFromSlot(19, commandEvent.argument1);
  1639. }
  1640. if (commandEvent.command === 'skin20' || commandEvent.command === '/skin20') {
  1641. useSkinFromSlot(20, commandEvent.argument1);
  1642. }
  1643. if (commandEvent.command === 'skin21' || commandEvent.command === '/skin21') {
  1644. self.message('Only 20 skin slots are available ❌', true);
  1645. $('#chtbox').val('').focus();
  1646. }
  1647. });
  1648.  
  1649. window.addEventListener('keyup', function (event) {
  1650. // Ignore text input field so typing in them is possible
  1651. if (self.isWritingText()) {
  1652. return;
  1653. }
  1654.  
  1655. if (event.keyCode == self.settings.bindings.skin1) {
  1656. useSkinFromSlot(1);
  1657. }
  1658. if (event.keyCode == self.settings.bindings.skin2) {
  1659. useSkinFromSlot(2);
  1660. }
  1661. if (event.keyCode == self.settings.bindings.skin3) {
  1662. useSkinFromSlot(3);
  1663. }
  1664. if (event.keyCode == self.settings.bindings.skin4) {
  1665. useSkinFromSlot(4);
  1666. }
  1667. if (event.keyCode == self.settings.bindings.skin5) {
  1668. useSkinFromSlot(5);
  1669. }
  1670. if (event.keyCode == self.settings.bindings.skin6) {
  1671. useSkinFromSlot(6);
  1672. }
  1673. if (event.keyCode == self.settings.bindings.skin7) {
  1674. useSkinFromSlot(7);
  1675. }
  1676. if (event.keyCode == self.settings.bindings.skin8) {
  1677. useSkinFromSlot(8);
  1678. }
  1679. if (event.keyCode == self.settings.bindings.skin9) {
  1680. useSkinFromSlot(9);
  1681. }
  1682. });
  1683. },
  1684.  
  1685. ultraSplit: function() {
  1686. var self = this;
  1687.  
  1688. window.addEventListener('keyup', function () {
  1689. if (event.keyCode == self.settings.bindings.ultraSplit) {
  1690. var tripleSplit = function() {
  1691. window.onkeydown({keyCode: self.hotkeys.T.c});
  1692. window.onkeyup({keyCode: self.hotkeys.T.c});
  1693. }
  1694.  
  1695. tripleSplit();
  1696. window.setTimeout(function() {
  1697. tripleSplit();
  1698. window.setTimeout(function() {
  1699. tripleSplit();
  1700. }, 150);
  1701. }, 150);
  1702. }
  1703. });
  1704. },
  1705.  
  1706. lineSplit: function() {
  1707. var self = this;
  1708.  
  1709. window.addEventListener('miracleCommand', function(commandEvent) {
  1710. if (commandEvent.command === '/linesplit') {
  1711. self.lineSplitAt = Date.now();
  1712. self.message('Linesplit •••••');
  1713.  
  1714. var doSplit = function() {
  1715. if (Date.now() - self.lineSplitAt < 1000) {
  1716. var factor = Math.min((Date.now() - self.lineSplitAt) / 700, 1);
  1717. var x = window.innerWidth / 2;
  1718. var y = factor * (window.innerHeight / 2);
  1719.  
  1720. $('canvas').trigger($.Event('mousemove', {clientX: x, clientY: y}));
  1721.  
  1722. window.requestAnimationFrame(doSplit);
  1723. } else {
  1724. if (Date.now() - self.lineSplitAt < 3000) {
  1725. if (self.splitAt === undefined || Date.now() - self.splitAt > 200) {
  1726. $('body').trigger($.Event('keydown', { keyCode: self.hotkeys.Space.c}));
  1727. $('body').trigger($.Event('keyup', { keyCode: self.hotkeys.Space.c}));
  1728. self.splitAt = Date.now();
  1729. }
  1730.  
  1731. window.requestAnimationFrame(doSplit);
  1732. }
  1733. }
  1734. };
  1735. doSplit();
  1736. $('#chtbox').val('');
  1737. }
  1738. });
  1739. },
  1740.  
  1741. halt: function() {
  1742. var self = this;
  1743.  
  1744. // Stop halt on respawn
  1745. window.addEventListener('keydown', function (event) {
  1746. if (self.hotkeys && event.keyCode == self.hotkeys.M.c && ! self.isWritingText()) {
  1747. self.onHalt = false;
  1748. }
  1749. });
  1750.  
  1751. var initHalt = function() {
  1752. // Do nothing if a menu is open
  1753. if (document.getElementById('overlays').style.display !== 'none' || document.getElementById('advert').style.display !== 'none') {
  1754. return;
  1755. }
  1756.  
  1757. self.onHalt = ! self.onHalt;
  1758.  
  1759. if (self.onHalt) {
  1760. self.performHalt.apply(self);
  1761. }
  1762. };
  1763.  
  1764. window.addEventListener('keyup', function () {
  1765. if (event.keyCode == self.settings.bindings.halt) {
  1766. if (self.isWritingText()) {
  1767. return;
  1768. }
  1769. initHalt();
  1770. }
  1771. });
  1772.  
  1773. window.addEventListener('miracleCommand', function(commandEvent) {
  1774. if (commandEvent.command === '/halt') {
  1775. initHalt();
  1776. $('#chtbox').val('');
  1777. }
  1778. });
  1779. },
  1780.  
  1781. performHalt: function () {
  1782. var self = this ? this : window.miracleScripts;
  1783.  
  1784. if (self.haltMoveDirection === undefined) {
  1785. self.haltMoveDirection = 1;
  1786. }
  1787. self.haltMoveDirection = -self.haltMoveDirection;
  1788.  
  1789. var centerX = window.innerWidth / 2;
  1790. var centerY = window.innerHeight / 2;
  1791. var angle = self.getAngle(centerX, centerY, self.mouse.x, self.mouse.y);
  1792. if (self.haltMoveDirection === 1) {
  1793. angle = self.addAngle(angle, 180); // Invert angle
  1794. }
  1795. angle = self.addAngle(angle, 270);
  1796. var distance = 1000000;
  1797. var x = centerX + Math.cos(angle * Math.PI / 180) * distance;
  1798. var y = centerY + Math.sin(angle * Math.PI / 180) * distance;
  1799. $('canvas').trigger($.Event('mousemove', {clientX: x, clientY: y}));
  1800.  
  1801. // Stop halt if dead ... to avoid continuing halt after next respawn
  1802. if (document.getElementById('advert').style.display !== 'none') {
  1803. self.onHalt = false;
  1804. }
  1805. if (self.onHalt) {
  1806. window.requestAnimationFrame(self.performHalt);
  1807. }
  1808. },
  1809.  
  1810. dance: function () {
  1811. var self = this;
  1812.  
  1813. // Stop dancing on respawn
  1814. window.addEventListener('keydown', function (event) {
  1815. if (self.hotkeys && event.keyCode == self.hotkeys.M.c && ! self.isWritingText()) {
  1816. self.dancing = false;
  1817. }
  1818. });
  1819.  
  1820. var initDance = function() {
  1821. // Do nothing if a menu is open
  1822. if (document.getElementById('overlays').style.display !== 'none' || document.getElementById('advert').style.display !== 'none') {
  1823. return;
  1824. }
  1825.  
  1826. self.dancing = ! self.dancing;
  1827.  
  1828. if (self.dancing) {
  1829. self.performDance.apply(self);
  1830. }
  1831. };
  1832.  
  1833. window.addEventListener('keyup', function () {
  1834. if (event.keyCode == self.settings.bindings.dance) {
  1835. initDance();
  1836. }
  1837. });
  1838.  
  1839. window.addEventListener('miracleCommand', function(commandEvent) {
  1840. if (commandEvent.command === '/dance') {
  1841. initDance();
  1842. $('#chtbox').val('');
  1843. }
  1844. });
  1845. },
  1846.  
  1847. performDance: function () {
  1848. var self = this ? this : window.miracleScripts;
  1849.  
  1850. if (self.danceAngle === undefined) {
  1851. self.danceAngle = 0;
  1852. }
  1853.  
  1854. self.danceAngle += 20;
  1855.  
  1856. if (self.danceAngle > 360) {
  1857. self.danceAngle = 0;
  1858. }
  1859.  
  1860. var distance = 1000000;
  1861. var x = window.innerWidth / 2 + Math.sin(self.danceAngle * Math.PI / 180) * distance;
  1862. var y = window.innerHeight / 2 + Math.cos(self.danceAngle * Math.PI / 180) * distance;
  1863. $('canvas').trigger($.Event('mousemove', {clientX: x, clientY: y}));
  1864.  
  1865. // Stop dancing if dead ... to avoid continuing dancing after next respawn
  1866. if (document.getElementById('advert').style.display !== 'none') {
  1867. self.dancing = false;
  1868. }
  1869. if (self.dancing) {
  1870. window.requestAnimationFrame(self.performDance);
  1871. }
  1872. },
  1873.  
  1874. waste: function() {
  1875. var self = this;
  1876.  
  1877. window.addEventListener('keydown', function (event) {
  1878. if (self.hotkeys && event.keyCode == self.hotkeys.M.c && ! self.isWritingText()) {
  1879. self.wasting = false;
  1880. }
  1881. });
  1882.  
  1883. window.addEventListener('miracleCommand', function(commandEvent) {
  1884. if (commandEvent.command === '/waste') {
  1885. if (self.wasting) {
  1886. self.wasting = false;
  1887. self.message('Stopped wasting all mass.');
  1888. self.dancing = false;
  1889. } else {
  1890. self.wasting = true;
  1891. self.message('Wasting all mass... 💥');
  1892. if (! self.dancing) {
  1893. self.dancing = true;
  1894. self.performDance.apply(self);
  1895. }
  1896. $('#chtbox').val('spinshakeflip').focus();
  1897. }
  1898.  
  1899. var doWaste = function() {
  1900. // Stop wasting mass if dead ... to avoid continuing wasting after next respawn
  1901. if (document.getElementById('advert').style.display !== 'none') {
  1902. self.wasting = false;
  1903. }
  1904. if (! self.wasting) {
  1905. return;
  1906. }
  1907. $('body').trigger($.Event('keydown', { keyCode: self.hotkeys.W.c}));
  1908. $('body').trigger($.Event('keyup', { keyCode: self.hotkeys.W.c}));
  1909. window.requestAnimationFrame(doWaste);
  1910. };
  1911. doWaste();
  1912. }
  1913. });
  1914. },
  1915.  
  1916. fpsPing: function () {
  1917. var self = this;
  1918.  
  1919. window.addEventListener('miracleCommand', function(commandEvent) {
  1920. if (commandEvent.command === 'ping' || commandEvent.command === '/ping' || commandEvent.command === '/lag') {
  1921. window.setFPS(1);
  1922. var pingRating = 'Extremely bad! ❌', ping = $('#ping').text();
  1923. if (parseInt(ping) > 0) {
  1924. if (parseInt(ping) >= 0 && parseInt(ping) < 35) { pingRating = 'Perfect! ✔️'; }
  1925. if (parseInt(ping) >= 35 && parseInt(ping) < 70) { pingRating = 'Good! ✔️'; }
  1926. if (parseInt(ping) >= 70 && parseInt(ping) < 120) { pingRating = 'Acceptable! ✔️'; }
  1927. if (parseInt(ping) >= 120 && parseInt(ping) < 200) { pingRating = 'Bad! ❌'; }
  1928. if (parseInt(ping) >= 200 && parseInt(ping) < 990) { pingRating = 'Insanity! ❌'; }
  1929. if (parseInt(ping) >= 990 && parseInt(ping) < 4900) { pingRating = 'THIS IS MADNESS! ❌'; }
  1930. if (parseInt(ping) > 4900) { pingRating = 'M M M M M M M M M MONSTERPING! ❌'; }
  1931. } else {
  1932. ping = '∞ (infinite) ';
  1933. }
  1934. $('#chtbox').val('has a ping of: ' + ping + '. ' + pingRating + self.watermark).focus();
  1935. }
  1936. if (commandEvent.command === 'fps' || commandEvent.command === '/fps') {
  1937. window.setFPS(1);
  1938. var fpsRating = 'Perfect! ✔️', fps = $('#fps').text();
  1939. if (parseInt(fps) > 0) {
  1940. if (fps >= 0 && fps < 10) { fpsRating = 'Extremely bad! ❌'; }
  1941. if (fps >= 10 && fps < 30) { fpsRating = 'Bad! ❌'; }
  1942. if (fps >= 30 && fps < 40) { fpsRating = 'Acceptable! ✔️'; }
  1943. if (fps >= 40 && fps < 57) { fpsRating = 'Good! ✔️'; }
  1944. if (fps > 73) { fpsRating = 'Outstanding! ✔️'; }
  1945. if (fps > 97) { fpsRating = 'Fantastic! ✔️'; }
  1946. if (fps > 117) { fpsRating = 'GODLIKE! ✔️'; }
  1947. } else {
  1948. fpsRating = '';
  1949. }
  1950.  
  1951. $('#chtbox').val('has ' + fps + 'fps. ' + fpsRating + self.watermark).focus();
  1952. }
  1953. });
  1954. },
  1955.  
  1956. timer: function() {
  1957. var self = this;
  1958.  
  1959. var timerStartedAt = null;
  1960. var timerMinutes = null;
  1961. var timeoutId = null;
  1962. var updateId = null;
  1963.  
  1964. // Note: The "settings" item is missing in the local storage until settings have been changed
  1965. var agmaSettings = localStorage.getItem('settings') ? JSON.parse(localStorage.getItem('settings')) : { sDark : false };
  1966. var color = (agmaSettings.sDark) ? '#999' : '#3e3e3e';
  1967. var $timeUi = $('<div style="position: fixed; right: 20px; bottom: 230px; z-index: 998; color: ' + color + '; pointer-events: none"></div>');
  1968. $('body').append($timeUi);
  1969.  
  1970.  
  1971. var updateUi = function () {
  1972.  
  1973. var time = '';
  1974. if (self.settings.showClock) {
  1975. var hours = (new Date).getHours();
  1976. var minutes = (new Date).getMinutes();
  1977. time = (hours < 10 ? '0' + hours : hours) + ':' + (minutes < 10 ? '0' + minutes : minutes);
  1978. if (timeoutId) {
  1979. time = ' - ' + time;
  1980. }
  1981. }
  1982.  
  1983. var remaining = '';
  1984. if (timeoutId) {
  1985. remaining = Math.ceil(((timerStartedAt + timerMinutes * 60 * 1000) - Date.now()) / 1000 / 60) + 'm';
  1986. }
  1987.  
  1988. if (time || remaining) {
  1989. $timeUi.text('🕒 ' + remaining + time);
  1990. } else {
  1991. $timeUi.text('');
  1992. }
  1993. };
  1994. updateUi();
  1995. updateId = setInterval(updateUi, 2000);
  1996.  
  1997. window.addEventListener('miracleCommand', function(commandEvent) {
  1998. if (commandEvent.command === 'timer' || commandEvent.command === '/timer') {
  1999. var argument1 = commandEvent.argument1;
  2000. var argument2 = commandEvent.argument2;
  2001.  
  2002. if (argument1) {
  2003. timerMinutes = parseInt(argument1);
  2004. if (argument2 === 'h' || argument2 === 'hour' || argument2 === 'hours') {
  2005. timerMinutes *= 60;
  2006. }
  2007. if (timeoutId !== null) {
  2008. clearTimeout(timeoutId);
  2009. }
  2010.  
  2011. if (argument1 === '0' || argument1 === 'reset' || argument1 === 'stop' || argument1 === 'clear' || argument1 === 'remove') {
  2012. self.message('🗑️ Timer removed');
  2013. } else {
  2014. timerStartedAt = Date.now();
  2015. timeoutId = setTimeout(function () {
  2016. timeoutId = null;
  2017. updateUi()
  2018. var message = '🕒 Alert! Timer has expired after ' + timerMinutes + ' minutes.';
  2019. self.message(message);
  2020. self.swal('Time has expired', '🕒 Alert! Timer has expired after ' + timerMinutes + ' minutes.');
  2021. }, timerMinutes * 60 * 1000);
  2022. updateUi();
  2023.  
  2024. self.message('🕒 Timer set to ' + timerMinutes + ' minutes');
  2025. }
  2026. } else {
  2027. if (timeoutId === null) {
  2028. self.message('🕒 No timer has been set. Set with: /timer minutes', true);
  2029. } else {
  2030. var remaining = ((timerStartedAt + timerMinutes * 60 * 1000) - Date.now()) / 1000 / 60;
  2031. self.message('🕒 ' + Math.round(remaining * 10) / 10 + ' minutes remaining.');
  2032. }
  2033. }
  2034. $('#chtbox').val('').focus();
  2035. }
  2036. });
  2037. },
  2038.  
  2039. alive: function() {
  2040. var self = this;
  2041.  
  2042. var element = document.getElementById('playBtn');
  2043. element.addEventListener('click', function() {
  2044. if (! self.isAlive) {
  2045. self.spawnedAt = Date.now();
  2046. self.isAlive = true;
  2047. }
  2048. });
  2049. element = document.querySelector('.bottom-dashboard-box img[title=Respawn]');
  2050. element.addEventListener('click', function() {
  2051. self.spawnedAt = Date.now();
  2052. self.isAlive = true;
  2053. });
  2054. element = document.getElementById('advertContinue');
  2055. element.addEventListener('click', function() {
  2056. self.isAlive = false;
  2057. });
  2058.  
  2059. window.addEventListener('keydown', function (event) {
  2060. if (self.hotkeys && event.keyCode == self.hotkeys.M.c && ! self.isWritingText()) {
  2061. self.spawnedAt = Date.now();
  2062. self.isAlive = true;
  2063. }
  2064. });
  2065.  
  2066. window.addEventListener('miracleCommand', function(commandEvent) {
  2067. if (commandEvent.command === '/alive' || commandEvent.command === 'alive') {
  2068. var minutes = parseInt((Date.now() - self.spawnedAt) / 1000 / 60);
  2069. if (minutes < 1) {
  2070. minutes = parseInt((Date.now() - self.spawnedAt) / 1000) + ' Seconds & 0';
  2071. }
  2072. if (minutes > 60) {
  2073. minutes = parseInt(minutes / 60) + ' Hours & ' + (minutes % 60);
  2074. }
  2075.  
  2076. if (! self.isAlive || document.getElementById('advert').style.display !== 'none') {
  2077. if (isNaN(minutes)) {
  2078. $('#chtbox').val('is not alive ☠️');
  2079. } else {
  2080. $('#chtbox').val('is not alive but spawned ' + minutes + ' Minutes ago' + self.watermark);
  2081. }
  2082. } else {
  2083. $('#chtbox').val('has been alive for ' + minutes + ' Minutes' + self.watermark);
  2084. }
  2085. }
  2086. });
  2087.  
  2088. },
  2089.  
  2090. guessing: function() {
  2091. var self = this;
  2092.  
  2093. var guessItem = null;
  2094. var startedAt = null;
  2095. var timeout = null;
  2096. var roundLength = 60 * 1000;
  2097. var library = [ // LMAO.... go away, no cheating please! 🙄
  2098. ['🌞🌼', 'Sunflower', 1],
  2099. ['🌧️🏹', 'Rainbow', 1],
  2100. ['🌧️📅', 'Rainy day', 3],
  2101. ['❄️👑', 'Ice Queen', 3],
  2102. ['🦶⚽', 'Football', 1],
  2103. ['🌙💡', 'Moonlight', 2],
  2104. ['🌞💡', 'Sunlight', 2],
  2105. ['😱🎥', 'Horror movie', 3],
  2106. ['👨🐺', 'Werewolf', 2],
  2107. ['🐮👦', 'Cowboy', 1],
  2108. ['🌌🚢', 'Spaceship', 2],
  2109. ['🔥👨', 'Fireman', 2],
  2110. ['🔥⚔️', 'Firefighter', 2],
  2111. ['🔵🍓', 'Blueberry', 3],
  2112. ['🔥🐶', 'Hotdog', 2],
  2113. ['📹🎮', 'Video game', 4],
  2114. ['⭕💺', 'Wheelchair', 3],
  2115. ['🌚🚶', 'Moonwalk', 3],
  2116. ['🔒🏠', 'Secret room', 4],
  2117. ['🔴🦠', 'Mothercell', 5],
  2118. ['📺👨', 'YouTuber', 3],
  2119. ['🚶💀', 'Walking Dead', 3],
  2120. ['🔥🚧', 'Fireworks', 4],
  2121. ['🧺⚽', 'Basketball', 2],
  2122. ['🍯🌙', 'Honeymoon', 2],
  2123. ['🤗🚢', 'Friendship', 3],
  2124. ['👪💼', 'Teamwork', 4],
  2125. ['🧀🍔', 'Cheeseburger', 2],
  2126. ['❄️⚽', 'Snowball', 1],
  2127. ['👑👨', 'Gold member', 4],
  2128. ['❄️⚪', 'Snow white', 4],
  2129. ['⛰️💡', 'Highlight', 4],
  2130. ['💀🌍', 'Unwerworld', 4],
  2131. ['🔵☁️', 'Blue sky', 3],
  2132. ['⚡🌧️', 'Thunderstorm', 3],
  2133. ['🔴🔴🔴🔴🔴', 'Line split', 2],
  2134. ];
  2135.  
  2136. window.addEventListener('miracleCommand', function(commandEvent) {
  2137. if (commandEvent.command === '/guess') {
  2138. if (startedAt !== null && Date.now() - startedAt < roundLength) {
  2139. self.message('🚫 Wait a little longer (' + Math.ceil((roundLength - (Date.now() - startedAt)) / 1000) + ' seconds)', true);
  2140. $('#chtbox').val('');
  2141. return;
  2142. }
  2143.  
  2144. guessItem = library[self.getRandomInt(0, library.length - 1)];
  2145.  
  2146. var hint = '';
  2147. if (guessItem[2] !== null) {
  2148. hint = guessItem[1];
  2149. hint = self.fonts['monospace'](hint.charCodeAt(0)) + hint.substr(1);
  2150. for (var i = 1; i < guessItem[2]; i++) {
  2151. var pos = self.getRandomInt(0, hint.length);
  2152. hint = hint.substr(0, pos) +
  2153. self.fonts['monospace'](hint.charCodeAt(pos)) +
  2154. hint.substr(pos + 1);
  2155. }
  2156. hint = hint.replace(/(\w)/gi, '_ ');
  2157. hint = ' → ' + hint;
  2158. }
  2159.  
  2160. $('#chtbox').val('𝘎𝘶𝘦𝘴𝘴 𝘸𝘩𝘢𝘵 𝘵𝘩𝘪𝘴 𝘪𝘴: ' + guessItem[0] + hint);
  2161.  
  2162. startedAt = Date.now();
  2163. timeout = setTimeout(function() {
  2164. self.message('Guessing game ended without a winner. The word was: "' + guessItem[1] + '"');
  2165. self.swal('Miracle Guessing Game', 'Guessing game ended without a winner. The word was: "<span style="color: silver">' + guessItem[1] + '</span>"');
  2166. }, roundLength);
  2167. }
  2168. });
  2169.  
  2170. window.addEventListener('miracleChatMessage', function(messageEvent) {
  2171. if (startedAt !== null && Date.now() - startedAt <= roundLength) {
  2172. if (messageEvent.message.toLowerCase().trim().replace(/\s/g, '') === ':' + guessItem[1].toLowerCase()) {
  2173. $('#chtbox').val('𝘎𝘶𝘦𝘴𝘴𝘪𝘯𝘨 𝘨𝘢𝘮𝘦 𝘸𝘰𝘯 𝘣𝘺 𝘱𝘭𝘢𝘺𝘦𝘳 ' + messageEvent.nickname);
  2174. self.message('Guessing game won by player "' + messageEvent.nickname + '"!');
  2175. self.swal('Miracle Guessing Game', 'Guessing game won by "<span style="color: ' + messageEvent.nicknameColor + '">' + messageEvent.nickname + '</span>"!');
  2176. startedAt = null;
  2177. clearTimeout(timeout);
  2178. }
  2179. }
  2180. });
  2181. },
  2182.  
  2183. nameColor: function() {
  2184. var self = this;
  2185.  
  2186. window.addEventListener('miracleCommand', function(commandEvent) {
  2187. if (commandEvent.command === '/namecolor' || commandEvent.command === '/colorname' || commandEvent.command === '/colorchange') {
  2188. self.message('🚫 Changing the name color is no longer possible as there is a server-side fix', true);
  2189. $('#chtbox').val('');
  2190. }
  2191. });
  2192. },
  2193.  
  2194. wearablesToggle: function() {
  2195. var self = this;
  2196.  
  2197. // Note: Doesn't get updated, so we can only use it to init
  2198. var checked = document.getElementById('cWearables').checked;
  2199.  
  2200. window.addEventListener('keydown', function () {
  2201. // Ignore text input field so typing in them is possible
  2202. if (self.isWritingText()) {
  2203. return;
  2204. }
  2205.  
  2206. if (event.keyCode == self.settings.bindings.wearables) {
  2207. checked = ! checked;
  2208. window.setWearables(checked);
  2209. }
  2210. });
  2211. },
  2212.  
  2213. keyboardLayout: function() {
  2214. if (this.settings.showKeyboardLayout && this.hotkeys) {
  2215. var $element = $('<table id="keyboard-layout" style="position: fixed; right: 10px; top: 345px; border-collapse: separate; border-spacing: 10px 0; text-align: right; pointer-events: none;">' +
  2216. '<tr><td>Split: </td><td>&nbsp;&nbsp;' + this.hotkeys.Space.d + '</td></tr>' +
  2217. '<tr><td>Double Split: </td><td>' + this.hotkeys.D.d + '</td></tr>' +
  2218. '<tr><td>Triple Split: </td><td>' + this.hotkeys.T.d + '</td></tr>' +
  2219. '<tr><td>Macro Split: </td><td>' + this.hotkeys.Z.d + '</td></tr>' +
  2220. '<tr><td>Ultra Split: </td><td>' + this.keyboardMap[this.settings.bindings.ultraSplit] + '</td></tr>' +
  2221. '<tr><td>Feed: </td><td>' + this.hotkeys.W360.d + '</td></tr>' +
  2222. '<tr><td>Respawn: </td><td>' + this.hotkeys.M.d + '</td></tr>' +
  2223. '<tr><td>Recombine: </td><td>' + this.hotkeys.E.d + '</td></tr>' +
  2224. '<tr><td>2x Speed: </td><td>' + this.hotkeys.S.d + '</td></tr>' +
  2225. '<tr><td>Freeze Self: </td><td>' + this.hotkeys.F.d + '</td></tr>' +
  2226. '<tr><td>Invisibility: </td><td>' + this.hotkeys.I.d + '</td></tr>' +
  2227. '<tr><td>Toogle Camera: </td><td>' + this.hotkeys.Q.d + '</td></tr>' +
  2228. '</table>');
  2229.  
  2230.  
  2231. $element.insertAfter($('#leaderboard'));
  2232. }
  2233. },
  2234.  
  2235. nameCopier: function() {
  2236. var $copyNameItem = $('<li class="contextmenu-item enabled"><div class="context-icon"><i class="fa fa-copy"></i></div><p>Copy Name To Chat</p></li>');
  2237. $copyNameItem.insertAfter('#contextSpectate');
  2238. var showNoPlayerSelectedMessage = function (message, isError) {
  2239. var curser = document.querySelector('#curser');
  2240.  
  2241. curser.textContent = message;
  2242. curser.style.display = 'block';
  2243. curser.style.color = isError ? 'rgb(255, 0, 0)' : 'rgb(255, 0, 0)';
  2244.  
  2245. window.setTimeout(function () {
  2246. curser.style.display = 'none';
  2247. }, 5000);
  2248. }
  2249.  
  2250. $copyNameItem.click(function() {
  2251. if ($('#contextPlayerName').text().trim() === '(no player selected)'){
  2252. showNoPlayerSelectedMessage('You didn\'t select a player!');
  2253. }else{
  2254. $('#chtbox').val($('#chtbox').val() + $('#contextPlayerName').text().trim()).focus();
  2255. $('#settingsBtn').click();
  2256. setTimeout(function(){$('#settingsBtn').click();},20);}
  2257. });
  2258. },
  2259.  
  2260. skinApplier: function() {
  2261. var self = this;
  2262.  
  2263. var $useWearablesItem = $('<li class="contextmenu-item enabled"><div class="context-icon"><i class="fa fa-graduation-cap"></i></div><p>Use Player\'s Wearables</p></li>');
  2264. $useWearablesItem.insertAfter('#contextPlayer');
  2265. var $useSkinItem = $('<li class="contextmenu-item enabled"><div class="context-icon"><i class="fa fa-eye"></i></div><p>Use Player\'s Skin</p></li>');
  2266. $useSkinItem.insertAfter('#contextPlayer');
  2267.  
  2268. $useSkinItem.click(function() {
  2269. var skinUrl = self.getSkinUrl('#contextPlayerSkin');
  2270. if (skinUrl === null) {
  2271. self.message('This player does not use a skin or no player selected 🚫', true);
  2272. } else {
  2273. var skinId = parseInt(skinUrl.substr(22)); // Cut off "https://agma.io/skins/"
  2274. self.useSkin(skinId);
  2275. }
  2276. });
  2277.  
  2278. $useWearablesItem.click(function() {
  2279. var extractWearableId = function(style) {
  2280. var pos = style.indexOf('background-image: url("wearables/');
  2281. if (pos === -1) {
  2282. return null;
  2283. }
  2284. return parseInt(style.substr(pos + 33));
  2285. }
  2286.  
  2287. var wearables = [
  2288. extractWearableId($('#contextPlayerWear1').attr('style')),
  2289. extractWearableId($('#contextPlayerWear2').attr('style')),
  2290. extractWearableId($('#contextPlayerWear3').attr('style')),
  2291. extractWearableId($('#contextPlayerWear4').attr('style')),
  2292. extractWearableId($('#contextPlayerWear5').attr('style')),
  2293. ];
  2294.  
  2295. var useWearables = function(wearables) {
  2296. window.azad(true);
  2297.  
  2298. setTimeout(function () {
  2299. $('#skinExampleMenu').click();
  2300.  
  2301.  
  2302. setTimeout(function () {
  2303.  
  2304. $('#wearablesTab a').click()
  2305.  
  2306. setTimeout(function () {
  2307. // First remove all current wearables
  2308. var oldWearables = [
  2309. extractWearableId($('#wearExampleShop1').attr('style')),
  2310. extractWearableId($('#wearExampleShop2').attr('style')),
  2311. extractWearableId($('#wearExampleShop3').attr('style')),
  2312. extractWearableId($('#wearExampleShop4').attr('style')),
  2313. extractWearableId($('#wearExampleShop5').attr('style')),
  2314. ]
  2315. oldWearables.forEach(function(id) {
  2316. //toggleWearable(id, 0, 0, 0, false);
  2317. $('#wearableUseBtn' + id).click();
  2318. });
  2319.  
  2320.  
  2321. wearables.forEach(function(id) {
  2322. $('#wearableUseBtn' + id).click();
  2323. });
  2324.  
  2325. setTimeout(function () {
  2326. $('#shopModalDialog button.close').click();
  2327.  
  2328. setTimeout(function () {
  2329. window.setNick(document.getElementById('nick').value);
  2330. }, 200);
  2331. }, 200);
  2332. }, 1000);
  2333.  
  2334. }, 200);
  2335. }, 200);
  2336. }
  2337. useWearables(wearables);
  2338. });
  2339. },
  2340.  
  2341. help: function() {
  2342. $('body').append('<style>#miracle-help-table tr { cursor: pointer } #miracle-help-table table tr:hover { background-color: rgba(255,255,255,0.1) } #miracle-help-button:hover { background: rgba(68,68,68,.8); color: #ffdd67; cursor: pointer } #miracle-help-button { position: absolute; z-index: 10; bottom: 10px; left: 480px; height: 30px; width: 30px; background: rgba(68,68,68,.5); color: #cbb059; }</style>');
  2343. var $modal = $('<div class="miracle-primary-color-font" style="position: fixed; overflow-y: scroll; width: 100%; height: 100%; padding: 50px; background-color: rgba(0,0,0,0.95); z-index: 999; display: none"></div>');
  2344. $modal.append('<h1>Miracle Scripts Help</h1>');
  2345.  
  2346. var helpText = '<br><span style="color: #717171">These chat commands are available. Click on a command to use it!</span><br><br><table id="miracle-help-table"><tr><td><table>' +
  2347. '<tr><th style="padding-right: 70px"><i>Command</i></th><th><i>Description</i></th></tr>' +
  2348. '<tr><td><code>/help</code></td><td>Show this help</td></tr>' +
  2349. '<tr><td><code>/miracle</code></td><td>Show version info</td></tr>' +
  2350. '<tr><td><code>/miraclesettings</code></td><td>Show the miracle settings page</td></tr>' +
  2351. '<tr><td><code>/players</code></td><td>Display how many players are online</td></tr>' +
  2352. '<tr><td><code>/skin&lt;n></code></td><td>Change to skin &lt;n> (1-20)</td></tr>' +
  2353. '<tr><td><code>/skin&lt;n> this</code></td><td>Store current skin as skin <n></td></tr>' +
  2354. '<tr><td><code>/skin&lt;n> &lt;id></code></td><td>Store skin with ID &lt;id> as skin &lt;n> (1-20)</td></tr>' +
  2355. '<tr><td><code>/skinid</code></td><td>Send a chat message with your skin ID</td></tr>' +
  2356. '<tr><td><code>/useskin &lt;id></code></td><td>Use skin with the given ID</td></tr>' +
  2357. '<tr><td><code>/chatlog</code></td><td>Show the extended chat log</td></tr>' +
  2358. '<tr><td><code>/say &lt;text></code></td><td>Send a chat message with a fancy font</td></tr>' +
  2359. '<tr><td><code>/say&lt;n> &lt;text></code></td><td>Send chat message with fancy font number &lt;n> (1-7)</td></tr>' +
  2360. '<tr><td><code>/shout &lt;text></code></td><td>Purchase a megaphone shout for 20000 coins</td></tr>' +
  2361. '<tr><td><code>/paste</code></td><td>Show the emojis and text paste page</td></tr>' +
  2362. '<tr><td><code>/timer &lt;n></code></td><td>Set timer for &lt;n> minutes</td></tr>' +
  2363. '<tr><td><code>/timer &lt;n> h</code></td><td>Set timer for &lt;n> hours</td></tr>' +
  2364. '<tr><td><code>/timer stop</code></td><td>Stop the timer</td></tr>' +
  2365. '<tr><td><code>/xp</code></td><td>Send a chat message with your level and next level\'s progress</td></tr>' +
  2366. '<tr><td><code>/powerups</code></td><td>Send a chat message with your powerup amounts</td></tr>' +
  2367. '<tr><td><code>/fps</code></td><td>Send a chat message with current fps</td></tr>' +
  2368. '<tr><td><code>/ping</code></td><td>Send a chat message with current ping</td></tr>' +
  2369. '<tr><td><code>/online</code></td><td>For how long are you online in the current session?</td></tr>' +
  2370. '<tr><td><code>/alive</code></td><td>For how long are you alive?</td></tr>' +
  2371. '<tr><td><code>/solo</code></td><td>Show the solo server message</td></tr>' +
  2372. '<tr><td><code>/dice</code></td><td>Roll a die with 6 sides</td></tr>' +
  2373. '<tr><td><code>/dice &lt;n></code></td><td>Roll a die with &lt;n> sides</td></tr>' +
  2374. '<tr><td><code>/guess</code></td><td>Start a guessing chat game</td></tr>' +
  2375. '<tr><td><code>/linesplit</code></td><td>Let your cell make a linesplit</td></tr>' +
  2376. '<tr><td><code>/waste</code></td><td>Waste all your mass</td></tr>' +
  2377. '<tr><td><code>/dance</code></td><td>Let your cell dance</td></tr>' +
  2378. '<tr><td><code>/halt</code></td><td>Let your cells stop moving</td></tr>' +
  2379.  
  2380.  
  2381. '</table></td><td style="vertical-align: top"><table>' +
  2382. '<tr><th style="padding-right: 70px"><i>Command</i></th><th><i>Description</i></th></tr>' +
  2383. '<tr><td><code>/coins</code></td><td>Send a chat message with your coins</td></tr>' +
  2384. '<tr><td><code>/level</code></td><td>Send a chat message with your account level</td></tr>' +
  2385. '<tr><td><code>/rank</code></td><td>Send a chat message with your account rank</td></tr>' +
  2386. '<tr><td><code>/hours</code></td><td>Send a chat message with the time you played</td></tr>' +
  2387. '<tr><td><code>/shake</code></td><td>Let your cells shake!</td></tr>' +
  2388. '<tr><td><code>/flip</code></td><td>Let your cells flip!</td></tr>' +
  2389. '<tr><td><code>/spin</code></td><td>Let your cells spin!</td></tr>' +
  2390. '<tr><td><code>/jump</code></td><td>Let your cells jump!</td></tr>' +
  2391. '<tr><td><code>/wacky</code></td><td>Your cells will be laughing faces!</td></tr>' +
  2392. '<tr><td><code>/stats</code></td><td>Show your battle royale stats</td></tr>' +
  2393. '<tr><td><code>/party &lt;message></code></td><td>Write a message to your party</td></tr>' +
  2394. '<tr><td><code>/pm &lt;account></code></td><td>Write a message to a given account</td></tr>' +
  2395. '</table></td></tr></table>';
  2396.  
  2397. $modal.append(helpText);
  2398.  
  2399. $modal.append($('<br><a href="#" class="miracle-primary-color-background" style="display: inline-block; margin-top: 20px; padding: 10px; color: white">Close</a>').click(function () {
  2400. $modal.hide();
  2401. }));
  2402.  
  2403. $('body').append($modal);
  2404.  
  2405. this.$helpModal = $modal;
  2406.  
  2407. $('#miracle-help-table table tr').click(function() {
  2408. var cmd = $(this).find('code').text();
  2409. $('#chtbox').val($('#chtbox').val() + cmd).focus();
  2410. $modal.hide();
  2411. });
  2412.  
  2413. var $helpButton = $('<div id="miracle-help-button" title="Help" class="unselectable"><i class="fa fa-question-circle" style="position: absolute; top: 4px; left: 5px; font-size: 22px;"></i></div>').click(function() {
  2414. $modal.show();
  2415. });
  2416. $helpButton.insertAfter('#emojiBtn');
  2417. $('body').append('<style>@media (max-width: 1288px) { #inventory1 { left: 675px !important; } }</style>'); // Ensure help icon does not overlap powerups
  2418.  
  2419. window.addEventListener('miracleCommand', function(commandEvent) {
  2420. if (commandEvent.command === '/help' || commandEvent.command === '/miraclehelp') {
  2421. $('#chtbox').val('').focus();
  2422. $modal.show();
  2423. }
  2424. });
  2425. },
  2426.  
  2427. commands: function () {
  2428. var self = this;
  2429. var minutes, skinId;
  2430.  
  2431. var sessionStartedAt = Date.now();
  2432.  
  2433. $('#chtbox').keydown(function (event) {
  2434. if (event.keyCode === 13) {
  2435. var message = $('#chtbox').val();
  2436. var command = message.split(' ')[0];
  2437. var argument1 = message.split(' ')[1];
  2438. var argument2 = message.split(' ')[2];
  2439.  
  2440. if (message === 'time' || command === '/time' || command === '/localtime') {
  2441. var now = new Date();
  2442. $('#chtbox').val('Local time: ' + now.toLocaleString() + self.watermark).focus();
  2443. }
  2444.  
  2445. if (message === 'minutes' || command === '/minutes' || message === 'online' || command === '/online' || command === '/session') {
  2446. if (message === 'minutes' || command === '/minutes') {
  2447. self.message('⛔ The /minutes command is deprecated, please use /online instead.', true);
  2448. }
  2449.  
  2450. minutes = parseInt((Date.now() - sessionStartedAt) / 1000 / 60);
  2451. if (minutes < 1) {
  2452. minutes = parseInt((Date.now() - sessionStartedAt) / 1000) + ' Seconds & 0';
  2453. }
  2454. if (minutes > 60) {
  2455. minutes = parseInt(minutes / 60) + ' Hours & ' + (minutes % 60);
  2456. }
  2457. $('#chtbox').val('is online for: ' + minutes + ' Minutes in the current session' + self.watermark).focus();
  2458. }
  2459.  
  2460. if (command === '/solo' || command === '/noteam') {
  2461. $('#chtbox').val(':warning: SOLO SERVER :warning: No teaming!! No hay equipo!! Pas d\'équipe!! Kein Teaming!! لا فريق').focus();
  2462. }
  2463.  
  2464. if (command === '/miracle') {
  2465. var miracleInfo = 'uses 𝘔𝘪𝘳𝘢𝘤𝘭𝘦 𝘚𝘤𝘳𝘪𝘱𝘵𝘴';
  2466.  
  2467. if (GM_info) {
  2468. miracleInfo += ' ' + GM_info.script.version;
  2469. }
  2470.  
  2471. $('#chtbox').val(miracleInfo + '. Install for free from 𝘎𝘳𝘦𝘢𝘴𝘺𝘧𝘰𝘳𝘬.𝘰𝘳𝘨!' + self.watermark).focus();
  2472. }
  2473.  
  2474. if (command === '/samira') {
  2475. $('#chtbox').val('Samira is the initiator of 𝘔𝘪𝘳𝘢𝘤𝘭𝘦 𝘚𝘤𝘳𝘪𝘱𝘵𝘴' + self.watermark).focus();
  2476. }
  2477.  
  2478. if (command === '/skinid' || command === '/sayskin') {
  2479. var skinUri = self.getSkinUrl();
  2480. skinId = parseInt(skinUri.substr(skinUri.indexOf('skins/') + 6));
  2481. $('#chtbox').val('uses the skin with the ID ' + skinId + self.watermark);
  2482. return;
  2483. }
  2484.  
  2485. if (command === '/useskin') {
  2486. skinId = parseInt(argument1);
  2487. if (! (skinId > 0)) {
  2488. self.message('Invalid skin ID given. Example usage of command: /useskin 123', true);
  2489. } else {
  2490. self.useSkin(skinId);
  2491. }
  2492.  
  2493. $('#chtbox').val('');
  2494. }
  2495.  
  2496. if (command.substr(0, 4) === '/say' || (command === '/party' && argument1.substr(0, 4) === '/say') || (command === '/pm' && argument2.substr(0, 4) === '/say')) {
  2497. self.message('🚫 This feature has been removed since the Agma staff does not allow it', true);
  2498. $('#chtbox').val('');
  2499. }
  2500.  
  2501. if (command === '/dice') {
  2502. var max = (argument1 > 0) ? parseInt(argument1) : 6;
  2503. var number = self.getRandomInt(1, max);
  2504. $('#chtbox').val('rolled a die with ' + max + ' sides. Result: ' + number + self.watermark);
  2505. }
  2506.  
  2507. if (command === '/powerups' || command === '/powers' || command === '/has') {
  2508. var map = {
  2509. invRecombine: 'recombine',
  2510. invSpeed: 'speed',
  2511. invGrowth: 'growth',
  2512. invSpawnVirus: 'virus',
  2513. invSpawnMothercell: 'red virus',
  2514. invSpawnPortal: 'portal',
  2515. invSpawnGoldOre: 'gold block',
  2516. invFreeze: 'freeze',
  2517. inv360Shot: 'push',
  2518. invWall: 'wall',
  2519. invAntiFreeze: 'nofreeze',
  2520. invAntiRecombine: 'anti-rec',
  2521. invFrozenVirus: 'frozen virus',
  2522. }
  2523. var getPowerUps = function(map, shortNames) {
  2524. var ids = Object.keys(map); var amount; var powerups = ''; var powerUpName;
  2525. for (var i = 0; i < ids.length; i++) {
  2526. // Note: If the amount of a power-ups is 1, no number will be displayed.
  2527. amount = $('#' + ids[i] + ' p').text() || ($('#' + ids[i]).css('display') === 'none' ? 0 : 1);
  2528. if (amount > 0) {
  2529. if (powerups != '') {
  2530. powerups += ', ';
  2531. }
  2532. powerUpName = map[ids[i]];
  2533. if (shortNames) {
  2534. powerUpName = powerUpName.substr(0, 3);
  2535. }
  2536. powerups += amount + ' ' + powerUpName;
  2537. }
  2538. }
  2539. return powerups;
  2540. }
  2541.  
  2542. var powerups = getPowerUps(map, false);
  2543. if (powerups.length >= 95) {
  2544. powerups = getPowerUps(map, true);
  2545. }
  2546.  
  2547. if (powerups === '') {
  2548. powerups = 'no power-ups';
  2549. }
  2550. $('#chtbox').val(self.watermark + 'has ' + powerups);
  2551. }
  2552.  
  2553. if (command === '/xp' || command === '/progress') {
  2554. var xp = parseInt($('.xpBarTop span').text());
  2555. var text = '█'.repeat(xp / 10) + '▒'.repeat(10 - parseInt(xp / 10)) + ' ' + xp + '%';
  2556. $('#chtbox').val('is currently level ' + $('#level2').text() + ' with ' + text + ' of the next level completed' + self.watermark);
  2557. }
  2558.  
  2559. if (command === '/megaphone' || command === '/megashout' || command === '/shout') {
  2560. // Notes: 1-7 = colors. The shout message can have max 130 chars, but chat messages can be only 100(?) chars long so np
  2561. self.warnBeforeMegaShout(message.substr(message.indexOf(' ') + 1), self.getRandomInt(1, 7));
  2562. $('#chtbox').val('');
  2563. }
  2564.  
  2565. if (command === '/players') {
  2566. var gameservers = JSON.parse(localStorage.getItem('gameservers'));
  2567. var players = 0;
  2568. var current = null;
  2569.  
  2570. gameservers.forEach(function(gameserver) {
  2571. players += gameserver.players;
  2572. if (gameserver.isCurrent) {
  2573. current = gameserver.players + '/' + gameserver.maxPlayers;
  2574. }
  2575. });
  2576.  
  2577. $('#chtbox').val('Players online in Agma: ' + players);
  2578.  
  2579. if (current !== null) {
  2580. $('#chtbox').val($('#chtbox').val() + ' - current server: ' + current);
  2581. }
  2582. }
  2583.  
  2584. var commandEvent = new Event('miracleCommand');
  2585. commandEvent.message = message;
  2586. commandEvent.command = command;
  2587. commandEvent.argument1 = argument1;
  2588. commandEvent.argument2 = argument2;
  2589. window.dispatchEvent(commandEvent);
  2590. }
  2591. });
  2592. },
  2593.  
  2594. /**
  2595. * This object is a container for functions that convert english letters and digits to fancy Unicode characters
  2596. * @see https://en.wikipedia.org/wiki/Mathematical_Alphanumeric_Symbols
  2597. * @see https://en.wikipedia.org/wiki/Enclosed_Alphanumerics
  2598. * @see https://en.wikipedia.org/wiki/Enclosed_Alphanumeric_Supplement
  2599. */
  2600. fonts: {
  2601. doubleStruck : function(charCode) {
  2602. if (charCode === 67) { return String.fromCodePoint(0x2102); } // C
  2603. if (charCode === 72) { return String.fromCodePoint(0x210D); } // H
  2604. if (charCode === 78) { return String.fromCodePoint(0x2115); } // N
  2605. if (charCode === 80) { return String.fromCodePoint(0x2119); } // P
  2606. if (charCode === 81) { return String.fromCodePoint(0x211A); } // Q
  2607. if (charCode === 82) { return String.fromCodePoint(0x211D); } // R
  2608. if (charCode === 90) { return String.fromCodePoint(0x2124); } // Z
  2609. if (charCode >= 65 && charCode <= 90) {
  2610. return String.fromCodePoint(0x1D538 + charCode - 65);
  2611. }
  2612. if (charCode >= 97 && charCode <= 122) {
  2613. return String.fromCodePoint(0x1D552 + charCode - 97);
  2614. }
  2615. if (charCode >= 48 && charCode <= 57) {
  2616. return String.fromCodePoint(0x1D7D8 + charCode - 48);
  2617. }
  2618. return String.fromCharCode(charCode);
  2619. },
  2620.  
  2621. monospace : function(charCode) {
  2622. if (charCode >= 65 && charCode <= 90) {
  2623. return String.fromCodePoint(0x1D670 + charCode - 65);
  2624. }
  2625. if (charCode >= 97 && charCode <= 122) {
  2626. return String.fromCodePoint(0x1D68A + charCode - 97);
  2627. }
  2628. if (charCode >= 48 && charCode <= 57) {
  2629. return String.fromCodePoint(0x1D7F6 + charCode - 48);
  2630. }
  2631. return String.fromCharCode(charCode);
  2632. },
  2633.  
  2634. scriptBold : function(charCode) {
  2635. if (charCode >= 65 && charCode <= 90) {
  2636. return String.fromCodePoint(0x1D4D0 + charCode - 65);
  2637. }
  2638. if (charCode >= 97 && charCode <= 122) {
  2639. return String.fromCodePoint(0x1D4EA + charCode - 97);
  2640. }
  2641. if (charCode >= 48 && charCode <= 57) {
  2642. return String.fromCodePoint(0x1D7CE + charCode - 48);
  2643. }
  2644. return String.fromCharCode(charCode);
  2645. },
  2646.  
  2647. frakturBold : function(charCode) {
  2648. if (charCode === 121) { return '𝐲'; } // y
  2649. if (charCode >= 65 && charCode <= 90) {
  2650. return String.fromCodePoint(0x1D56C + charCode - 65);
  2651. }
  2652. if (charCode >= 97 && charCode <= 122) {
  2653. return String.fromCodePoint(0x1D586 + charCode - 97);
  2654. }
  2655. if (charCode >= 48 && charCode <= 57) {
  2656. return String.fromCodePoint(0x1D7CE + charCode - 48);
  2657. }
  2658. return String.fromCharCode(charCode);
  2659. },
  2660.  
  2661. serifItalic: function(charCode) {
  2662. if (charCode === 104) { return String.fromCodePoint(0x1D629); } // h
  2663. if (charCode >= 65 && charCode <= 90) {
  2664. return String.fromCodePoint(0x1D434 + charCode - 65);
  2665. }
  2666. if (charCode >= 97 && charCode <= 122) {
  2667. return String.fromCodePoint(0x1D44E + charCode - 97);
  2668. }
  2669. return String.fromCharCode(charCode);
  2670. },
  2671.  
  2672. circled: function(charCode) {
  2673. if (charCode >= 65 && charCode <= 90) {
  2674. return String.fromCodePoint(0x24B6 + charCode - 65);
  2675. }
  2676. if (charCode >= 97 && charCode <= 122) {
  2677. return String.fromCodePoint(0x24D0 + charCode - 97);
  2678. }
  2679. if (charCode >= 49 && charCode <= 57) {
  2680. return String.fromCodePoint(0x2460 + charCode - 49);
  2681. }
  2682. return String.fromCharCode(charCode);
  2683. },
  2684.  
  2685. boxed: function(charCode) {
  2686. if (charCode >= 65 && charCode <= 90) {
  2687. return String.fromCodePoint(0x1F130 + charCode - 65);
  2688. }
  2689. if (charCode >= 97 && charCode <= 122) {
  2690. return String.fromCodePoint(0x1F130 + charCode - 97);
  2691. }
  2692. if (charCode >= 49 && charCode <= 57) {
  2693. return String.fromCodePoint(0x2460 + charCode - 49);
  2694. }
  2695. return String.fromCharCode(charCode);
  2696. }
  2697. },
  2698.  
  2699. /**
  2700. * True if currently a HTML text element is focused
  2701. */
  2702. isWritingText: function() {
  2703. return document.activeElement.type === 'text' || document.activeElement.type === 'password' || document.activeElement.type === 'textarea';
  2704. },
  2705.  
  2706. /**
  2707. * Let the browser download string data as a text file with a given filename.
  2708. */
  2709. download: function (filename, text) {
  2710. var element = document.createElement('a');
  2711. element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
  2712. element.setAttribute('download', filename);
  2713.  
  2714. element.style.display = 'none';
  2715. document.body.appendChild(element);
  2716.  
  2717. element.click();
  2718.  
  2719. document.body.removeChild(element);
  2720. },
  2721.  
  2722. /**
  2723. * Converts a version string (for example "1.5.7") to an integer (for example 1005007)
  2724. * If no string version is given, the current version of the script will be used.
  2725. */
  2726. getVersionAsInt: function(stringVersion) {
  2727. if (stringVersion === undefined) {
  2728. stringVersion = typeof GM_info !== 'undefined' ? GM_info.script.version : '0';
  2729. }
  2730.  
  2731. var parts = stringVersion.split('.');
  2732. if (parts.length === 1) {
  2733. parts.push('0');
  2734. }
  2735. if (parts.length === 2) {
  2736. parts.push('0');
  2737. }
  2738.  
  2739. return parseInt(parts[0]) * 1000000 + parseInt(parts[1]) * 1000 + parseInt(parts[2]);
  2740. },
  2741.  
  2742. /**
  2743. * Returns a random number between min and max (both inclusive)
  2744. * Source: MDN
  2745. */
  2746. getRandomInt: function (min, max) {
  2747. return Math.round(Math.random() * (max - min) + min);
  2748. },
  2749.  
  2750.  
  2751. /**
  2752. * Returns the 360-angle between two points 8coordinates), starting by the first point.
  2753. * 0° means the second point is in the north of the first point.
  2754. * The returned angle will always be >= 0 and < 360.
  2755. */
  2756. getAngle: function(x1, y1, x2, y2) {
  2757. var angle = Math.atan2(y2 - y1, x2 - x1); // range (-PI, PI]
  2758. angle *= 180 / Math.PI; // rads to degs, range (-180, 180]
  2759. angle += 90;
  2760.  
  2761. if (angle < 0) angle = 360 + angle; // range [0, 360)
  2762. if (angle >= 360) angle = 360 - angle; // range [0, 360)
  2763.  
  2764. return angle;
  2765. },
  2766.  
  2767. /**
  2768. * Adds angle2 to angle1 and returns the resulting angle.
  2769. */
  2770. addAngle: function(angle1, angle2) {
  2771. var angle = angle1 + angle2;
  2772.  
  2773. angle %= 360;
  2774. if (angle < 0) angle += 360;
  2775.  
  2776. return angle;
  2777. },
  2778.  
  2779. /**
  2780. * Use the curser div to display a message at the top of the screen.
  2781. *
  2782. * @param message
  2783. * @param isError
  2784. */
  2785. message: function (message, isError) {
  2786. var curser = document.querySelector('#curser');
  2787.  
  2788. curser.textContent = message;
  2789. curser.style.display = 'block';
  2790. curser.style.color = isError ? 'rgb(255, 0, 0)' : 'rgb(0, 192, 0)';
  2791.  
  2792. window.setTimeout(function () {
  2793. curser.style.display = 'none';
  2794. }, 5000);
  2795. },
  2796.  
  2797. /**
  2798. * Show a sweet alert (modal/popup) with a given title and message.
  2799. */
  2800. swal: function (title, message, html) {
  2801. if (html === undefined) {
  2802. html = true;
  2803. }
  2804. window.swal({
  2805. title: '📢 <span class="miracle-primary-color-font">' + title + '</span>',
  2806. text: message,
  2807. html: html
  2808. });
  2809. },
  2810.  
  2811. /**
  2812. * Returns the URI of my skin or null if not skin has been set.
  2813. * Use this.skinUrl() to get it.
  2814. */
  2815. getSkinUrl: function(sourceSelector) {
  2816. if (sourceSelector === undefined) {
  2817. sourceSelector = '#skinExampleMenu';
  2818. }
  2819. var skinUrlRaw = $(sourceSelector).css('background-image');
  2820.  
  2821. var parts = skinUrlRaw.split('"');
  2822.  
  2823. if (parts.length !== 3) {
  2824. return null;
  2825. } else {
  2826. return parts[1];
  2827. }
  2828. },
  2829.  
  2830. getAccountName: function() {
  2831. return document.querySelector('#dashPanel .username').innerText;
  2832. },
  2833.  
  2834. /**
  2835. * Tries to pick a skin that is identified by its skin ID.
  2836. * Opens the skin menu, chooses the skin, and closes the menu again.
  2837. * The skin must be available for the current player (e.g. because it's a public one).
  2838. */
  2839. useSkin: function(skinId) {
  2840. window.azad(true);
  2841.  
  2842. setTimeout(function () {
  2843. $('#skinExampleMenu').click();
  2844.  
  2845. var checkLoaded = function () {
  2846. var loaded = ($('#skinsFree tr').length > 1);
  2847. if (loaded) {
  2848. window.toggleSkin(skinId);
  2849.  
  2850. setTimeout(function () {
  2851. $('#shopModalDialog button.close').click();
  2852.  
  2853. setTimeout(function () {
  2854. window.setNick(document.getElementById('nick').value);
  2855. }, 200);
  2856. }, 200);
  2857. } else {
  2858. setTimeout(checkLoaded, 300);
  2859. }
  2860. };
  2861. checkLoaded();
  2862. }, 200);
  2863. },
  2864.  
  2865. /**
  2866. * This is an original Agma function but the original is not accessible - so this is a copy.
  2867. */
  2868. warnBeforeMegaShout: function(msg, color) {
  2869. swal({
  2870. title: "Confirm",
  2871. text: 'If you click "Buy", you will purchase the megaphone shout.',
  2872. type: "warning",
  2873. showCancelButton: true,
  2874. confirmButtonColor: "#4CAF50",
  2875. confirmButtonText: "Yes, confirm purchase",
  2876. cancelButtonText: "No, cancel purchase"
  2877. }, function() {
  2878. //Confirm purchase
  2879. //console.log('purchased megaphone');
  2880. purchaseMega(msg,color);
  2881. //window.location.href = linkURL;
  2882. });
  2883. },
  2884.  
  2885. setupPolyfills: function() {
  2886. // Polyfill for old browser so they have String.fromCodePoint()
  2887. if (!String.fromCodePoint) (function(stringFromCharCode) {
  2888. var fromCodePoint = function(_) {
  2889. var codeUnits = [], codeLen = 0, result = "";
  2890. for (var index=0, len = arguments.length; index !== len; ++index) {
  2891. var codePoint = +arguments[index];
  2892. // correctly handles all cases including `NaN`, `-Infinity`, `+Infinity`
  2893. // The surrounding `!(...)` is required to correctly handle `NaN` cases
  2894. // The (codePoint>>>0) === codePoint clause handles decimals and negatives
  2895. if (!(codePoint < 0x10FFFF && (codePoint>>>0) === codePoint))
  2896. throw RangeError("Invalid code point: " + codePoint);
  2897. if (codePoint <= 0xFFFF) { // BMP code point
  2898. codeLen = codeUnits.push(codePoint);
  2899. } else { // Astral code point; split in surrogate halves
  2900. // https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
  2901. codePoint -= 0x10000;
  2902. codeLen = codeUnits.push(
  2903. (codePoint >> 10) + 0xD800, // highSurrogate
  2904. (codePoint % 0x400) + 0xDC00 // lowSurrogate
  2905. );
  2906. }
  2907. if (codeLen >= 0x3fff) {
  2908. result += stringFromCharCode.apply(null, codeUnits);
  2909. codeUnits.length = 0;
  2910. }
  2911. }
  2912. return result + stringFromCharCode.apply(null, codeUnits);
  2913. };
  2914. try { // IE 8 only supports `Object.defineProperty` on DOM elements
  2915. Object.defineProperty(String, "fromCodePoint", {
  2916. "value": fromCodePoint, "configurable": true, "writable": true
  2917. });
  2918. } catch(e) {
  2919. String.fromCodePoint = fromCodePoint;
  2920. }
  2921. }(String.fromCharCode));
  2922. },
  2923. };
  2924.  
  2925. window.miracleScripts.init();
  2926. })();