Miracle Scripts For cellcraft.io

Best Cellcraft.io Script!

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

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