Miracle Scripts

Best Agma.io script with tons of features

目前为 2020-09-16 提交的版本。查看 最新版本

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