Miracle Scripts

Best Agma.io script with tons of features

当前为 2020-09-27 提交的版本,查看 最新版本

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

QingJ © 2025

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