ADMIN SCRIPT

Best Agma.io script ever made

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