Miracle Scripts

Bookmark your favorite skins! Use skin shortcuts! Go crazy with cell animations! Improved chatlog! Dance! Use chat replacements! Display the time!

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

  1. // ==UserScript==
  2. // @name Miracle Scripts
  3. // @namespace Miracle Scripts
  4. // @version 1.7.0
  5. // @description Bookmark your favorite skins! Use skin shortcuts! Go crazy with cell animations! Improved chatlog! Dance! Use chat replacements! Display the time!
  6. // @homepage http://agarioforums.net/member.php?action=profile&uid=21263
  7. // @author You
  8. // @license MIT
  9. // @icon https://abload.de/img/mh3k8o.png
  10. // @match http://agma.io/
  11. // @grant none
  12. // ==/UserScript==
  13.  
  14. // Source: http://stackoverflow.com/questions/1772179/get-character-value-from-keycode-in-javascript-then-trim#answer-23377822
  15. window.keyboardMap = [
  16. "", // [0]
  17. "", // [1]
  18. "", // [2]
  19. "CANCEL", // [3]
  20. "", // [4]
  21. "", // [5]
  22. "HELP", // [6]
  23. "", // [7]
  24. "BACK_SPACE", // [8]
  25. "TAB", // [9]
  26. "", // [10]
  27. "", // [11]
  28. "CLEAR", // [12]
  29. "ENTER", // [13]
  30. "ENTER_SPECIAL", // [14]
  31. "", // [15]
  32. "SHIFT", // [16]
  33. "CONTROL", // [17]
  34. "ALT", // [18]
  35. "PAUSE", // [19]
  36. "CAPS_LOCK", // [20]
  37. "KANA", // [21]
  38. "EISU", // [22]
  39. "JUNJA", // [23]
  40. "FINAL", // [24]
  41. "HANJA", // [25]
  42. "", // [26]
  43. "ESCAPE", // [27]
  44. "CONVERT", // [28]
  45. "NONCONVERT", // [29]
  46. "ACCEPT", // [30]
  47. "MODECHANGE", // [31]
  48. "SPACE", // [32]
  49. "PAGE_UP", // [33]
  50. "PAGE_DOWN", // [34]
  51. "END", // [35]
  52. "HOME", // [36]
  53. "LEFT", // [37]
  54. "UP", // [38]
  55. "RIGHT", // [39]
  56. "DOWN", // [40]
  57. "SELECT", // [41]
  58. "PRINT", // [42]
  59. "EXECUTE", // [43]
  60. "PRINTSCREEN", // [44]
  61. "INSERT", // [45]
  62. "DELETE", // [46]
  63. "", // [47]
  64. "0", // [48]
  65. "1", // [49]
  66. "2", // [50]
  67. "3", // [51]
  68. "4", // [52]
  69. "5", // [53]
  70. "6", // [54]
  71. "7", // [55]
  72. "8", // [56]
  73. "9", // [57]
  74. "COLON", // [58]
  75. "SEMICOLON", // [59]
  76. "LESS_THAN", // [60]
  77. "EQUALS", // [61]
  78. "GREATER_THAN", // [62]
  79. "QUESTION_MARK", // [63]
  80. "AT", // [64]
  81. "A", // [65]
  82. "B", // [66]
  83. "C", // [67]
  84. "D", // [68]
  85. "E", // [69]
  86. "F", // [70]
  87. "G", // [71]
  88. "H", // [72]
  89. "I", // [73]
  90. "J", // [74]
  91. "K", // [75]
  92. "L", // [76]
  93. "M", // [77]
  94. "N", // [78]
  95. "O", // [79]
  96. "P", // [80]
  97. "Q", // [81]
  98. "R", // [82]
  99. "S", // [83]
  100. "T", // [84]
  101. "U", // [85]
  102. "V", // [86]
  103. "W", // [87]
  104. "X", // [88]
  105. "Y", // [89]
  106. "Z", // [90]
  107. "OS_KEY", // [91] Windows Key (Windows) or Command Key (Mac)
  108. "", // [92]
  109. "CONTEXT_MENU", // [93]
  110. "", // [94]
  111. "SLEEP", // [95]
  112. "NUMPAD0", // [96]
  113. "NUMPAD1", // [97]
  114. "NUMPAD2", // [98]
  115. "NUMPAD3", // [99]
  116. "NUMPAD4", // [100]
  117. "NUMPAD5", // [101]
  118. "NUMPAD6", // [102]
  119. "NUMPAD7", // [103]
  120. "NUMPAD8", // [104]
  121. "NUMPAD9", // [105]
  122. "MULTIPLY", // [106]
  123. "ADD", // [107]
  124. "SEPARATOR", // [108]
  125. "SUBTRACT", // [109]
  126. "DECIMAL", // [110]
  127. "DIVIDE", // [111]
  128. "F1", // [112]
  129. "F2", // [113]
  130. "F3", // [114]
  131. "F4", // [115]
  132. "F5", // [116]
  133. "F6", // [117]
  134. "F7", // [118]
  135. "F8", // [119]
  136. "F9", // [120]
  137. "F10", // [121]
  138. "F11", // [122]
  139. "F12", // [123]
  140. "F13", // [124]
  141. "F14", // [125]
  142. "F15", // [126]
  143. "F16", // [127]
  144. "F17", // [128]
  145. "F18", // [129]
  146. "F19", // [130]
  147. "F20", // [131]
  148. "F21", // [132]
  149. "F22", // [133]
  150. "F23", // [134]
  151. "F24", // [135]
  152. "", // [136]
  153. "", // [137]
  154. "", // [138]
  155. "", // [139]
  156. "", // [140]
  157. "", // [141]
  158. "", // [142]
  159. "", // [143]
  160. "NUM_LOCK", // [144]
  161. "SCROLL_LOCK", // [145]
  162. "WIN_OEM_FJ_JISHO", // [146]
  163. "WIN_OEM_FJ_MASSHOU", // [147]
  164. "WIN_OEM_FJ_TOUROKU", // [148]
  165. "WIN_OEM_FJ_LOYA", // [149]
  166. "WIN_OEM_FJ_ROYA", // [150]
  167. "", // [151]
  168. "", // [152]
  169. "", // [153]
  170. "", // [154]
  171. "", // [155]
  172. "", // [156]
  173. "", // [157]
  174. "", // [158]
  175. "", // [159]
  176. "CIRCUMFLEX", // [160]
  177. "EXCLAMATION", // [161]
  178. "DOUBLE_QUOTE", // [162]
  179. "HASH", // [163]
  180. "DOLLAR", // [164]
  181. "PERCENT", // [165]
  182. "AMPERSAND", // [166]
  183. "UNDERSCORE", // [167]
  184. "OPEN_PAREN", // [168]
  185. "CLOSE_PAREN", // [169]
  186. "ASTERISK", // [170]
  187. "PLUS", // [171]
  188. "PIPE", // [172]
  189. "HYPHEN_MINUS", // [173]
  190. "OPEN_CURLY_BRACKET", // [174]
  191. "CLOSE_CURLY_BRACKET", // [175]
  192. "TILDE", // [176]
  193. "", // [177]
  194. "", // [178]
  195. "", // [179]
  196. "", // [180]
  197. "VOLUME_MUTE", // [181]
  198. "VOLUME_DOWN", // [182]
  199. "VOLUME_UP", // [183]
  200. "", // [184]
  201. "", // [185]
  202. "SEMICOLON", // [186]
  203. "EQUALS", // [187]
  204. "COMMA", // [188]
  205. "MINUS", // [189]
  206. "PERIOD", // [190]
  207. "SLASH", // [191]
  208. "BACK_QUOTE", // [192]
  209. "", // [193]
  210. "", // [194]
  211. "", // [195]
  212. "", // [196]
  213. "", // [197]
  214. "", // [198]
  215. "", // [199]
  216. "", // [200]
  217. "", // [201]
  218. "", // [202]
  219. "", // [203]
  220. "", // [204]
  221. "", // [205]
  222. "", // [206]
  223. "", // [207]
  224. "", // [208]
  225. "", // [209]
  226. "", // [210]
  227. "", // [211]
  228. "", // [212]
  229. "", // [213]
  230. "", // [214]
  231. "", // [215]
  232. "", // [216]
  233. "", // [217]
  234. "", // [218]
  235. "OPEN_BRACKET", // [219]
  236. "BACK_SLASH", // [220]
  237. "CLOSE_BRACKET", // [221]
  238. "QUOTE", // [222]
  239. "", // [223]
  240. "META", // [224]
  241. "ALTGR", // [225]
  242. "", // [226]
  243. "WIN_ICO_HELP", // [227]
  244. "WIN_ICO_00", // [228]
  245. "", // [229]
  246. "WIN_ICO_CLEAR", // [230]
  247. "", // [231]
  248. "", // [232]
  249. "WIN_OEM_RESET", // [233]
  250. "WIN_OEM_JUMP", // [234]
  251. "WIN_OEM_PA1", // [235]
  252. "WIN_OEM_PA2", // [236]
  253. "WIN_OEM_PA3", // [237]
  254. "WIN_OEM_WSCTRL", // [238]
  255. "WIN_OEM_CUSEL", // [239]
  256. "WIN_OEM_ATTN", // [240]
  257. "WIN_OEM_FINISH", // [241]
  258. "WIN_OEM_COPY", // [242]
  259. "WIN_OEM_AUTO", // [243]
  260. "WIN_OEM_ENLW", // [244]
  261. "WIN_OEM_BACKTAB", // [245]
  262. "ATTN", // [246]
  263. "CRSEL", // [247]
  264. "EXSEL", // [248]
  265. "EREOF", // [249]
  266. "PLAY", // [250]
  267. "ZOOM", // [251]
  268. "", // [252]
  269. "PA1", // [253]
  270. "WIN_OEM_CLEAR", // [254]
  271. "" // [255]
  272. ];
  273.  
  274. // Don't remove the spaces, they are used as seperators! Source: https://emojiterra.com/de/liste/
  275. window.emojis = '😀 😃 😄 😁 😆 😅 😂 😉 😊 😇 😍 😘 😗 ☺️ 😚 😙 😋 😛 😜 😝 😐 😑 😶 😏 😒 😬 😌 😔 😪 😴 😷 😵 😎 😕 😟 😮 😯 😲 😳 😦 😧 😨 😰 😥 😢 😭 😱 😖 😣 😞 😓 😩 😫 😤 😡 😠 😈 👿 💀 💩 👹 👺 👻 👽 👾 😺 😸 😹 😻 😼 😽 🙀 😿 😾 🙈 🙉 🙊 💋 💌 💘 💝 💖 💗 💓 💞 💕 💟 💔 ❤️ 💛 💚 💙 💜 💯 💢 💥 💫 💦 💨 💣 💬 💭 💤 👋 ✋ 👌 ✌️ 👈 👉 👆 👇 ☝️ 👍 👎 ✊ 👊 👏 🙌 👐 🙏 💅 💪 👂 👃 👀 👅 👄 👶 👦 👧 👱 👨 👩 👴 👵 🙍 🙎 🙅 🙆 💁 🙋 🙇 👮 💂 👷 👸 👳 👲 👰 👼 🎅 💆 💇 🚶 🏃 💃 👯 🏇 🏂 🏄 🚣 🏊 🚴 🚵 🛀 👭 👫 👬 💏 💑 👪 👤 👥 👣 🐵 🐒 🐶 🐕 🐩 🐺 🐱 🐈 🐯 🐅 🐆 🐴 🐎 🐮 🐂 🐃 🐄 🐷 🐖 🐗 🐽 🐏 🐑 🐐 🐪 🐫 🐘 🐭 🐁 🐀 🐹 🐰 🐇 🐻 🐨 🐼 🐾 🐔 🐓 🐣 🐤 🐥 🐦 🐧 🐸 🐊 🐢 🐍 🐲 🐉 🐳 🐋 🐬 🐟 🐠 🐡 🐙 🐚 🐌 🐛 🐜 🐝 🐞 💐 🌸 💮 🌹 🌺 🌻 🌼 🌷 🌱 🌲 🌳 🌴 🌵 🌾 🌿 🍀 🍁 🍂 🍃 🍇 🍈 🍉 🍊 🍋 🍌 🍍 🍎 🍏 🍐 🍑 🍒 🍓 🍅 🍆 🌽 🍄 🌰 🍞 🍖 🍗 🍔 🍟 🍕 🍳 🍲 🍱 🍘 🍙 🍚 🍛 🍜 🍝 🍠 🍢 🍣 🍤 🍥 🍡 🍦 🍧 🍨 🍩 🍪 🎂 🍰 🍫 🍬 🍭 🍮 🍯 🍼 ☕ 🍵 🍶 🍷 🍸 🍹 🍺 🍻 🍴 🔪 🌍 🌎 🌏 🌐 🗾 🌋 🗻 🏠 🏡 🏢 🏣 🏤 🏥 🏦 🏨 🏩 🏪 🏫 🏬 🏭 🏯 🏰 💒 🗼 🗽 ⛪ ⛲ ⛺ 🌁 🌃 🌄 🌅 🌆 🌇 🌉 ♨️ 🎠 🎡 🎢 💈 🎪 🚂 🚃 🚄 🚅 🚆 🚇 🚈 🚉 🚊 🚝 🚞 🚋 🚌 🚍 🚎 🚐 🚑 🚒 🚓 🚔 🚕 🚖 🚗 🚘 🚙 🚚 🚛 🚜 🚲 🚏 ⛽ 🚨 🚥 🚦 🚧 ⚓ ⛵ 🚤 🚢 ✈️ 💺 🚁 🚟 🚠 🚡 🚀 ⌛ ⏳ ⌚ ⏰ 🕛 🕧 🕐 🕜 🕑 🕝 🕒 🕞 🕓 🕟 🕔 🕠 🕕 🕡 🕖 🕢 🕗 🕣 🕘 🕤 🕙 🕥 🕚 🕦 🌑 🌒 🌓 🌔 🌕 🌖 🌗 🌘 🌙 🌚 🌛 🌜 ☀️ 🌝 🌞 ⭐ 🌟 🌠 🌌 ☁️ ⛅ 🌀 🌈 🌂 ☔ ⚡ ❄️ ⛄ 🔥 💧 🌊 🎃 🎄 🎆 🎇 ✨ 🎈 🎉 🎊 🎋 🎍 🎎 🎏 🎐 🎑 🎀 🎁 🎫 🏆 ⚽ ⚾ 🏀 🏈 🏉 🎾 🎳 ⛳ 🎣 🎽 🎿 🎯 🎱 🔮 🎮 🎰 🎲 ♠️ ♥️ ♦️ ♣️ 🃏 🀄 🎴 🎭 🎨 👓 👔 👕 👖 👗 👘 👙 👚 👛 👜 👝 🎒 👞 👟 👠 👡 👢 👑 👒 🎩 🎓 💄 💍 💎 🔇 🔈 🔉 🔊 📢 📣 📯 🔔 🔕 🎼 🎵 🎶 🎤 🎧 📻 🎷 🎸 🎹 🎺 🎻 📱 📲 ☎️ 📞 📟 📠 🔋 🔌 💻 💽 💾 💿 📀 🎥 🎬 📺 📷 📹 📼 🔍 🔎 💡 🔦 🏮 📔 📕 📖 📗 📘 📙 📚 📓 📒 📃 📜 📄 📰 📑 🔖 💰 💴 💵 💶 💷 💸 💳 💹 💱 💲 ✉️ 📧 📨 📩 📤 📥 📦 📫 📪 📬 📭 📮 ✏️ ✒️ 📝 💼 📁 📂 📅 📆 📇 📈 📉 📊 📋 📌 📍 📎 📏 📐 ✂️ 🔒 🔓 🔏 🔐 🔑 🔨 🔫 🔧 🔩 🔗 🔬 🔭 📡 💉 💊 🚪 🚽 🚿 🛁 🚬 🗿 🏧 🚮 🚰 ♿ 🚹 🚺 🚻 🚼 🚾 🛂 🛃 🛄 🛅 ⚠️ 🚸 ⛔ 🚫 🚳 🚭 🚯 🚱 🚷 📵 🔞 ⬆️ ↗️ ➡️ ↘️ ⬇️ ↙️ ⬅️ ↖️ ↕️ ↔️ 🔃 🔄 🔙 🔚 🔛 🔜 🔝 🔯 ♈ ♉ ♊ ♋ ♌ ♍ ♎ ♏ ♐ ♑ ♒ ♓ ⛎ 🔀 🔁 🔂 ▶️ ◀️ 🔼 🔽 🎦 📶 📳 📴 ♻️ 🔱 📛 🔰 ⭕ ✅ ☑️ ✖️ ❌ ❎ ➕ ➖ ➗ ➰ ➿ 〽️ ✳️ ✴️ ❇️ ‼️ ⁉️ ❓ ❔ ❕ ❗ 〰️ ©️ ®️ ™️ 🔠 🔡 🔢 🔣 🔤 🅰️ 🆎 🅱️ 🆑 🆒 🆓 🆔 Ⓜ️ 🆕 🆖 🅾️ 🆗 🅿️ 🆘 🆙 🆚 🈁 🈂️ 🈷️ 🈶 🈯 🉐 🈹 🈚 🈲 🉑 🈸 🈴 🈳 ㊗️ ㊙️ 🈺 🈵 🔴 🔵 ⚫ ⚪ ⬛ ⬜ ◼️ ◻️ ◾ ◽ ▪️ ▫️ 🔶 🔷 🔸 🔹 🔺 🔻 💠 🔘 🔳 🔲 🏁 🚩 🎌';
  276.  
  277. (function() {
  278. 'use strict';
  279.  
  280. var settings;
  281.  
  282. var loadSettings = function(stringifiedSettings) {
  283. var defaultSettings = {
  284. // To get keycodes: https://keycode.info
  285. bindings: {
  286. animation: 17, // CRTL
  287. paste: 33, // PAGE UP
  288. dance: 34, // PAGE DOWN,
  289. chatLog: 76, // L
  290. },
  291. replacements: ":D|:smile:\n:*(|:sob:\n:'D|:sweat_smiley:\nxD|:joy:",
  292. primaryColor: "#FF69B4",
  293. targetLanguage: 'EN',
  294. favSkins: [],
  295. };
  296.  
  297. if (stringifiedSettings == null) {
  298. settings = defaultSettings;
  299. localStorage.setItem('miracleScripts', JSON.stringify(settings));
  300. } else {
  301. settings = JSON.parse(stringifiedSettings);
  302.  
  303. // Update for settigns:
  304. if (typeof settings.primaryColor === 'undefined') {
  305. settings.primaryColor = defaultSettings.primaryColor;
  306. localStorage.setItem('miracleScripts', JSON.stringify(settings));
  307. }
  308. if (typeof settings.bindings.chatLog === 'undefined') {
  309. settings.bindings.chatLog = defaultSettings.bindings.chatLog;
  310. localStorage.setItem('miracleScripts', JSON.stringify(settings));
  311. }
  312. if (typeof settings.favSkins === 'undefined') {
  313. settings.favSkins = defaultSettings.favSkins;
  314. localStorage.setItem('miracleScripts', JSON.stringify(settings));
  315. }
  316. if (typeof settings.targetLanguage === 'undefined') {
  317. settings.targetLanguage = defaultSettings.targetLanguage;
  318. localStorage.setItem('miracleScripts', JSON.stringify(settings));
  319. }
  320. if (typeof settings.quickSkins === 'undefined') {
  321. settings.quickSkins = []
  322. localStorage.setItem('miracleScripts', JSON.stringify(settings));
  323. }
  324. }
  325. }
  326. loadSettings(localStorage.getItem('miracleScripts'));
  327.  
  328. var applyPrimaryColor = function() {
  329. var primaryColorCss = '.miracle-primary-color-font { color: ' + settings.primaryColor + ' !important } .miracle-primary-color-background { background-color: ' + settings.primaryColor + ' !important }; ';
  330. $('body').append('<style>' + primaryColorCss + '</style>');
  331. };
  332. applyPrimaryColor();
  333.  
  334. var download = function(filename, text) {
  335. var element = document.createElement('a');
  336. element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
  337. element.setAttribute('download', filename);
  338.  
  339. element.style.display = 'none';
  340. document.body.appendChild(element);
  341.  
  342. element.click();
  343.  
  344. document.body.removeChild(element);
  345. }
  346.  
  347. window.curserMessage = function(message) {
  348. var curser = document.querySelector('#curser');
  349.  
  350. curser.textContent = message;
  351. curser.style.display = 'block';
  352.  
  353. window.setTimeout(function() {
  354. curser.style.display = 'none';
  355. }, 5000);
  356. },
  357.  
  358. // We need to have a delay, because the menu is not laoded right away
  359. setTimeout(function() {
  360. var $playButton = $('#playBtn');
  361. var $specateButton = $('#spectateBtn');
  362.  
  363. $playButton.get(0).style.width = '40%';
  364. $specateButton.get(0).style.width = '40%';
  365.  
  366. var $settingsButton = $('<button class="spec" style="width: 40px; margin-left: 7px; text-align: center; padding: 10px 0 20px 0" title="Miracle Scripts Settings">📜</button>');
  367. $settingsButton.insertAfter($playButton);
  368.  
  369. var changeKey = function(event) {
  370. var name = this.name.substr(4);
  371. $(this).val(window.keyboardMap[event.keyCode]);
  372. settings.bindings[name] = event.keyCode;
  373. localStorage.setItem('miracleScripts', JSON.stringify(settings));
  374. };
  375.  
  376. var deleteKey = function(event) {
  377. var action = $(this).attr('data-action');
  378. $('#miracle-settings input[name=key_' + action + ']').val('undefined');
  379. settings.bindings[action] = null;
  380. localStorage.setItem('miracleScripts', JSON.stringify(settings));
  381. }
  382.  
  383. // Weird Agma scripting... press enter in the replacements textarea and the chatbox gets focused!
  384. // Therefore catch the keydown event (that happens earlier) and insert the linebreak manually,
  385. // focus again (delayed) and go to the end of the text where the linebreak is.
  386. // We can improve this later on...
  387. var addReturn = function(event) {
  388. if (event.keyCode == 13) {
  389. var textarea = this;
  390. $(textarea).text($(this).text() + '\n').focus();
  391. setTimeout(function(){
  392. $(textarea).focus();
  393. textarea.setSelectionRange(textarea.value.length, textarea.value.length);
  394. }, 1);
  395. }
  396. };
  397. var changeReplacements = function(event) {
  398. settings.replacements = $(this).val();
  399. localStorage.setItem('miracleScripts', JSON.stringify(settings));
  400. };
  401. var changePrimaryColor = function(event) {
  402. settings.primaryColor = $(this).val();
  403. localStorage.setItem('miracleScripts', JSON.stringify(settings));
  404. applyPrimaryColor();
  405. };
  406. var changeTargetLanguage = function(event) {
  407. settings.targetLanguage = $(this).val();
  408. localStorage.setItem('miracleScripts', JSON.stringify(settings));
  409. };
  410.  
  411. var $modal = $('<div id="miracle-settings" class="miracle-primary-color-font" style="position: fixed; width: 100%; height: 100%; padding: 50px; background-color: rgba(0,0,0,0.95); z-index: 999; display: none"></div>');
  412. $modal.append('<h1>Miracle Scripts Settings</h1>');
  413.  
  414. if (GM_info) {
  415. $modal.append('<small style="color: #717171">Version ' + GM_info.script.version + '</small>');
  416. }
  417.  
  418. var $element = $('<input name="key_animation" value="' + window.keyboardMap[settings.bindings.animation] + '"/>').keyup(changeKey);
  419. $modal.append('<br><br>Animation-Key:<br>', $element);
  420. $element = $('<a href="#" data-action="animation" class="miracle-primary-color-background" style="display: inline-block; padding: 3px 10px; color: white">✖</a>').click(deleteKey);
  421. $modal.append($element);
  422.  
  423. $element = $('<input name="key_paste" value="' + window.keyboardMap[settings.bindings.paste] + '"/>').keyup(changeKey);
  424. $modal.append('<br>Paste-Key:<br>', $element);
  425. $element = $('<a href="#" data-action="paste" class="miracle-primary-color-background" style="display: inline-block; padding: 3px 10px; color: white">✖</a>').click(deleteKey);
  426. $modal.append($element);
  427.  
  428. $element = $('<input name="key_dance" value="' + window.keyboardMap[settings.bindings.dance] + '"/>').keyup(changeKey);
  429. $modal.append('<br>Dance-Key:<br>', $element);
  430. $element = $('<a href="#" data-action="dance" class="miracle-primary-color-background" style="display: inline-block; padding: 3px 10px; color: white">✖</a>').click(deleteKey);
  431. $modal.append($element);
  432.  
  433. $element = $('<input name="key_chatLog" value="' + window.keyboardMap[settings.bindings.chatLog] + '"/>').keyup(changeKey);
  434. $modal.append('<br>Chat-Log-Key:<br>', $element);
  435. $element = $('<a href="#" data-action="chatLog" class="miracle-primary-color-background" style="display: inline-block; padding: 3px 10px; color: white">✖</a>').click(deleteKey);
  436. $modal.append($element);
  437.  
  438. $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></select>').change(changeTargetLanguage);
  439. $modal.append('<br><br>Translate chat messages to:<br>', $element);
  440. $element.get(0).value = settings.targetLanguage;
  441.  
  442. $element = $('<input type="color" name="favcolor" value="' + settings.primaryColor + '"/>').change(changePrimaryColor);
  443. $modal.append('<br><br>User interface color:<br>', $element);
  444.  
  445. $element = $('<textarea rows="6" style="width: 100%; max-width: 500px" placeholder="search|replace">').text(settings.replacements).keydown(addReturn).keyup(changeReplacements);
  446. $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>');
  447.  
  448. $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() { $modal.hide() }));
  449. $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() { download('miracle_settings.txt', localStorage.getItem('miracleScripts')) }));
  450. $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() {
  451. var stringifiedSettings = prompt('Paste the settings here');
  452. if (stringifiedSettings !== null) {
  453. loadSettings(stringifiedSettings);
  454. localStorage.setItem('miracleScripts', stringifiedSettings);
  455. $modal.hide();
  456. alert('Settings loaded! Reload Agma to refresh.');
  457. }
  458. }));
  459. $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>'));
  460.  
  461. $('body').append($modal);
  462.  
  463. $settingsButton.click(function(event)
  464. {
  465. $modal.show();
  466.  
  467. event.preventDefault();
  468. });
  469. }, 500);
  470. })();
  471.  
  472.  
  473. (function() {
  474. 'use strict';
  475.  
  476. /**
  477. * Returns a random number between min (inclusive) and max (exclusive)
  478. * Source: MDN
  479. */
  480. var getRandomArbitrary = function(min, max) {
  481. return Math.random() * (max - min) + min;
  482. }
  483.  
  484. var chatAnimate = function()
  485. {
  486. // All available commands and combinations
  487. var items = ['wacky',
  488. 'spin', 'spinspin', 'spinspinspin', 'wackyspin', 'wackyspinspin', 'wackyspinspinspin',
  489. 'flip', 'flipflip', 'flipflipflip', 'wackyflip', 'wackyflipflip', 'wackyflipflipfip',
  490. 'shake', 'shakeshake','shakeshakeshake','wackyshake','wackyshakeshake','wackyshakeshakeshake',
  491. 'jump', 'jumpjump', 'jumpjumpjump', 'wackyjump', 'wackyjumpjump', 'wackyjumpjumpjump',
  492. ];
  493.  
  494. // Super-combinations!!
  495. if (getRandomArbitrary(1, 3) == 1) {
  496. items = ['jumpspinflip', 'jumpflipshake', 'jumpspinshake', 'spinshakeflip'];
  497. }
  498.  
  499. // Choose randomly an item of the items array
  500. // Source: https://stackoverflow.com/questions/5915096/get-random-item-from-javascript-array
  501. var item = items[Math.floor(Math.random() * items.length)];
  502.  
  503. item += String.fromCharCode(8203).repeat(getRandomArbitrary(1, 5));
  504.  
  505. // Add text into the chatbox and focus it (Note: acutally "/" is no longer necessary)
  506. $('#chtbox').val($('#chtbox').val() + item).focus();
  507.  
  508. // Stop the event so that the pressed key won't be written into the chatbox!
  509. event.preventDefault();
  510. }
  511.  
  512. window.addEventListener('keydown', function(event)
  513. {
  514. // Do nothing if a menu is open
  515. if (document.getElementById('overlays').style.display != 'none' || document.getElementById('advert').style.display != 'none') {
  516. return;
  517. }
  518.  
  519. var settings = JSON.parse(localStorage.getItem('miracleScripts'));
  520.  
  521. if (event.keyCode == settings.bindings.animation) {
  522. chatAnimate();
  523. }
  524. });
  525. })();
  526.  
  527.  
  528. (function() {
  529. 'use strict';
  530.  
  531. var emojiFontSize = (window.innerWidth * window.innerHeight > 2000000) ? 24 : 18;
  532. 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' +
  533. '#miracle-emojis .miracle-emoji:hover { background-color: #FF69B4 }';
  534.  
  535. var emojis = window.emojis.split(' ');
  536. var emojiCode = '';
  537.  
  538. emojis.forEach(function(emoji) {
  539. emojiCode += '<a href="#" class="miracle-emoji">' + emoji + '</a>';
  540. });
  541.  
  542. var addEmoji = function()
  543. {
  544. setTimeout(function(){
  545. var $pasteInput = $(document).find('#miracle-emojis input[name=paste]');
  546.  
  547. // Add text into the chatbox and focus it
  548. $('#chtbox').val($('#chtbox').val() + $pasteInput.val()).focus();
  549. }, 200);
  550.  
  551. $modal.hide();
  552. };
  553.  
  554. 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>');
  555. $modal.append('<style>' + css + '</style>');
  556. $modal.append('<h1>Insert text or emoji</h1>');
  557. var $pasteInput = $('<input name="paste" value="" placeholder="Click to paste text, or (double)click emoji!" style="width: 300px; max-width: 100%" />');
  558. $modal.append('<br><br>Insert:<br>', $pasteInput);
  559. $modal.html($modal.html() + '<br><br>' + emojiCode);
  560. $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));
  561. $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() { $modal.hide() }));
  562.  
  563. $modal.find('input[name=paste]').click(function(event)
  564. {
  565. var text = prompt('Please paste your text here!');
  566.  
  567. if (text !== null) {
  568. var $pasteInput = $modal.find('input[name=paste]');
  569.  
  570. // Add text into the paste input
  571. $pasteInput.val($pasteInput.val() + text);
  572. }
  573. });
  574.  
  575. $modal.click(function(event)
  576. {
  577. if (event.target.classList.contains('miracle-emoji')) {
  578. var $target = $(this).find('input[name=paste]');
  579. $target.val($target.val() + $(event.target).text());
  580.  
  581. event.preventDefault();
  582. }
  583. });
  584.  
  585. $modal.dblclick(function(event)
  586. {
  587. if (event.target.classList.contains('miracle-emoji')) {
  588. $('#chtbox').val($('#chtbox').val() + $(event.target).text()).focus();
  589. $(this).hide();
  590.  
  591. event.preventDefault();
  592. }
  593. });
  594.  
  595. $('body').append($modal);
  596.  
  597. window.addEventListener('keydown', function(event)
  598. {
  599. // Do nothing if a menu is open
  600. if (document.getElementById('overlays').style.display != 'none' || document.getElementById('advert').style.display != 'none') {
  601. return;
  602. }
  603.  
  604. var settings = JSON.parse(localStorage.getItem('miracleScripts'));
  605.  
  606. if (event.keyCode == settings.bindings.paste) {
  607. $modal.find('input[name=paste]').val('');
  608. $modal.toggle();
  609. }
  610. });
  611. })();
  612.  
  613.  
  614. (function() {
  615. 'use strict';
  616.  
  617. var angle = 0;
  618. var angleSpeed = 20;
  619. var distance = Math.floor(Math.min(window.innerWidth, window.innerHeight) / 2);
  620. var dancing = false;
  621.  
  622. var dance = function()
  623. {
  624. angle += angleSpeed;
  625. if (angle > 360) {
  626. angle = 0;
  627. }
  628.  
  629. var x = window.innerWidth/2 + Math.sin(angle * Math.PI / 180) * distance;
  630. var y = window.innerHeight/2 + Math.cos(angle * Math.PI / 180) * distance;
  631. $('canvas').trigger($.Event('mousemove', {clientX: x, clientY: y}));
  632.  
  633. // Stop dancing if dead ... to avoid continuing dancing after next respawn
  634. if (document.getElementById('advert').style.display != 'none') {
  635. dancing = false;
  636. }
  637. if (dancing) {
  638. window.requestAnimationFrame(dance);
  639. }
  640. }
  641.  
  642. window.addEventListener('keyup', function() {
  643. // Do nothing if a menu is open
  644. if (document.getElementById('overlays').style.display != 'none' || document.getElementById('advert').style.display != 'none') {
  645. return;
  646. }
  647.  
  648. var settings = JSON.parse(localStorage.getItem('miracleScripts'));
  649.  
  650. if (event.keyCode == settings.bindings.dance) {
  651. dancing = ! dancing;
  652.  
  653. if (dancing) {
  654. window.requestAnimationFrame(dance);
  655. }
  656. }
  657. });
  658. })();
  659.  
  660.  
  661. (function() {
  662. 'use strict';
  663.  
  664. $('#chtbox').keyup(function(event)
  665. {
  666. var settings = JSON.parse(localStorage.getItem('miracleScripts'));
  667.  
  668. var lines = settings.replacements.split('\n');
  669.  
  670. var text = $('#chtbox').val();
  671.  
  672. lines.forEach(function(line) {
  673. var replacement = line.split('|');
  674. if (replacement.length == 2) {
  675. text = text.replace(replacement[0], replacement[1]);
  676. $('#chtbox').val(text).focus();
  677. }
  678. });
  679. });
  680. })();
  681.  
  682.  
  683. (function() {
  684. 'use strict';
  685.  
  686. // We escape the message before we print them, so no one can inject JS code!
  687. var htmlEntities = function(str) {
  688. return String(str).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
  689. }
  690.  
  691. var originalFillText = CanvasRenderingContext2D.prototype.fillText
  692. var lastChatNickname = null;
  693. var lastChatNicknameColor = null;
  694. var chatLogCode = '';
  695. var chatLog = [];
  696. CanvasRenderingContext2D.prototype.fillText = function () {
  697. if (this.canvas.id != 'leaderboard' && this.canvas.height == 23) {
  698. var text = arguments[0];
  699.  
  700. // Sometimes also numbers (int) are printed so we filter for strings
  701. if (typeof text == "string" && (this.fillStyle != "#f5f6ce" && this.fillStyle !== "#444444")) {
  702. // Dirty fix for the missing icon in the initial welcome messages
  703. if (text == '') {
  704. text = '📢';
  705. }
  706. lastChatNickname = text;
  707. lastChatNicknameColor = this.fillStyle;
  708. }
  709. if (typeof text == "string" && (this.fillStyle == "#f5f6ce" || this.fillStyle == "#444444")) {
  710. // Unfortunately chat messages will be printed more than just once and I don't know
  711. // how to identifiy them, so for now all messages will be stored and only new messages will be shown.
  712. // Ofcourse this means messages won't be shown if they are sned more than once (by the same nickname).
  713. var found = false;
  714. for (var i = 0; i < chatLog.length; i++) {
  715. if (chatLog[i].nickname == lastChatNickname && chatLog[i].nicknameColor == lastChatNicknameColor && chatLog[i].message == text) {
  716. found = true;
  717. break;
  718. };
  719. }
  720.  
  721. if (! found) {
  722. // NOTE: We might have to look for the coordinates of the text to find out the order of the messages (somehow)
  723. chatLogCode += '<div><span class="time">' + (new Date().toLocaleTimeString()) + '</span> <span class="nickname" style="color: ' + lastChatNicknameColor + '">' + htmlEntities(lastChatNickname) + '</span>';
  724. chatLogCode += '<span class="message" style="color: #f5f6ce">' + htmlEntities(text) + '</span></div>';
  725. chatLog.push({nickname: lastChatNickname, nicknameColor: lastChatNicknameColor, message: text});
  726. }
  727. }
  728. }
  729.  
  730. return originalFillText.apply(this, arguments);
  731. }
  732.  
  733. var performSearch = function(searchElement) {
  734. var subject = searchElement.value.toLowerCase();
  735.  
  736. $('#miracle-complete-chatlog div').each(function(a,b,c) {
  737. var $entry = $(this);
  738.  
  739. if ($entry.text().toLowerCase().indexOf(subject) == -1 && subject != '') {
  740. $entry.hide()
  741. } else {
  742. $entry.show()
  743. }
  744. });
  745. }
  746.  
  747. 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>');
  748. $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; }</style>');
  749. $modal.append('<h1>Complete chatlog</h1><br>');
  750. $modal.append('<div id="miracle-complete-chatlog"></div>');
  751. $modal.append($('<input type="text" style="display: inline-block; position: fixed; right: 20px; bottom: 20px;" placeholder="Type to search">').keyup(function(event) { performSearch(this) }));
  752. $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() { $modal.hide() }));
  753. $('body').append($modal);
  754.  
  755. $('#miracle-complete-chatlog').dblclick(function() {
  756. var $clickTarget = null;
  757.  
  758. // Each chat message is a div with spans in it. Either the spans or the div might be clicked.
  759. if (event.target.tagName.toLowerCase() == 'span') {
  760. $clickTarget = $(event.target).parent();
  761. } else {
  762. $clickTarget = $(event.target);
  763. }
  764.  
  765. var message = $clickTarget.find('.message').text();
  766.  
  767. // Messages usually start with ': ' but we do not want to "translate" it, so we remove it
  768. if (message.substr(0, 2) == ': ') {
  769. message = message.substr(2);
  770. }
  771.  
  772. var settings = JSON.parse(localStorage.getItem('miracleScripts'));
  773.  
  774. window.open('https://www.deepl.com/translator#en/' + settings.targetLanguage + '/' + message);
  775. });
  776.  
  777. window.addEventListener('keyup', function()
  778. {
  779. // Ignore text input field so typing in them is possible
  780. if (document.activeElement.type == 'text' || document.activeElement.type == 'password') {
  781. return;
  782. }
  783.  
  784. var settings = JSON.parse(localStorage.getItem('miracleScripts'));
  785.  
  786. if (event.keyCode == settings.bindings.chatLog) {
  787. $('#miracle-complete-chatlog').html(chatLogCode);
  788. $modal.toggle();
  789. $modal.get(0).scrollTo(0,$modal.get(0).scrollHeight);
  790. }
  791. });
  792. })();
  793.  
  794.  
  795. (function() {
  796. 'use strict';
  797.  
  798. // We need to have a delay, because the menu is not loaded right away
  799. setTimeout(function() {
  800. var settings = JSON.parse(localStorage.getItem('miracleScripts'));
  801.  
  802. var favIconClick = function() {
  803. var id = parseInt($(this).parent().parent().find('button').attr('onclick').substr(11));
  804.  
  805. if (settings.favSkins.includes(id)) {
  806. $(this).addClass('skin-not-fav');
  807. $('#skinUseBtn' + id).parent().find('span').addClass('skin-not-fav');
  808. var index = settings.favSkins.indexOf(id);
  809. settings.favSkins.splice(index, 1);
  810. } else {
  811. $(this).removeClass('skin-not-fav');
  812. settings.favSkins.push(id);
  813. }
  814. localStorage.setItem('miracleScripts', JSON.stringify(settings));
  815. renderFavSkins();
  816. };
  817.  
  818. var renderFavSkins = function() {
  819. var $skins = null;
  820.  
  821. if ($('#fav-skins').length > 0) {
  822. $skins = $('#fav-skins');
  823. $skins.html('');
  824. } else {
  825. $skins = $('<div id="fav-skins" style="background-color: #4d4950"></div>');
  826. $skins.insertAfter('#publicSkinsHeader');
  827.  
  828. $('#fav-skins').click(function(event) {
  829. if (event.target.tagName.toLowerCase() == 'span') {
  830. favIconClick.apply(event.target);
  831. }
  832. });
  833. }
  834. settings.favSkins.forEach(function(id) {
  835. $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>');
  836. });
  837. $skins.append('<div style="clear: both"></div>');
  838. };
  839.  
  840. var addFavIcons = function() {
  841. var $skins = $('#publicSkinsPage');
  842. $skins.append('<style>.skin-not-fav { opacity: 0.3 }</style>');
  843.  
  844. $skins.find('h4').each(function() {
  845. var $favIcon = $('<span style="cursor: pointer">⭐</span>');
  846. var id = parseInt($(this).parent().find('button').attr('onclick').substr(11));
  847.  
  848. $favIcon.click(favIconClick);
  849.  
  850. $(this).append($favIcon);
  851.  
  852. if (! settings.favSkins.includes(id)) {
  853. $favIcon.addClass('skin-not-fav');
  854. }
  855. });
  856. }
  857. var initialized = false;
  858. $('#skinsCustomTab, #skinExampleMenu').click(function() {
  859. if (! initialized) {
  860. var checkState = function() {
  861. if ($('#publicSkinsPage').html() != '') {
  862. addFavIcons();
  863. renderFavSkins();
  864. } else {
  865. setTimeout(checkState, 30);
  866. }
  867. };
  868. checkState();
  869. initialized = true;
  870. }
  871. });
  872. $('#phpSkins').click(function(event) {
  873. if (event.target.classList.contains('publicskins-nav-btn')) {
  874. addFavIcons();
  875. }
  876. });
  877.  
  878. }, 500);
  879. })();
  880.  
  881.  
  882. (function() {
  883. 'use strict';
  884.  
  885. var settings = JSON.parse(localStorage.getItem('miracleScripts'));
  886.  
  887. var sessionStartedAt = Date.now();
  888.  
  889. var originalToggleSkin = window.toggleSkin;
  890. window.toggleSkin = function()
  891. {
  892. window.curserMessage('Picked skin with ID ' + arguments[0]);
  893.  
  894. return originalToggleSkin.apply(this, arguments);
  895. };
  896.  
  897. $('#chtbox').keydown(function(event)
  898. {
  899. if (event.keyCode == 13) {
  900. var command = $('#chtbox').val();
  901.  
  902. if (command == 'time' || command == '/time') {
  903. var now = new Date();
  904. $('#chtbox').val('Local time: '+ now.toLocaleString()).focus();
  905. }
  906.  
  907. if (command == 'minutes' || command == '/minutes') {
  908. var minutes = parseInt((Date.now() - sessionStartedAt) / 1000 / 60);
  909. if (minutes > 60) {
  910. minutes = '' + minutes;
  911. minutes = parseInt(minutes / 60) + ' Hours & ' + (minutes % 60);
  912. }
  913. $('#chtbox').val('has played for: '+ minutes + ' Minutes in the current session').focus();
  914. }
  915.  
  916. if (command == 'ping' || command == '/ping') {
  917. var pingRating = 'Extremly bad!', ping = $('#ping').text();
  918. if (parseInt(ping) > 0) {
  919. if (parseInt(ping) < 40) pingRating = 'Perfect!';
  920. if (parseInt(ping) < 70) pingRating = 'Good!';
  921. if (parseInt(ping) < 110) pingRating = 'Acceptable!';
  922. if (parseInt(ping) < 150) pingRating = 'Bad!';
  923. }
  924. else {
  925. ping = '∞ (infinite) ';
  926. }
  927. $('#chtbox').val('has a ping of: ' + ping + '. ' + pingRating).focus();
  928. }
  929. if (command == 'fps' || command == '/fps') {
  930. var fpsRating = 'Perfect!', fps = $('#fps').text();
  931. if (fps < 10) fpsRating = 'Extremly bad!';
  932. if (fps < 30) fpsRating = 'Bad!';
  933. if (fps < 40) fpsRating = 'Acceptable!';
  934. if (fps < 57) fpsRating = 'Good!';
  935.  
  936. $('#chtbox').val('has ' + fps + ' frames per second (fps). ' + fpsRating).focus();
  937. }
  938.  
  939. var useSkin = function(skinSlot, skinId) {
  940. if (skinId) {
  941. skinId = parseInt(skinId);
  942. settings.quickSkins[skinSlot - 1] = skinId;
  943. localStorage.setItem('miracleScripts', JSON.stringify(settings));
  944. } else {
  945. skinId = settings.quickSkins[skinSlot - 1];
  946. if (! skinId) {
  947. window.curserMessage('Skin not set yet, set with /skin' + skinSlot + ' id');
  948. $('#chtbox').val('').focus();
  949. return;
  950. }
  951. }
  952.  
  953. window.azad(true);
  954.  
  955. setTimeout(function() {
  956. $('#skinExampleMenu').click();
  957.  
  958. var checkLoaded = function() {
  959. var loaded = ($('#skinsFree tr').length > 1);
  960. if (loaded) {
  961. toggleSkin(skinId);
  962.  
  963. setTimeout(function(){
  964. $('#shopModalDialog button.close').click();
  965.  
  966. setTimeout(function(){
  967. setNick(document.getElementById('nick').value);
  968. }, 200);
  969. }, 200);
  970. } else {
  971. setTimeout(checkLoaded, 300);
  972. }
  973. };
  974. checkLoaded();
  975. }, 200);
  976.  
  977. $('#chtbox').val('').focus();
  978. };
  979. if (command.substr(0, 5) == 'skin1' || command.substr(0, 6) == '/skin1') {
  980. useSkin(1, command.substr(6));
  981. }
  982. if (command.substr(0, 5) == 'skin2' || command.substr(0, 6) == '/skin2') {
  983. useSkin(2, command.substr(6));
  984. }
  985. if (command.substr(0, 5) == 'skin3' || command.substr(0, 6) == '/skin3') {
  986. useSkin(3, command.substr(6));
  987. }
  988. if (command.substr(0, 5) == 'skin4' || command.substr(0, 6) == '/skin4') {
  989. useSkin(4, command.substr(6));
  990. }
  991. if (command.substr(0, 5) == 'skin5' || command.substr(0, 6) == '/skin5') {
  992. useSkin(5, command.substr(6));
  993. }
  994. }
  995. });
  996. })();
  997.  
  998.  
  999. console.log('🌸 Miracle Scripts successfully loaded!');

QingJ © 2025

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