Miracle Scripts

Best Agma.io script with tons of features

当前为 2020-08-19 提交的版本,查看 最新版本

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

QingJ © 2025

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