Miracle Scripts

Best Agma.io script with tons of features

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

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

QingJ © 2025

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