// ==UserScript== // @name Black Magic // @namespace Black Magic // @version 3.1.3 // @description Unleash Agma.io with this extension - inofficial successor or Miracle Scripts! // @author Ventron // @license MIT // @icon https://abload.de/img/mh3k8o.png // @match *://agma.io/ // @grant none // @downloadURL https://update.greasyfork.cloud/scripts/397910/Black%20Magic.user.js // @updateURL https://update.greasyfork.cloud/scripts/397910/Black%20Magic.meta.js // ==/UserScript== (function() { 'use strict'; window.blackMagic = { // Source: http://stackoverflow.com/questions/1772179/get-character-value-from-keycode-in-javascript-then-trim#answer-23377822 keyboardMap: [ '', // [0] '', // [1] '', // [2] 'CANCEL', // [3] '', // [4] '', // [5] 'HELP', // [6] '', // [7] 'BACK_SPACE', // [8] 'TAB', // [9] '', // [10] '', // [11] 'CLEAR', // [12] 'ENTER', // [13] 'ENTER_SPECIAL', // [14] '', // [15] 'SHIFT', // [16] 'CONTROL', // [17] 'ALT', // [18] 'PAUSE', // [19] 'CAPS_LOCK', // [20] 'KANA', // [21] 'EISU', // [22] 'JUNJA', // [23] 'FINAL', // [24] 'HANJA', // [25] '', // [26] 'ESCAPE', // [27] 'CONVERT', // [28] 'NONCONVERT', // [29] 'ACCEPT', // [30] 'MODECHANGE', // [31] 'SPACE', // [32] 'PAGE_UP', // [33] 'PAGE_DOWN', // [34] 'END', // [35] 'HOME', // [36] 'LEFT', // [37] 'UP', // [38] 'RIGHT', // [39] 'DOWN', // [40] 'SELECT', // [41] 'PRINT', // [42] 'EXECUTE', // [43] 'PRINTSCREEN', // [44] 'INSERT', // [45] 'DELETE', // [46] '', // [47] '0', // [48] '1', // [49] '2', // [50] '3', // [51] '4', // [52] '5', // [53] '6', // [54] '7', // [55] '8', // [56] '9', // [57] 'COLON', // [58] 'SEMICOLON', // [59] 'LESS_THAN', // [60] 'EQUALS', // [61] 'GREATER_THAN', // [62] 'QUESTION_MARK', // [63] 'AT', // [64] 'A', // [65] 'B', // [66] 'C', // [67] 'D', // [68] 'E', // [69] 'F', // [70] 'G', // [71] 'H', // [72] 'I', // [73] 'J', // [74] 'K', // [75] 'L', // [76] 'M', // [77] 'N', // [78] 'O', // [79] 'P', // [80] 'Q', // [81] 'R', // [82] 'S', // [83] 'T', // [84] 'U', // [85] 'V', // [86] 'W', // [87] 'X', // [88] 'Y', // [89] 'Z', // [90] 'OS_KEY', // [91] Windows Key (Windows) or Command Key (Mac) '', // [92] 'CONTEXT_MENU', // [93] '', // [94] 'SLEEP', // [95] 'NUMPAD0', // [96] 'NUMPAD1', // [97] 'NUMPAD2', // [98] 'NUMPAD3', // [99] 'NUMPAD4', // [100] 'NUMPAD5', // [101] 'NUMPAD6', // [102] 'NUMPAD7', // [103] 'NUMPAD8', // [104] 'NUMPAD9', // [105] 'MULTIPLY', // [106] 'ADD', // [107] 'SEPARATOR', // [108] 'SUBTRACT', // [109] 'DECIMAL', // [110] 'DIVIDE', // [111] 'F1', // [112] 'F2', // [113] 'F3', // [114] 'F4', // [115] 'F5', // [116] 'F6', // [117] 'F7', // [118] 'F8', // [119] 'F9', // [120] 'F10', // [121] 'F11', // [122] 'F12', // [123] 'F13', // [124] 'F14', // [125] 'F15', // [126] 'F16', // [127] 'F17', // [128] 'F18', // [129] 'F19', // [130] 'F20', // [131] 'F21', // [132] 'F22', // [133] 'F23', // [134] 'F24', // [135] '', // [136] '', // [137] '', // [138] '', // [139] '', // [140] '', // [141] '', // [142] '', // [143] 'NUM_LOCK', // [144] 'SCROLL_LOCK', // [145] 'WIN_OEM_FJ_JISHO', // [146] 'WIN_OEM_FJ_MASSHOU', // [147] 'WIN_OEM_FJ_TOUROKU', // [148] 'WIN_OEM_FJ_LOYA', // [149] 'WIN_OEM_FJ_ROYA', // [150] '', // [151] '', // [152] '', // [153] '', // [154] '', // [155] '', // [156] '', // [157] '', // [158] '', // [159] 'CIRCUMFLEX', // [160] 'EXCLAMATION', // [161] 'DOUBLE_QUOTE', // [162] 'HASH', // [163] 'DOLLAR', // [164] 'PERCENT', // [165] 'AMPERSAND', // [166] 'UNDERSCORE', // [167] 'OPEN_PAREN', // [168] 'CLOSE_PAREN', // [169] 'ASTERISK', // [170] 'PLUS', // [171] 'PIPE', // [172] 'HYPHEN_MINUS', // [173] 'OPEN_CURLY_BRACKET', // [174] 'CLOSE_CURLY_BRACKET', // [175] 'TILDE', // [176] '', // [177] '', // [178] '', // [179] '', // [180] 'VOLUME_MUTE', // [181] 'VOLUME_DOWN', // [182] 'VOLUME_UP', // [183] '', // [184] '', // [185] 'SEMICOLON', // [186] 'EQUALS', // [187] 'COMMA', // [188] 'MINUS', // [189] 'PERIOD', // [190] 'SLASH', // [191] 'BACK_QUOTE', // [192] '', // [193] '', // [194] '', // [195] '', // [196] '', // [197] '', // [198] '', // [199] '', // [200] '', // [201] '', // [202] '', // [203] '', // [204] '', // [205] '', // [206] '', // [207] '', // [208] '', // [209] '', // [210] '', // [211] '', // [212] '', // [213] '', // [214] '', // [215] '', // [216] '', // [217] '', // [218] 'OPEN_BRACKET', // [219] 'BACK_SLASH', // [220] 'CLOSE_BRACKET', // [221] 'QUOTE', // [222] '', // [223] 'META', // [224] 'ALTGR', // [225] '', // [226] 'WIN_ICO_HELP', // [227] 'WIN_ICO_00', // [228] '', // [229] 'WIN_ICO_CLEAR', // [230] '', // [231] '', // [232] 'WIN_OEM_RESET', // [233] 'WIN_OEM_JUMP', // [234] 'WIN_OEM_PA1', // [235] 'WIN_OEM_PA2', // [236] 'WIN_OEM_PA3', // [237] 'WIN_OEM_WSCTRL', // [238] 'WIN_OEM_CUSEL', // [239] 'WIN_OEM_ATTN', // [240] 'WIN_OEM_FINISH', // [241] 'WIN_OEM_COPY', // [242] 'WIN_OEM_AUTO', // [243] 'WIN_OEM_ENLW', // [244] 'WIN_OEM_BACKTAB', // [245] 'ATTN', // [246] 'CRSEL', // [247] 'EXSEL', // [248] 'EREOF', // [249] 'PLAY', // [250] 'ZOOM', // [251] '', // [252] 'PA1', // [253] 'WIN_OEM_CLEAR', // [254] '' // [255] ], watermark: ' ', // Don't remove the spaces, they are used as separators! Source: https://emojiterra.com/de/liste/ emojis: '😀 😃 😄 😁 😆 😅 😂 😉 😊 😇 😍 😘 😗 ☺️ 😚 😙 😋 😛 😜 😝 😐 😑 😶 😏 😒 😬 😌 😔 😪 😴 😷 😵 😎 😕 😟 😮 😯 😲 😳 😦 😧 😨 😰 😥 😢 😭 😱 😖 😣 😞 😓 😩 😫 😤 😡 😠 😈 👿 💀 💩 👹 👺 👻 👽 👾 😺 😸 😹 😻 😼 😽 🙀 😿 😾 🙈 🙉 🙊 💋 💌 💘 💝 💖 💗 💓 💞 💕 💟 💔 ❤️ 💛 💚 💙 💜 💯 💢 💥 💫 💦 💨 💣 💬 💭 💤 👋 ✋ 👌 ✌️ 👈 👉 👆 👇 ☝️ 👍 👎 ✊ 👊 👏 🙌 👐 🙏 💅 💪 👂 👃 👀 👅 👄 👶 👦 👧 👱 👨 👩 👴 👵 🙍 🙎 🙅 🙆 💁 🙋 🙇 👮 💂 👷 👸 👳 👲 👰 👼 🎅 💆 💇 🚶 🏃 💃 👯 🏇 🏂 🏄 🚣 🏊 🚴 🚵 🛀 👭 👫 👬 💏 💑 👪 👤 👥 👣 🐵 🐒 🐶 🐕 🐩 🐺 🐱 🐈 🐯 🐅 🐆 🐴 🐎 🐮 🐂 🐃 🐄 🐷 🐖 🐗 🐽 🐏 🐑 🐐 🐪 🐫 🐘 🐭 🐁 🐀 🐹 🐰 🐇 🐻 🐨 🐼 🐾 🐔 🐓 🐣 🐤 🐥 🐦 🐧 🐸 🐊 🐢 🐍 🐲 🐉 🐳 🐋 🐬 🐟 🐠 🐡 🐙 🐚 🐌 🐛 🐜 🐝 🐞 💐 🌸 💮 🌹 🌺 🌻 🌼 🌷 🌱 🌲 🌳 🌴 🌵 🌾 🌿 🍀 🍁 🍂 🍃 🍇 🍈 🍉 🍊 🍋 🍌 🍍 🍎 🍏 🍐 🍑 🍒 🍓 🍅 🍆 🌽 🍄 🌰 🍞 🍖 🍗 🍔 🍟 🍕 🍳 🍲 🍱 🍘 🍙 🍚 🍛 🍜 🍝 🍠 🍢 🍣 🍤 🍥 🍡 🍦 🍧 🍨 🍩 🍪 🎂 🍰 🍫 🍬 🍭 🍮 🍯 🍼 ☕ 🍵 🍶 🍷 🍸 🍹 🍺 🍻 🍴 🔪 🌍 🌎 🌏 🌐 🗾 🌋 🗻 🏠 🏡 🏢 🏣 🏤 🏥 🏦 🏨 🏩 🏪 🏫 🏬 🏭 🏯 🏰 💒 🗼 🗽 ⛪ ⛲ ⛺ 🌁 🌃 🌄 🌅 🌆 🌇 🌉 ♨️ 🎠 🎡 🎢 💈 🎪 🚂 🚃 🚄 🚅 🚆 🚇 🚈 🚉 🚊 🚝 🚞 🚋 🚌 🚍 🚎 🚐 🚑 🚒 🚓 🚔 🚕 🚖 🚗 🚘 🚙 🚚 🚛 🚜 🚲 🚏 ⛽ 🚨 🚥 🚦 🚧 ⚓ ⛵ 🚤 🚢 ✈️ 💺 🚁 🚟 🚠 🚡 🚀 ⌛ ⏳ ⌚ ⏰ 🕛 🕧 🕐 🕜 🕑 🕝 🕒 🕞 🕓 🕟 🕔 🕠 🕕 🕡 🕖 🕢 🕗 🕣 🕘 🕤 🕙 🕥 🕚 🕦 🌑 🌒 🌓 🌔 🌕 🌖 🌗 🌘 🌙 🌚 🌛 🌜 ☀️ 🌝 🌞 ⭐ 🌟 🌠 🌌 ☁️ ⛅ 🌀 🌈 🌂 ☔ ⚡ ❄️ ⛄ 🔥 💧 🌊 🎃 🎄 🎆 🎇 ✨ 🎈 🎉 🎊 🎋 🎍 🎎 🎏 🎐 🎑 🎀 🎁 🎫 🏆 ⚽ ⚾ 🏀 🏈 🏉 🎾 🎳 ⛳ 🎣 🎽 🎿 🎯 🎱 🔮 🎮 🎰 🎲 ♠️ ♥️ ♦️ ♣️ 🃏 🀄 🎴 🎭 🎨 👓 👔 👕 👖 👗 👘 👙 👚 👛 👜 👝 🎒 👞 👟 👠 👡 👢 👑 👒 🎩 🎓 💄 💍 💎 🔇 🔈 🔉 🔊 📢 📣 📯 🔔 🔕 🎼 🎵 🎶 🎤 🎧 📻 🎷 🎸 🎹 🎺 🎻 📱 📲 ☎️ 📞 📟 📠 🔋 🔌 💻 💽 💾 💿 📀 🎥 🎬 📺 📷 📹 📼 🔍 🔎 💡 🔦 🏮 📔 📕 📖 📗 📘 📙 📚 📓 📒 📃 📜 📄 📰 📑 🔖 💰 💴 💵 💶 💷 💸 💳 💹 💱 💲 ✉️ 📧 📨 📩 📤 📥 📦 📫 📪 📬 📭 📮 ✏️ ✒️ 📝 💼 📁 📂 📅 📆 📇 📈 📉 📊 📋 📌 📍 📎 📏 📐 ✂️ 🔒 🔓 🔏 🔐 🔑 🔨 🔫 🔧 🔩 🔗 🔬 🔭 📡 💉 💊 🚪 🚽 🚿 🛁 🚬 🗿 🏧 🚮 🚰 ♿ 🚹 🚺 🚻 🚼 🚾 🛂 🛃 🛄 🛅 ⚠️ 🚸 ⛔ 🚫 🚳 🚭 🚯 🚱 🚷 📵 🔞 ⬆️ ↗️ ➡️ ↘️ ⬇️ ↙️ ⬅️ ↖️ ↕️ ↔️ 🔃 🔄 🔙 🔚 🔛 🔜 🔝 🔯 ♈ ♉ ♊ ♋ ♌ ♍ ♎ ♏ ♐ ♑ ♒ ♓ ⛎ 🔀 🔁 🔂 ▶️ ◀️ 🔼 🔽 🎦 📶 📳 📴 ♻️ 🔱 📛 🔰 ⭕ ✅ ☑️ ✖️ ❌ ❎ ➕ ➖ ➗ ➰ ➿ 〽️ ✳️ ✴️ ❇️ ‼️ ⁉️ ❓ ❔ ❕ ❗ 〰️ ©️ ®️ ™️ 🔠 🔡 🔢 🔣 🔤 🅰️ 🆎 🅱️ 🆑 🆒 🆓 🆔 Ⓜ️ 🆕 🆖 🅾️ 🆗 🅿️ 🆘 🆙 🆚 🈁 🈂️ 🈷️ 🈶 🈯 🉐 🈹 🈚 🈲 🉑 🈸 🈴 🈳 ㊗️ ㊙️ 🈺 🈵 🔴 🔵 ⚫ ⚪ ⬛ ⬜ ◼️ ◻️ ◾ ◽ ▪️ ▫️ 🔶 🔷 🔸 🔹 🔺 🔻 💠 🔘 🔳 🔲 🏁 🚩 🎌', settings: null, hotkeys: null, init: function() { this.setupPolyfills(); this.hotkeys = JSON.parse(localStorage.getItem('hotkeys')); this.config(); this.moveRespawnBtn(); this.players(); this.animation(); this.chatLog(); this.dance(); this.favSkins(); this.paste(); this.replacements(); this.fpsPing(); this.timer(); this.alive(); this.skinChanger(); this.skinApplier(); this.lineSplit(); this.waste(); this.nameColor(); this.skinBrowser(); this.help(); this.commands(); console.log('🔮 Black Magic successfully loaded!'); }, config: function() { var self = this; var settings = null; var loadSettings = function (stringifiedSettings) { var defaultSettings = { // To get keycodes: https://keycode.info bindings: { animation: 17, // CTRL paste: 33, // PAGE UP dance: 34, // PAGE DOWN, chatLog: 76, // L skin1: 49, // 1 skin2: 50, // 2 skin3: 51, // 3 skin4: 52, // 4 skin5: 53, // 5 skin6: 54, // 6 skin7: 55, // 7 skin8: 56, // 8 skin9: 57, // 9 }, replacements: ":D|:smile:\n:*(|:sob:\n:'D|:sweat_smiley:\nxD|:joy:", primaryColor: '#e60000', targetLanguage: 'en', favSkins: [], showClock: false, }; if (stringifiedSettings == null) { settings = defaultSettings; localStorage.setItem('miracleScripts', JSON.stringify(settings)); } else { settings = JSON.parse(stringifiedSettings); // Update for settings: if (typeof settings.primaryColor === 'undefined') { settings.primaryColor = defaultSettings.primaryColor; localStorage.setItem('miracleScripts', JSON.stringify(settings)); } if (typeof settings.bindings.chatLog === 'undefined') { settings.bindings.chatLog = defaultSettings.bindings.chatLog; localStorage.setItem('miracleScripts', JSON.stringify(settings)); } if (typeof settings.favSkins === 'undefined') { settings.favSkins = defaultSettings.favSkins; localStorage.setItem('miracleScripts', JSON.stringify(settings)); } if (typeof settings.targetLanguage === 'undefined') { settings.targetLanguage = defaultSettings.targetLanguage; localStorage.setItem('miracleScripts', JSON.stringify(settings)); } if (typeof settings.quickSkins === 'undefined') { settings.quickSkins = []; localStorage.setItem('miracleScripts', JSON.stringify(settings)); } if (typeof settings.nameChangeDelay === 'undefined') { settings.nameChangeDelay = 1000; localStorage.setItem('miracleScripts', JSON.stringify(settings)); } if (typeof settings.installedVersion === 'undefined') { settings.installedVersion = 1; localStorage.setItem('miracleScripts', JSON.stringify(settings)); } if (typeof settings.players === 'undefined') { settings.players = []; localStorage.setItem('miracleScripts', JSON.stringify(settings)); } if (typeof settings.bindings.skin1 === 'undefined') { settings.bindings.skin1 = defaultSettings.bindings.skin1; settings.bindings.skin2 = defaultSettings.bindings.skin2; settings.bindings.skin3 = defaultSettings.bindings.skin3; settings.bindings.skin4 = defaultSettings.bindings.skin4; settings.bindings.skin5 = defaultSettings.bindings.skin6; settings.bindings.skin6 = defaultSettings.bindings.skin6; settings.bindings.skin7 = defaultSettings.bindings.skin7; settings.bindings.skin8 = defaultSettings.bindings.skin8; settings.bindings.skin9 = defaultSettings.bindings.skin9; localStorage.setItem('miracleScripts', JSON.stringify(settings)); } if (typeof settings.showClock === 'undefined') { settings.showClock = false; localStorage.setItem('miracleScripts', JSON.stringify(settings)); } } self.settings = settings; }; loadSettings(localStorage.getItem('miracleScripts')); if (settings.installedVersion < this.getVersionAsInt()) { if (settings.installedVersion > 1) { // We do not want to inform new scripts user of past updates if (settings.installedVersion < this.getVersionAsInt('3.1.0')) { self.swal( 'Black Magic Update', 'New: Use the /skins command to open a super cool skin browser! It\'s much better than the built-in skin browser.'); } } settings.installedVersion = this.getVersionAsInt(); localStorage.setItem('miracleScripts', JSON.stringify(settings)); self.settings = settings; } var applyPrimaryColor = function () { var primaryColorCss = '.magic-primary-color-font { color: ' + self.settings.primaryColor + ' !important } .magic-primary-color-background { background-color: ' + self.settings.primaryColor + ' !important }; '; $('body').append(''); }; applyPrimaryColor(); // We need to have a delay, because the menu is not loaded right away setTimeout(function () { var $playButton = $('#playBtn'); var $specateButton = $('#spectateBtn'); $playButton.get(0).style.width = '40%'; $specateButton.get(0).style.width = '40%'; var $settingsButton = $(''); $settingsButton.insertAfter($playButton); var changeKey = function (event) { var name = this.name.substr(4); $(this).val(self.keyboardMap[event.keyCode]); self.settings.bindings[name] = event.keyCode; localStorage.setItem('miracleScripts', JSON.stringify(self.settings)); }; var deleteKey = function () { var action = $(this).attr('data-action'); $('#magic-settings input[name=key_' + action + ']').val('undefined'); self.settings.bindings[action] = null; localStorage.setItem('miracleScripts', JSON.stringify(self.settings)); }; // Weird Agma scripting... press enter in the replacements textarea and the chat box gets focused! // Therefore catch the keydown event (that happens earlier) and insert the linebreak manually, // focus again (delayed) and go to the end of the text where the linebreak is. // We can improve this later on... var addReturn = function (event) { if (event.keyCode === 13) { var textarea = this; $(textarea).text($(this).text() + '\n').focus(); setTimeout(function () { $(textarea).focus(); textarea.setSelectionRange(textarea.value.length, textarea.value.length); }, 1); } }; var changeReplacements = function () { self.settings.replacements = $(this).val(); localStorage.setItem('miracleScripts', JSON.stringify(self.settings)); }; var changePrimaryColor = function () { self.settings.primaryColor = $(this).val(); localStorage.setItem('miracleScripts', JSON.stringify(self.settings)); applyPrimaryColor(); }; var changeTargetLanguage = function () { self.settings.targetLanguage = $(this).val(); localStorage.setItem('miracleScripts', JSON.stringify(self.settings)); }; var changeClock = function() { self.settings.showClock = $(this).is(':checked'); localStorage.setItem('miracleScripts', JSON.stringify(self.settings)); } var $modal = $('
'); $modal.append('