Fav script v2.1

Best Agma.io script ever made

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

QingJ © 2025

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