fsfb script

An agma.io script, which includes fastsplit, secret bot packs, linesplit lock, and many other amazing features!

当前为 2024-06-09 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name fsfb script
  3. // @namespace http://tampermonkey.net/
  4. // @homepage https://greasyfork.org/scripts/446564/
  5. // @version 1.5.9
  6. // @description An agma.io script, which includes fastsplit, secret bot packs, linesplit lock, and many other amazing features!
  7. // @author fishy & firebone
  8. // @match *://agma.io/*
  9. // @icon data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48c3ZnIGlkPSJhIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB2aWV3Qm94PSIwIDAgNTE1IDUxNSI+PGRlZnM+PHJhZGlhbEdyYWRpZW50IGlkPSJiIiBjeD0iMjg2LjgiIGN5PSIxMDYiIGZ4PSIyODYuOCIgZnk9IjEwNiIgcj0iMTEzLjI4NCIgZ3JhZGllbnRVbml0cz0idXNlclNwYWNlT25Vc2UiPjxzdG9wIG9mZnNldD0iMCIgc3RvcC1jb2xvcj0iI2VmNDYzMCIvPjxzdG9wIG9mZnNldD0iLjEyNSIgc3RvcC1jb2xvcj0iI2VjNGUzMSIvPjxzdG9wIG9mZnNldD0iLjI1IiBzdG9wLWNvbG9yPSIjZTk1ZDM1Ii8+PHN0b3Agb2Zmc2V0PSIuNTIxIiBzdG9wLWNvbG9yPSIjZTk4MjM2Ii8+PHN0b3Agb2Zmc2V0PSIuOSIgc3RvcC1jb2xvcj0iI2ZjYzczOSIvPjxzdG9wIG9mZnNldD0iLjk4MSIgc3RvcC1jb2xvcj0iI2YxZDIzNSIvPjwvcmFkaWFsR3JhZGllbnQ+PHJhZGlhbEdyYWRpZW50IGlkPSJjIiBjeD0iMzIxLjIiIGN5PSIxMzMuMiIgZng9IjMyMS4yIiBmeT0iMTMzLjIiIHI9IjM5LjUyNSIgZ3JhZGllbnRVbml0cz0idXNlclNwYWNlT25Vc2UiPjxzdG9wIG9mZnNldD0iMCIgc3RvcC1jb2xvcj0iI2U3NDQyZSIvPjxzdG9wIG9mZnNldD0iLjEyNSIgc3RvcC1jb2xvcj0iI2U1NGMyZiIvPjxzdG9wIG9mZnNldD0iLjI1IiBzdG9wLWNvbG9yPSIjZTM1YjMzIi8+PHN0b3Agb2Zmc2V0PSIuNTIxIiBzdG9wLWNvbG9yPSIjZTk4MjM2Ii8+PHN0b3Agb2Zmc2V0PSIuOSIgc3RvcC1jb2xvcj0iI2ZjYzczOSIvPjxzdG9wIG9mZnNldD0iLjk4MSIgc3RvcC1jb2xvcj0iI2ZjYzg0OSIvPjwvcmFkaWFsR3JhZGllbnQ+PGxpbmVhckdyYWRpZW50IGlkPSJkIiB4MT0iMTg4LjE0NiIgeTE9IjIzMi41NDYiIHgyPSIxNTMuNDc5IiB5Mj0iMjU3LjA3OSIgZ3JhZGllbnRVbml0cz0idXNlclNwYWNlT25Vc2UiPjxzdG9wIG9mZnNldD0iMCIgc3RvcC1jb2xvcj0iI2UzNDIyZSIvPjxzdG9wIG9mZnNldD0iLjExNyIgc3RvcC1jb2xvcj0iI2UyNGEyZiIvPjxzdG9wIG9mZnNldD0iLjI1IiBzdG9wLWNvbG9yPSIjZTI1YjMzIi8+PHN0b3Agb2Zmc2V0PSIuNTIxIiBzdG9wLWNvbG9yPSIjZTk4MjM2Ii8+PHN0b3Agb2Zmc2V0PSIuOSIgc3RvcC1jb2xvcj0iI2ZjYzczOSIvPjxzdG9wIG9mZnNldD0iLjk4MSIgc3RvcC1jb2xvcj0iI2ZjYzg0OSIvPjwvbGluZWFyR3JhZGllbnQ+PHJhZGlhbEdyYWRpZW50IGlkPSJlIiBjeD0iMTA1LjMzMyIgY3k9IjI2Ni42NjciIGZ4PSIxMDUuMzMzIiBmeT0iMjY2LjY2NyIgcj0iMjcwLjMwNCIgZ3JhZGllbnRVbml0cz0idXNlclNwYWNlT25Vc2UiPjxzdG9wIG9mZnNldD0iLjExIiBzdG9wLWNvbG9yPSIjZmNjODQ5Ii8+PHN0b3Agb2Zmc2V0PSIuMTE0IiBzdG9wLWNvbG9yPSIjZmNjNzQ3Ii8+PHN0b3Agb2Zmc2V0PSIuMTczIiBzdG9wLWNvbG9yPSIjZmNjNzNjIi8+PHN0b3Agb2Zmc2V0PSIuMjM2IiBzdG9wLWNvbG9yPSIjZmNjNzM5Ii8+PHN0b3Agb2Zmc2V0PSIuNjEyIiBzdG9wLWNvbG9yPSIjZTk4MjM2Ii8+PHN0b3Agb2Zmc2V0PSIuNzgzIiBzdG9wLWNvbG9yPSIjZTk1ZDM1Ii8+PHN0b3Agb2Zmc2V0PSIuODgyIiBzdG9wLWNvbG9yPSIjZWU1NzM0Ii8+PHN0b3Agb2Zmc2V0PSIuODg2IiBzdG9wLWNvbG9yPSIjZWM1NjMzIi8+PHN0b3Agb2Zmc2V0PSIuOTE2IiBzdG9wLWNvbG9yPSIjZTU1MjJmIi8+PHN0b3Agb2Zmc2V0PSIxIiBzdG9wLWNvbG9yPSIjZTQ1MTJlIi8+PC9yYWRpYWxHcmFkaWVudD48cmFkaWFsR3JhZGllbnQgaWQ9ImYiIGN4PSIzNzAiIGN5PSIzMTIuMTMzIiBmeD0iMzcwIiBmeT0iMzEyLjEzMyIgcj0iMzguOTQyIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSI+PHN0b3Agb2Zmc2V0PSIwIiBzdG9wLWNvbG9yPSIjZDk0MDJiIi8+PHN0b3Agb2Zmc2V0PSIuMTE3IiBzdG9wLWNvbG9yPSIjZGE0ODJkIi8+PHN0b3Agb2Zmc2V0PSIuMjUiIHN0b3AtY29sb3I9IiNkZDU5MzIiLz48c3RvcCBvZmZzZXQ9Ii41MjEiIHN0b3AtY29sb3I9IiNlOTgyMzYiLz48c3RvcCBvZmZzZXQ9Ii45IiBzdG9wLWNvbG9yPSIjZmNjNzM5Ii8+PHN0b3Agb2Zmc2V0PSIuOTgxIiBzdG9wLWNvbG9yPSIjZmNjODQ5Ii8+PC9yYWRpYWxHcmFkaWVudD48cmFkaWFsR3JhZGllbnQgaWQ9ImciIGN4PSIzODEuMiIgY3k9IjI1OCIgZng9IjM4MS4yIiBmeT0iMjU4IiByPSIxMTMuNjAzIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSI+PHN0b3Agb2Zmc2V0PSIwIiBzdG9wLWNvbG9yPSIjZWY0NjMwIi8+PHN0b3Agb2Zmc2V0PSIuMTI1IiBzdG9wLWNvbG9yPSIjZWM0ZTMxIi8+PHN0b3Agb2Zmc2V0PSIuMjUiIHN0b3AtY29sb3I9IiNlOTVkMzUiLz48c3RvcCBvZmZzZXQ9Ii40IiBzdG9wLWNvbG9yPSIjZTk4MjM2Ii8+PHN0b3Agb2Zmc2V0PSIuNDExIiBzdG9wLWNvbG9yPSIjZTk4NDM2Ii8+PHN0b3Agb2Zmc2V0PSIuNTM2IiBzdG9wLWNvbG9yPSIjZjFhMTM3Ii8+PHN0b3Agb2Zmc2V0PSIuNjYiIHN0b3AtY29sb3I9IiNmN2I2MzgiLz48c3RvcCBvZmZzZXQ9Ii43ODIiIHN0b3AtY29sb3I9IiNmYWMyMzgiLz48c3RvcCBvZmZzZXQ9Ii45IiBzdG9wLWNvbG9yPSIjZmNjNzM5Ii8+PHN0b3Agb2Zmc2V0PSIuOTgxIiBzdG9wLWNvbG9yPSIjZmNjODQ5Ii8+PC9yYWRpYWxHcmFkaWVudD48bGluZWFyR3JhZGllbnQgaWQ9ImgiIHgxPSIyNjkuOTQ0IiB5MT0iMjg3LjM0NSIgeDI9IjI2MC41MzciIHkyPSIyODkuMTE1IiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSI+PHN0b3Agb2Zmc2V0PSIwIiBzdG9wLWNvbG9yPSIjN2U0NzBjIi8+PHN0b3Agb2Zmc2V0PSIuOTk2IiBzdG9wLWNvbG9yPSIjNWYyZjAwIi8+PC9saW5lYXJHcmFkaWVudD48bGluZWFyR3JhZGllbnQgaWQ9ImkiIHgxPSIzMzkuNTU2IiB5MT0iMjMzLjgwMSIgeDI9IjMyMi4yMjIiIHkyPSIxNzEuNDY4IiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSI+PHN0b3Agb2Zmc2V0PSIwIiBzdG9wLWNvbG9yPSIjZTlhZTM1Ii8+PHN0b3Agb2Zmc2V0PSIxIiBzdG9wLWNvbG9yPSIjZmVkNTczIi8+PC9saW5lYXJHcmFkaWVudD48bGluZWFyR3JhZGllbnQgaWQ9ImoiIHgxPSIyNTQuNDk3IiB5MT0iMTExLjkzNiIgeDI9IjIwMC4xNjQiIHkyPSIxODYuNjAzIiB4bGluazpocmVmPSIjaSIvPjwvZGVmcz48cmVjdCB3aWR0aD0iNTE1IiBoZWlnaHQ9IjUxNSIgcng9IjEwMCIgcnk9IjEwMCIgc3R5bGU9ImZpbGw6Izc1MmIxNjsiLz48cGF0aCBkPSJNMTUwLjYyMiw0NTkuOTU2YzAsOC41MzMsMjEyLjI2NywxMS4yLDIxMi4yNjcsMHMtMjEyLjI2Ny0xMi44LTIxMi4yNjcsMFoiIHN0eWxlPSJmaWxsOiM0ZTFmMTQ7IG9wYWNpdHk6Ljk7Ii8+PHBhdGggZD0iTTI2NS44NjcsNDYuOTMzczMzLjgwMSwxOS4zMzMsMzMuODAxLDQ1LjczM2MwLDMzLjYtMzIuMzM0LDQxLjQ2Ny01MC42MDEsNTYuNzM0LDAsMC00OS43MzMsMzkuNDY3LTM3LjczMyw5My42LDAsMC00MC4yNjctMzcuOTc5LTE1LjkxMS05MS40OSwxMi44LTM5LjY0NCw3Ni45NzgtNjMuNjQ0LDc2Ljk3OC04OC44ODksMCwwLDEuMTU2LTIuNC02LjUzMy0xNS42ODlaIiBzdHlsZT0iZmlsbDp1cmwoI2IpOyIvPjxwYXRoIGQ9Ik0zMjAuOCwxMjUuMmMxNS40LDE1LjQsMzAuMjY3LTEzLjMzMywyNy40NjctMTkuNDY3LTguNjY3LTMuMzMzLTI2LjgtNi4xMzMtMjcuNDY3LDE5LjQ2N1oiIHN0eWxlPSJmaWxsOnVybCgjYyk7Ii8+PHBhdGggZD0iTTE5Mi4zMzQsMjQ5LjczM2MtNy45MzQsMTEuODY3LTM4LjczNCwxOS4zMzMtNDYuNjAxLTguNTMzLDQuNDkxLTQuMzUsMTYuOTU3LTkuNjYxLDI3Ljg2OC05LjQxMiw5LjgyMywuMjI0LDE4LjM4NSwzLjk1MywxOC43MzMsMTcuOTQ1WiIgc3R5bGU9ImZpbGw6dXJsKCNkKTsiLz48cGF0aCBkPSJNMjI3LjcxNSwyNTMuNjhjLTEyLTczLjM3OCw1Ni4zODQtMTA2LjI1OCw5MC44MjgtMTEwLjQ4LDAsMC0zMy41MTEsMjYuNDg5LTMzLjUxMSw2My4wMjJzMzcuNiw2OC44LDM3LjYsNjguOGMwLDAsNDUuMzMzLDMzLjg2Nyw0NS4zMzMsODYuOTMzcy00Mi4zMTEsOTguMjIyLTExMS40MzMsOTguMjIyLTk2LjAzMy01MC44NDQtMTAwLjMtNjAuOTc4Yy00LjI2Ny0xMC4xMzMtMzguNzU2LTE2LTM4Ljc1Ni0xNiwwLDAsMy43MzMtMzQuMzExLDMzLjQyMi01Ni41MzMsMTcuNTExLTUwLjU1NSw1MS43MTgtNjcuOTg3LDc2LjgxNi03Mi45ODYsNi40OTktMS4yOTQsMTIuNDAyLTEuNjgsMTcuMjI4LTEuNjgsMTUuNjQ0LDMuOTExLDE4Ljg0NCw2NS44OSwxOC44NDQsNjUuODksMCwwLTMyLjcxMSwzLjc5OS00NS4zMzMtMi40MjMsOS43NzgsMTEuOTExLDQwLjg4OSwxNC43NTYsNDAuODg5LDE0Ljc1Ni0uNTMzLDIzLjExMS00MS42LDM5LjQ2Ny0zNS4yLDkzLjY4OSw2LjA0NCw5LjI0NCwzNS4wMjIsNy40NjcsMzUuMDIyLDcuNDY3LDQ0LjQ0OS03LjY1Myw0NS4zMzMtNjUuMTMzLDQuNjIyLTExMy40ODhtLTQwLjg4OS00NS4yNjdjLTUuNDQ5LDAtOS44NjcsNC40MTctOS44NjcsOS44NjdzNC40MTcsOS44NjcsOS44NjcsOS44NjcsOS44NjctNC40MTcsOS44NjctOS44NjctNC40MTctOS44NjctOS44NjctOS44NjdaIiBzdHlsZT0iZmlsbDp1cmwoI2UpOyIvPjxwYXRoIGQ9Ik0zNjUuMzMzLDMwNy4wNjdjLjEzMy0xOC44LDEzLjczMy0yNy4zMzMsMjcuNzMzLTE5LjQ2NywxLjMzMywxNi41MzMtMTguMjgxLDMyLjkzMy0yNy43MzMsMTkuNDY3WiIgc3R5bGU9ImZpbGw6dXJsKCNmKTsiLz48cGF0aCBkPSJNMzU2Ljg2NywyNzguNDY3czE2Ljk5OS04Ljg2NywxNi45OTktMjguMDY3LTE4LTM1LjItMTgtMzUuMmMwLDAtMTcuODY3LTE5LjYtMTcuODY3LTM4LjhzOC44LTMyLjgsOC44LTMyLjhjMCwwLTM5LjEyNCwxOC4wMDctMzkuODY3LDU2LjgsMCwwLTEuNiwyNS42LDE0LjUzMyw0NC4xMzMsMCwwLDI4LjEzNSwzMy45MzQsMzUuNDAxLDMzLjkzNFoiIHN0eWxlPSJmaWxsOnVybCgjZyk7Ii8+PHBhdGggZD0iTTI2My43ODgsMzE3Ljg5Yy0xLjQxNi0xNC40MDMtNC41MS01NS41NTYtMTYuNTUtNjUuMDc4LDMxLjkyOSwxMi4zNTUsMjMuMDAzLDczLjI4NCwyMy4wMDMsNzMuMjg0bC02LjQ1My04LjIwNloiIHN0eWxlPSJmaWxsOnVybCgjaCk7IG9wYWNpdHk6LjY7Ii8+PHBhdGggZD0iTTMyMi4xNjcsMzMxLjgzM2MxMi41LDI5LjgzMywxOC4zNTMsODMuODExLTM0LDEwNC44MzMsNDMuODMzLTI3Ljc3OCw0MC43NzgtODQuMjc4LDM0LTEwNC44MzNaIiBzdHlsZT0iZmlsbDojZjU4NjYzOyIvPjxwYXRoIGQ9Ik0yNzUuMjA4LDI2OS4zNjdjLTM1LjkzNC00MS4xNjYtMjQuMTExLTk1LjI3OCw0My4xNjctMTI2LjE2Ny01Ni4xNjcsMzUuNTU2LTcwLjE2Nyw2OC4zMzMtNDMuMTY3LDEyNi4xNjdaIiBzdHlsZT0iZmlsbDojZjlhMzVkOyIvPjxwYXRoIGQ9Ik0yMjQuMjA0LDQyMy44NjRsLS43MDItOC40MTlzLTM3LTE2LjY2Ny0zNy0zOGMwLDMyLjY2NywzNy43MDIsNDYuNDE5LDM3LjcwMiw0Ni40MTlaIiBzdHlsZT0iZmlsbDojZjhhYzVlOyIvPjxwYXRoIGQ9Ik0zNDMuMjIyLDIzMS42NjdjLTguNjA4LTEwLjI3Mi0zMS40NzItMzQuOTE3LTE1LjU1Ni02My40NDQtMy41ODMsMjQuOTQ0LDIuNjY3LDM5LjI3OCwxNS41NTYsNjMuNDQ0WiIgc3R5bGU9ImZpbGw6dXJsKCNpKTsiLz48cGF0aCBkPSJNMjA0LDE5MS44MzNjLTUuNS0xOC42NjcsMjYuMjUtNjIuNTgzLDQ5LjgzMy03Ny00NSw1NS41LTM5LjE2Nyw1MS4zMzMtNDkuODMzLDc3WiIgc3R5bGU9ImZpbGw6dXJsKCNqKTsiLz48L3N2Zz4=
  10. // @run-at document-start
  11. // @require https://greasyfork.org/scripts/459346-fsfb-facts/code/fsfb%20facts.js?version=1145073
  12. // @license GPL-3.0-or-later
  13. // @connect translate.google.com
  14. // @connect greasyfork.org
  15. // @grant unsafeWindow
  16. // @grant GM_setValue
  17. // @grant GM_getValue
  18. // @grant GM_xmlhttpRequest
  19. // @grant GM_registerMenuCommand
  20. // @grant GM_unregisterMenuCommand
  21. // ==/UserScript==
  22.  
  23.  
  24.  
  25. // ~~~~~~~~~ Don't change anything below this unless you know what you are doing ~~~~~~~~~
  26. const version = typeof GM_info != 'undefined' && GM_info?.script?.version || '1.5.9';
  27.  
  28. let settings = {
  29. hotkeys: [
  30. {title: "Shoot 7 Ejected", id: "fsfb-key7Feed", key: 0, active: false}, // 0
  31. {title: "Linesplit Lock", id: "fsfb-linesplit", key: 0, active: false}, // 1
  32. {title: "Macro Split Bots", id: "fsfb-MacroSplitBots", key: 0, active: false}, // 2
  33. {title: "Hide UI", id: "fsfb-hideUI", key: 0, active: false}, // 3
  34. {title: "Toggle Cursor", id: "fsfb-togglecursor", key: 0, active: false}, // 4
  35. {title: "Check Profile", id: "fsfb-checkprofile", key: 0, active: false} // 5
  36. ],
  37. fastsplit_hotkeys: [
  38. {title: "Fast Onesplit", id: "fsfb-fsOne", keyName: "", keyCode: 0, active: false}, // 0
  39. {title: "1st Delay (ms)", id: "fsfb-firstdelay", val: 60, active: false}, // 1
  40. {title: "2nd Delay (ms)", id: "fsfb-secdelay", val: 60, active: false}, // 2
  41. {title: "Fast Doublesplit", id: "fsfb-fsTwo", keyName: "", keyCode: 0, active: false}, // 3
  42. {title: "1st Delay (ms)", id: "fsfb-dubfirstdelay", val: 60, active: false}, // 4
  43. {title: "2nd Delay (ms)", id: "fsfb-dubsecdelay", val: 60, active: false}, // 5
  44. {title: "Fast Triplesplit", id: "fsfb-fsThree", keyName: "", keyCode: 0, active: false}, // 6
  45. {title: "1st Delay (ms)", id: "fsfb-threefirstdelay", val: 120, active: false}, // 7
  46. {title: "2nd Delay (ms)", id: "fsfb-threesecdelay", val: 60, active: false} // 8
  47. ],
  48. frozenvirus: [
  49. {title: "Frozen Virus", id: "fsfb-frzvs", key: 0, active: false},
  50. {title: "Press Delay (ms)", id: "fsfb-fvsdelay", val: 100, active: false}
  51. ],
  52. checkboxes: [
  53. {title: "Chat Copy/Cut/Paste", id: "fsfb-copycutpaste", active: false}, // 0
  54. {title: "Anti-AFK", id: "fsfb-antiAFK", active: false}, // 1
  55. {title: "Anti-Invis", id: "fsfb-anticloak", active: false}, // 2
  56. {title: "Linesplit Toggle", id: "fsfb-linetoggle", active: false}, // 3
  57. {title: "Change Page Title", id: "fsfb-changetitle", active: false}, // 4
  58. {title: "Hide Shouts", id: "fsfb-hideshouts", active: false}, // 5
  59. {title: "Hold To Spam Rec/Spd", id: "fsfb-recospeed", active: false}, // 6
  60. {title: "Show Portal Mass", id: "fsfb-portalmass", active: false}, // 7
  61. {title: "Pow Spawns Overlay", id: "fsfb-powsoverlay", active: false}, // 8
  62. {title: "Mothercell Mass", id: "fsfb-mtchmass", active: false}, // 9
  63. {title: "Inventory One Row", id: "fsfb-pwsonerow", active: false}, // 10
  64. {title: "Quick Buy", id: "fsfb-qBuy", active: false} // 11-
  65. ],
  66. slowFeed: [
  67. {title: "Toggle Feed", id: "fsfb-slowFeed", key: 0, active: false},
  68. {title: "Feed Delay (ms)", id: "fsfb-slowfeedtime", val: 100, active: false}
  69. ],
  70. quickSettings: [
  71. {id: "fsfb-quick-hotkey1", id1: "fsfb-quick-select1", set: "cSkins", key: 0, active: false},
  72. {id: "fsfb-quick-hotkey2", id1: "fsfb-quick-select2", set: "cWearables", key: 0, active: false},
  73. {id: "fsfb-quick-hotkey3", id1: "fsfb-quick-select3", set: "cFood", key: 0, active: false},
  74. {id: "fsfb-quick-hotkey4", id1: "fsfb-quick-select4", set: "cBubbleCells", key: 0, active: false},
  75. {id: "fsfb-quick-hotkey5", id1: "fsfb-quick-select5", set: "cNames", key: 0, active: false},
  76. {id: "fsfb-quick-hotkey6", id1: "fsfb-quick-select6", set: "cNameOutlines", key: 0, active: false}
  77. ],
  78. uiScaling: [
  79. // {title: "Chat Size", id: "fsfb-chatSize", level: 5},
  80. {title: "Inventory Size", id: "fsfb-invSize", level: 5}, // 0
  81. {title: "Food Size", id: "fsfb-foodSize", level: 1}, // 1
  82. {title: "Statsbox Size", id: "fsfb-statsSize", level: 5} // 2
  83. ],
  84. theme: [
  85. {title: "Food Color", id: "fsfb-check-foodcolor", id1: "fsfb-color-foodcolor", color: "#FFFFFF", active: false}, // 0
  86. {title: "Virus Color", id: "fsfb-check-viruscolor", id1: "fsfb-color-viruscolor", color: "#00ff00", active: false}, // 1
  87. {title: "Virus Stroke", id: "fsfb-check-virusstroke", id1: "fsfb-color-virusstroke", color: "#00ff00", active: false}, // 2
  88. {title: "Mothercell Color", id: "fsfb-check-msColor", id1: "fsfb-color-msColor", color: "#cd5564", active: false}, // 3
  89. {title: "Mothercell Stroke", id: "fsfb-check-msStroke", id1: "fsfb-color-msStroke", color: "#cd5564", active: false}, // 4
  90. {title: "Border Color", id: "fsfb-check-border", id1: "fsfb-color-border", color: "#CC3030", active: false}, // 5
  91. {title: "BR Hazard Zone", id: "fsfb-check-Hazard", id1: "fsfb-color-hazard", color: "#cc3030", active: false} // 6
  92. ],
  93. theme_boxes: [
  94. {title: "Fancy Bubble Cells", id: "fsfb-bublecell", active: false}, // 0
  95. {title: "Show Player Mass", id: "fsfb-showmass", active: false}, // 1
  96. {title: "Only My Skin", id: "fsfb-myskins", active: false}, // 2
  97. {title: "Only Party Skins", id: "fsfb-partyskins", active: false}, // 3
  98. {title: "Only My Nick", id: "fsfb-mynick", active: false}, // 4
  99. {title: "Only Party Nicks", id: "fsfb-partynicks", active: false}, // 5
  100. {title: "Spiked Cells", id: "fsfb-spikedcells", active: false}, // 6
  101. {title: "Reverse Cell Order", id: "fsfb-revcell", active: false}, // 7
  102. {title: "Render Portals Top", id: "fsfb-portalstop", active: false}, // 8
  103. ],
  104. name_color: [
  105. {title: "Public Name Color", id: "fsfb-nc-public", active: true}, // 0
  106. // start with a (somewhat) random color so not everyone has the same color
  107. {title: "Name Color", id: "fsfb-box-nc", id1: "fsfb-nc-color", color: ["#22FF22", "#2299FF", "#FF9922", "#FF2222", "#000000", "#800080", "#0086b9"][~~(new Date().getHours() % 7)], active: false}, // 1
  108. {title: "Name Stroke", id: "fsfb-box-ncs", id1: "fsfb-nc-stroke", color: ["#000000", "#000000", "#000000", "#000000", "#777777", "#f5e666", "#06ffda"][~~(new Date().getHours() % 7)], active: false} // 2
  109. ],
  110. anti_lag: [
  111. {title: "Hide Small Minions", id: "fsfb-hideminions", active: false}, // 0
  112. {title: "No Minion Skins", id: "fsfb-nominionskins", active: false}, // 1
  113. {title: "Hide All Ejected", id: "fsfb-hideejected", active: false}, // 2
  114. {title: "Hide Static Ejected", id: "fsfb-hidestaticej", active: false}, // 3
  115. {title: "No Eat Anims", id: "fsfb-nodeathanims", active: false} // 4
  116. ],
  117. chat_translate: [
  118. {title: "Translate Chat", id: "fsfb-tranchat", active: false}, // 0
  119. {title: "Translate Server", id: "fsfb-tranplyr", active: false}, // 1
  120. {title: "Show Original", id: "fsfb-tranorig", active: false}, // 2
  121. {title: "Translate From:", id: "fsfb-tran1", set: "auto"}, // 3
  122. {title: "Translate To:", id: "fsfb-tran2", set: "auto"} // 4
  123. ],
  124. export_import: [
  125. {title: "Game Settings", id: "fsfb-game-settings", active: false},
  126. {title: "Game Controls", id: "fsfb-game-controls", active: false},
  127. {title: "Custom Background", id: "fsfb-custom-bg", active: false},
  128. {title: "Script Settings", id: "fsfb-script-settings", active: false},
  129. {title: "Script Theme", id: "fsfb-theme-settings", active: false}
  130. ]
  131.  
  132. }, misc_settings = {
  133. abil: {},
  134. bots: {},
  135. statsPos: null,
  136. statsSettings: {
  137. xp: {
  138. lvlcomp: true,
  139. rem: true,
  140. projhr: true,
  141. lasthr: true,
  142. lastmin: true,
  143. lastsec: true,
  144. mean: true,
  145. median: true,
  146. sd: true,
  147. sesh: true,
  148. seshlength: true,
  149. lifetime: true
  150. },
  151. coins: {
  152. rem: true,
  153. projhr: true,
  154. lasthr: true,
  155. lastmin: true,
  156. mean: true,
  157. median: true,
  158. sd: true,
  159. sesh: true,
  160. seshlength: true
  161. }
  162. }
  163. }
  164. // Don't edit these settings directly (changing code) unless you aren't using tampermonkey or can't access the settings via the menu commands
  165. let userPreferences = {
  166. hideAds: true,
  167. improvedShop: true,
  168. extraBotPacks: true,
  169. rightClickCopyChat: true,
  170. rightClickCopyInfo: true,
  171. showRemainingAbilityTime: true,
  172. unlockFreeSkins: true,
  173. hoverShowSkinID: true,
  174. coinXPstats: true,
  175. saveStatsBoxPosition: true,
  176. showXPdecimals: true,
  177. whiteBorder4BlackCells: true,
  178. sortWearablesByOwned: true,
  179. linesplitClosestSide: false,
  180. // friendDeclineAll: true,
  181. rainbowMapBorder: false,
  182. rainbowBorderSpeed: 5,
  183. rainbowBrHazard: false,
  184. rainbowBrHazardSpeed: 5,
  185. extraChatCommands: true,
  186. chatPrefix: '/f ',
  187. bypassConfirmChatRules: true,
  188. publicSkinSearch: true,
  189. extraOneFastSplitDelay: false,
  190. notifyNewUpdates: true,
  191. preventAutoLowGraphics: true,
  192. stylizeActiveSettings: true,
  193. removeMultiFeedPopup: true,
  194. level1kFix: true,
  195. messageBanWarning: true,
  196. removeModMessages: false,
  197. removeColorTagsInChat: true,
  198. tripleFastSplitSetting: false,
  199. rainbowNameColor: false,
  200. rainbowNameSpeed: 3
  201. }
  202. const keyCodeMappings = { 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", 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 /", 112: "F1", 113: "F2", 114: "F3", 115: "F4", 116: "F5", 117: "F6", 118: "F7", 119: "F8", 120: "F9", 121: "F10", 122: "F11", 123: "F12", 124: "F13", 125: "F14", 126: "F15", 127: "F16", 128: "F17", 129: "F18", 130: "F19", 131: "F20", 132: "F21", 133: "F22", 134: "F23", 135: "F24", 144: "NUMLOCK", 145: "SCROLLLOCK", 186: ";", 187: "=", 188: ",", 189: "-", 190: ".", 191: "/", 192: "`", 219: "[", 220: "\\", 221: "]", 222: "'"}, cmap = { a: "а", e: "е", i: "і", o: "ο", u: "υ", y: "у", A: "А", E: "Е", I: "Ӏ", O: "Ο", U: "𝗨", Y: "Υ"};
  203. const invisUnicodeIds = [9, 32, 160, 847, 1564, 4448, 6068, 6069, 8192, 8193, 8194, 8195, 8196, 8197, 8198, 8199, 8200, 8201, 8232, 8239, 8287, 8289, 8290, 8291, 8292, 8298, 8299, 8300, 8301, 8302, 8303, 12288, 12644, 65440];
  204.  
  205. const setStorage = (name, obj) => typeof GM_setValue != "function" ? localStorage.setItem(name, JSON.stringify(obj)) : GM_setValue(name, obj),
  206. getStorage = (name, default_obj) => typeof GM_getValue != "function" ? localStorage.getItem(name) != null ? JSON.parse(localStorage.getItem(name)) : setStorage(name, default_obj) : GM_getValue(name, default_obj);
  207.  
  208. if(typeof unsafeWindow === 'undefined') unsafeWindow = window;
  209.  
  210. const saveSettings = () => setStorage("fsfb-scripts", settings);
  211. const getSettings = () => {
  212. let settingsPrev = getStorage("fsfb-scripts", settings);
  213. for(let i in settingsPrev) {
  214. for(let j in settingsPrev[i]) {
  215. for(let x in settings){
  216. for(let y in settings[x]){
  217. if(settingsPrev[i][j].id == settings[x][y].id) settings[x][y] = settingsPrev[i][j];
  218. }
  219. }
  220. }
  221. }
  222. }
  223.  
  224. let prevPreferences = getStorage('fsfb-user-settings', userPreferences);
  225.  
  226. for(let prevSetting in prevPreferences) {
  227. for(let currSetting in userPreferences){
  228. if(prevSetting == currSetting) userPreferences[currSetting] = prevPreferences[prevSetting]; //settings[x][y] = settingsPrev[i][j];
  229. }
  230. }
  231.  
  232. const getMiscSettings = () => {
  233. let prevSettings = getStorage("fsfb-misc", misc_settings);
  234. misc_settings = {...misc_settings, ... prevSettings};
  235. }
  236. getSettings();
  237. getMiscSettings();
  238.  
  239. const getName = key => key ? keyCodeMappings[key] ?? String.fromCharCode(key) : '';
  240.  
  241. const levelSum = lvl => lvl * --lvl / 2,
  242. range = arr => Math.max(...arr) - Math.min(...arr),
  243. sigma = arr => arr.reduce((a, b) => a + b),
  244. mean = arr => sigma(arr) / arr.length,
  245. variance = arr => arr.reduce((a, b) => a + (b - mean(arr)) ** 2, 0) / arr.length,
  246. standardDeviation = arr => Math.sqrt(variance(arr)),
  247. ascending = arr => arr.sort((a, b) => a - b),
  248. getIQR = arr => quartile(arr, .75) - quartile(arr, .25),
  249. round = (num, places = 0) => Math.round(num * +("1e" + places)) / +("1e" + places);
  250. const median = arr => {
  251. const mid = ~~(arr.length / 2),
  252. asc = ascending(arr);
  253. return arr.length % 2 !== 0 ? asc[mid] : (asc[mid - 1] + asc[mid]) / 2;
  254. }
  255. const getProperty = (arr, property) => {
  256. let newArr = [];
  257. for (let i of arr) newArr.push(i[property]);
  258. return newArr;
  259. }
  260. const quartile = (arr, q) => {
  261. const sorted = ascending(arr),
  262. pos = (sorted.length - 1) * q,
  263. base = ~~pos,
  264. rest = pos - base;
  265. return sorted[base + 1] !== null ? sorted[base] + rest * (sorted[base + 1] - sorted[base]) : sorted[base]
  266. }
  267. const checkOutliers = (arr, returnOutliers) => {
  268. let nonOutliers = [], outliers = [];
  269. const IQR = getIQR(arr),
  270. Q1 = quartile(arr, .25),
  271. Q3 = quartile(arr, .75);
  272. for (let i of arr) i < Q1 - 1.5 * IQR || i > Q3 + 1.5 * IQR ? outliers.push(i) : nonOutliers.push(i);
  273. return returnOutliers ? outliers : nonOutliers;
  274. }
  275. const msToTime = ms => {
  276. const pad = num => num < 10 ? '0' + ~~num : ~~num;
  277. return `${pad(ms / 36e5)}:${pad(ms / 6e4 % 60)}:${pad(ms / 1e3 % 60)}`; // hrs:mins:secs
  278. }
  279. const changeTitle = title => {
  280. if(document.title != title) document.title = title;
  281. };
  282.  
  283. if(settings.checkboxes[4].active && document.title == 'Agma.io - A free multiplayer MMO game') changeTitle('Agma.io');
  284.  
  285. if(userPreferences.unlockFreeSkins){
  286. ["", 56, 1657, 2281, 2282, 2297, 2331, 2529, 2626, 2683, 2816, 2832].forEach(id => localStorage.setItem('ytSkin' + id, '1'));
  287. localStorage.setItem('fbSkin', '1');
  288. }
  289.  
  290. const softSanitize = str => {
  291. const map = {
  292. '&': '&amp;',
  293. '<': '&lt;',
  294. '>': '&gt;',
  295. '"': '&quot;',
  296. "'": '&#x27;',
  297. "/": '&#x2F;',
  298. };
  299. return str.replace(/[&<>"'/]/ig, match => map[match]);
  300. }
  301.  
  302. const escapeRegExp = str => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
  303.  
  304. ['paste', 'copy', 'cut'].forEach(a => {
  305. unsafeWindow.addEventListener(a, e => {
  306. if(document.querySelector('#fsfb-copycutpaste')?.checked) e.stopImmediatePropagation();
  307. }, true)
  308. });
  309.  
  310.  
  311. let agmaHotkeys = JSON.parse(localStorage.getItem('hotkeys'));
  312. let agmaSettings = JSON.parse(localStorage.getItem('settings'));
  313.  
  314. Object.defineProperty(unsafeWindow, 'localStorage', {
  315. value: new Proxy(localStorage, {
  316. set: function (ls, prop, val) {
  317. if(prop === 'hotkeys') agmaHotkeys = JSON.parse(val);
  318. else if(prop === 'settings'){
  319. let prevNick = agmaSettings?.nickName;
  320. agmaSettings = JSON.parse(val);
  321. if(settings.name_color[0].active && !!document.querySelector('#nick') && prevNick && prevNick != agmaSettings.nickName) val = JSON.stringify((agmaSettings.nickName = document.querySelector('#nick').value, agmaSettings));
  322. }
  323. return !void(ls[prop] = val);
  324. },
  325. get: function(ls, prop) {
  326. if(prop === "settings" && unsafeWindow?.uisdoa?.o){
  327. let realsetting = JSON.parse(prop === 'setItem' || typeof ls[prop] === 'function' ? ls[prop].bind(ls) : ls[prop]);
  328. realsetting.wearablesSelected = [
  329. { "wearId": 57,
  330. "N": 0,
  331. "zIndex": 0,
  332. "wearGroup": 4,
  333. "wearTry": false }];
  334. return JSON.stringify(realsetting);
  335. }
  336. return prop === 'setItem' || typeof ls[prop] === 'function' ? ls[prop].bind(ls) : ls[prop];
  337. }
  338. }),
  339. configurable: true,
  340. enumerable: true
  341. });
  342.  
  343. const hotkeysMap = {
  344. 360: "W360",
  345. Split: "Space",
  346. DoubleSplit: "D",
  347. TripleSplit: "T",
  348. MacroSplit: "Z",
  349. MacroFeed: "W",
  350. FixedMouse: "C",
  351. Respawn: "M",
  352. MultiFeed: "V",
  353. Recombine: "E",
  354. Speed: "S",
  355. FreezeSelf: "F",
  356. Invisibility: "I",
  357. DropWall: "DW",
  358. ToggleCamera: "Q",
  359. FreezeCamera: "F",
  360. ToggleControlBots: "Q",
  361. SplitBots: "A",
  362. FeedBots: "X"
  363. }
  364. const getKey = id => agmaHotkeys && agmaHotkeys[hotkeysMap?.[id.replace(/^key/gm, '')]]?.c;
  365. unsafeWindow.getKey = getKey;
  366.  
  367. if(userPreferences.bypassConfirmChatRules) localStorage.setItem('crc', 'true');
  368.  
  369.  
  370. const insertCustomjQuery = $ => {
  371. // const { $ } = unsafeWindow;
  372.  
  373. if(userPreferences.extraBotPacks){
  374.  
  375. const newBots = [
  376. {title: "100 Bots", time: "24 HOURS", price: "700,000", id: 9},
  377. {title: "125 Bots", time: "48 HOURS", price: "900,000", id: 10},
  378. {title: "300 Bots", time: "24 HOURS", price: "900,000", id: 7},
  379. {title: "100 MASS Bots", time: "1 HOURS", price: "800,000", id: 8},
  380. {title: "300 Bots", time: "72 HOURS", price: "2,000,000", id: 11},
  381. {title: "100 MASS Bots", time: "24 HOURS", price: "2,600,000", id: 12},
  382. {title: "500 MASS Bots", time: "2 HOURS", price: "20,000,000", id: 17},
  383. {title: "500 MASS Bots", time: "12 HOURS", price: "30,000,000", id: 16}
  384. ]
  385.  
  386.  
  387. if(document.getElementsByClassName('tab-container-section minion scroll')?.[0]?.children?.[0].children.length){ // check if minions page has already been loaded
  388. $('.confirm-minion[item=7], .confirm-minion[item=8]').parent().hide();
  389. for(let i of newBots) createEl(i);
  390. document.getElementById('extraTab').childNodes[0].setAttribute('onclick', '');
  391. $('.confirm-minion.extra-min').click(function(e) {
  392. e.preventDefault(); // Prevent the href from redirecting directly
  393. const { setMinionUi, purchaseMinion } = unsafeWindow;
  394. let linkURL = $(this).attr("href"),
  395. priceK = $(this).attr("price"),
  396. itemId = $(this).attr("item");
  397. setMinionUi(true);
  398. unsafeWindow.swal({
  399. title: "Confirm",
  400. text: 'If you click "Buy", you will purchase these minions. They cost ' + priceK,
  401. type: "warning",
  402. showCancelButton: true,
  403. confirmButtonColor: "#4CAF50",
  404. confirmButtonText: "Yes, confirm purchase",
  405. cancelButtonText: "No, cancel purchase"
  406. }, function() {
  407. purchaseMinion(itemId);
  408. });
  409. });
  410. } else {
  411. const _$click = $.prototype.click;
  412.  
  413. $.prototype.click = function(){
  414. if(this.selector === ".confirm-minion" && typeof arguments[0] === 'function'){
  415. $('.confirm-minion[item=7], .confirm-minion[item=8]').parent().hide();
  416. for(let i of newBots) createEl(i);
  417. document.getElementById('extraTab').childNodes[0].setAttribute('onclick', '');
  418. return _$click.apply($('.confirm-minion'), arguments);
  419. }
  420. return _$click.apply(this, arguments);
  421. }
  422. }
  423. function createEl(i) {
  424. const botEl = document.createElement('li');
  425. botEl.setAttribute('class', 'masterTooltip extra-min');
  426. botEl.setAttribute('title', 'Spawns bots/minions which suicide into your playercell to make you big in no time! Minions follow your mouse and split upon your command! Minions start immediately after you buy them.');
  427. document.getElementsByClassName('tab-container-section minion scroll')[0].children[0].children[0].appendChild(botEl);
  428. botEl.innerHTML = `<div class="title_prch"><img src="img/store/minions/minions_tab.png" width="70px" height="60px"><div class="minionDescription"><h4 style="font-size: 18px;">${i.title}</h4><h3 style="margin-top:10px;color:white;"> ${i.time}</h3></div> <span class="win-price">${i.price}</span></div><a href="#" price="${i.price}" item="${i.id}" class="purchase-btn2 confirm-minion extra-min">Buy</a>`;
  429. }
  430. }
  431. }
  432.  
  433.  
  434. if(typeof unsafeWindow.$ === 'function'){
  435. insertCustomjQuery(unsafeWindow.$);
  436. } else {
  437. let setjQueryVal;
  438. Object.defineProperty(unsafeWindow, '$', { // intercept immediately after jQuery is defined on window
  439. set: function(val) {
  440. setjQueryVal = val;
  441. insertCustomjQuery(val);
  442. },
  443. get: function() {
  444. return setjQueryVal;
  445. },
  446. configurable: true
  447. });
  448. }
  449.  
  450.  
  451. const afterLoaded = () => {
  452.  
  453. unsafeWindow.fsfbStartedLoading = true;
  454. const { $, swal, purchaseItem, hotkeySetDefaults, setDefaults, uisdoa } = unsafeWindow;
  455.  
  456. // attempt to prevent the script from being active on subpages of agma.io
  457. if($ == null || $('#friendResizer').length < 1 || $('#megaholder').length < 1 || $('#preroll').length < 1) return;
  458.  
  459. if(!agmaHotkeys) hotkeySetDefaults();
  460. if(!agmaSettings) setDefaults();
  461.  
  462. if(typeof GM_registerMenuCommand === 'function' && typeof GM_unregisterMenuCommand === 'function'){
  463.  
  464. const addMenuCmd = (name, callback, accessKey) => GM_registerMenuCommand(name, callback, accessKey);
  465. const remMenuCmd = command_id => GM_unregisterMenuCommand(command_id);
  466.  
  467. let expandedUserPref = {
  468. hideAds: { title: 'Hide Ads', type: 'bool' },
  469. improvedShop: { title: 'Improved Shop', type: 'bool' },
  470. extraBotPacks: { title: 'Better Shop', type: 'bool' },
  471. rightClickCopyChat: { title: 'Right-Click Copy Chat', type: 'bool' },
  472. rightClickCopyInfo: { title: 'Right-Click Copy Info', type: 'bool' },
  473. showRemainingAbilityTime: { title: 'Show Remaining Abilities', type: 'bool' },
  474. unlockFreeSkins: { title: 'Unlock Free Skins', type: 'bool' },
  475. hoverShowSkinID: { title: 'Hover Show Skin ID', type: 'bool' },
  476. coinXPstats: { title: 'Coin/XP Statistics', type: 'bool' },
  477. saveStatsBoxPosition: { title: 'Save Stats-Box Position', type: 'bool' },
  478. showXPdecimals: { title: 'Show Decimals in % XP', type: 'bool' },
  479. whiteBorder4BlackCells: { title: 'White Border For Black Cells', type: 'bool' },
  480. sortWearablesByOwned: { title: 'Sort Owned Wearables', type: 'bool' },
  481. linesplitClosestSide: { title: 'Linesplit Closest Side', type: 'bool' },
  482. // friendDeclineAll: { title: 'Friend Decline All', type: 'bool' },
  483. rainbowMapBorder: { title: 'Rainbow Map Border', type: 'bool' },
  484. rainbowBorderSpeed: { title: 'Rainbow Border Speed', type: 'num' },
  485. rainbowBrHazard: { title: 'Rainbow BR Hazard', type: 'bool' },
  486. rainbowBrHazardSpeed: { title: 'Rainbow Hazard Speed', type: 'num' },
  487. extraChatCommands: { title: 'FSFB Chat Commands', type: 'bool' },
  488. chatPrefix: { title: 'Chat Command Prefix', type: 'str' },
  489. bypassConfirmChatRules: { title: 'Bypass Chat Confirm', type: 'bool' },
  490. publicSkinSearch: { title: 'Public Skin Search', type: 'bool' },
  491. extraOneFastSplitDelay: { title: 'Extra Fastsplit Delay', type: 'bool' },
  492. notifyNewUpdates: { title: 'Notify New Updates', type: 'bool' },
  493. preventAutoLowGraphics: { title: 'Disable Auto-Low Graphics', type: 'bool' },
  494. stylizeActiveSettings: { title: 'Stylize Active Settings', type: 'bool' },
  495. removeMultiFeedPopup: { title: 'Remove MultiFeed Warning', type: 'bool' },
  496. level1kFix: { title: 'Fix Level 1000 Bug', type: 'bool'},
  497. messageBanWarning: { title: 'Censor Message To Mitigate Ban', type: 'bool' },
  498. removeModMessages: { title: 'Remove Server Mod Messages', type: 'bool' },
  499. removeColorTagsInChat: { title: 'Remove Custom Name Tags In Chat', type: 'bool' },
  500. tripleFastSplitSetting: { title: 'Triple Fastsplit Setting', type: 'bool'},
  501. rainbowNameColor: { title: 'Rainbow Name Color (Client Only)', type: 'bool'},
  502. rainbowNameSpeed: { title: 'Rainbow Name Speed (Client Only)', type: 'num'}
  503. }
  504.  
  505. function updateShownSettings(){
  506. for(let keyName in expandedUserPref){
  507. const expObj = expandedUserPref[keyName];
  508.  
  509. if('menu' in expObj){
  510. remMenuCmd(expObj.menu);
  511. }
  512.  
  513. let value = userPreferences[keyName],
  514. typeIndicator = expObj.type == 'bool' ? `[ ${value ? '✅' : '❌'} ] ` : `[ "${value}" ] `;
  515.  
  516. expObj.menu = addMenuCmd(typeIndicator + expObj.title, function(e){
  517. let newVal;
  518. if(expObj.type === 'bool'){
  519. newVal = !value;
  520. userPreferences[keyName] = newVal;
  521. } else {
  522. newVal = prompt('Please input the value you want to set:', value);
  523.  
  524. if(expObj.type === 'num' && !/^[0-9]+$/.test(newVal)){
  525. updateShownSettings();
  526. return alert('Please only enter numbers');
  527. }
  528. userPreferences[keyName] = expObj.type === 'num' ? Number(newVal) : newVal;
  529. }
  530. updateShownSettings();
  531. setStorage('fsfb-user-settings', userPreferences);
  532. alert(`Setting: "${expObj.title}" value changed to: ${expObj.type === 'bool' ? `[ ${newVal ? '✅' : '❌'} ] ` : `[ "${newVal}" ] `}.\nNote that some (not all) settings require a browser reload to take full effect.`);
  533. })
  534. }
  535. addHideAll();
  536. }
  537.  
  538. function addHideAll(){
  539. let hideAllBtn = addMenuCmd('Hide all settings', function(){
  540. for(let keyName in expandedUserPref){
  541. const expObj = expandedUserPref[keyName];
  542. if('menu' in expObj){
  543. remMenuCmd(expObj.menu);
  544. }
  545. }
  546. remMenuCmd(hideAllBtn);
  547. addShowMore();
  548. });
  549. }
  550. function addShowMore(){
  551. let showMoreBtn = addMenuCmd('Show all settings', function(){
  552. remMenuCmd(showMoreBtn);
  553. updateShownSettings();
  554. })
  555. }
  556. addShowMore();
  557. }
  558.  
  559. const _slideDown = $.prototype.slideDown;
  560. $.prototype.slideDown = function () {
  561. if(this.selector === '#curser'){
  562. let content = this[0].textContent;
  563. if(content?.includes("Your FPS seems to be low")) return;
  564. if(content?.includes("Connected to server")){
  565. playerAlive = false;
  566. svSwitch = true;
  567. try{
  568. currentServerId = 0;
  569. for(let { isCurrent, id } of JSON.parse(localStorage.gameservers)){
  570. if(isCurrent) currentServerId = id;
  571. }
  572. } catch {
  573. console.warn("FSFB: Failed to grab server id from localStorage")
  574. currentServerId = parseInt($(".server-tabmenu").find(".active")[0]?.id.slice(9));
  575. }
  576. }
  577. }
  578. return _slideDown.apply(this, arguments);
  579. }
  580.  
  581. const _$text = $.prototype.text;
  582. $.prototype.text = function(){
  583. if(this.selector === '.exp-bar' && userPreferences.showXPdecimals){
  584. arguments[0] = (~~(+this[0].parentElement.style.width.slice(0, -1) * 100) / 100) + '%';
  585. }
  586. if(this.selector === '#userCoins2' && typeof arguments[0] === 'string') currentUser = arguments[0];
  587. // if(this.selector === '#megaphone_text' && typeof arguments[0] === 'string' && addChatMsg !== null){
  588. // let name = document.querySelector('#megaphone_name').textContent,
  589. // [message] = arguments,
  590. // id = unsafeWindow.md5(Math.round(Math.random()));
  591. // addChatMsg({
  592. // R: !1,
  593. // v: 0,
  594. // i: 0,
  595. // P: id,
  596. // z: id,
  597. // name,
  598. // G: "",
  599. // color: "#FF0A0A",
  600. // message,
  601. // category: 0,
  602. // goldMember: 0,
  603. // L: 0,
  604. // Y: 0,
  605. // j: 0,
  606. // q: 0,
  607. // J: 1,
  608. // time: Date.now(),
  609. // cache: null
  610. // });
  611. // }
  612. return _$text.apply(this, arguments);
  613. }
  614.  
  615. let swalUserColor = '#FF00D8',
  616. swalRoleTitle = 'Fsfb Developer',
  617. swalRoleColor = '#FF78EA';
  618.  
  619. unsafeWindow.swal = function() {
  620. if(typeof arguments[0] === 'object' && 'title' in arguments[0] && userPreferences.removeMultiFeedPopup && arguments[0].type === "error" && arguments[0].text === "Eject multiple cells (Multi Feed) is only available for users who purchased the Custom Skins Sale"){
  621. return void(curserMsg(arguments[0].text, 'red', 1e4));
  622. }
  623. if(typeof arguments[0] === 'object' && 'title' in arguments[0] && userPreferences.removeModMessages && arguments[0].title.includes("Mod Message") && arguments[0]?.customClass === "swal-title-green"){
  624. return void(curserMsg(`<b>${arguments[0].title}:</b>\n${arguments[0].text}`, 'purple', 0, true));
  625. }
  626. if (typeof arguments[0] === 'object' && 'title' in arguments[0] && /<img src="((skins\/\d+(_lo)?\.png\?(u=\d+)?)|img\/userprofile\.png)" width="\d+" height="\d+" style="border-radius:50%;"><br><br><span style=".*?">(Fishyyyy|firebonee|kidmaletteo)<\/span>/gm.test(arguments[0].title)) {
  627. arguments[0].title = arguments[0].title
  628. .replace(/(?<=<span style=").*(?=">(Fishyyyy|firebonee|kidmaletteo))/gm, 'color: ' + swalUserColor)
  629. .replace(/(?<=(?:<span style="display:block; margin:-10px 0px 15px; font-size:12px; line-height:normal;"><br>)|(?:<br><span style="padding:2px 5px; font-size:10px; background:#999; color:#000; border-radius:10px;">Hidden<\/span><br><br>))(?=<span)/gm, `<span style="color: ${swalRoleColor};">&#9734;&#9734; ${swalRoleTitle} &#9734;&#9734;</span><br>`);
  630. }
  631. return swal.apply(this, arguments);
  632. }
  633.  
  634. $('.setting-tablink').css({'width' : '30%'});
  635. $('#settingTab2').after(`<button id="settingTab4" class="setting-tablink" onclick="openSettingPage(4);" style="width: 9%; font-size: calc(0.3vw + 7.5px);"><div class="fa fa-cogs fa-lg" style="font-size: 15px; color: lightgray;"></div></button>`);
  636. $('#settingPage3').after(`<div id="settingPage4" class="setting-tabcontent"><div class="row"><div class="col-md-10 col-md-offset-1 stng" id="fsfb-settings-main" style="padding:0"><div id="fsfb-settings-left"><section id="fsfb-sect-checkbox" class="padbot10 fsfb-sect-ch"></section><section id="fsfb-sect-theme" class="fsfb-sect-ch padbot10"></section><section id="fsfb-sect-namecolor" class="fsfb-sect-ch padbot10"></section><section id="fsfb-sect-antilag" class="fsfb-sect-ch padbot10"></section></div><div id="fsfb-settings-right"><section id="fsfb-sect-hotkeys" class="padbot10"></section><section id="fsfb-sect-slowfeed" class="padbot10"></section><section id="fsfb-sect-frzvrs" class="padbot10"></section><section id="fsfb-sect-fastsplit" class="padbot10"></section><section id="fsfb-sect-quickSettings" class="padbot10"></section><section id="fsfb-sect-uiScale" class="padbot10"></section><section id="fsfb-sect-imexport" class="fsfb-sect-ch padbot10"></section><section id="fsfb-sect-translate"></section></div></div></div></div>`);
  637. $('.container').eq(0).css("max-width", "1250px");
  638. $('#fsfb-sect-checkbox').append(`<p class="hotkey-paragraph">Script Features</p>`);
  639.  
  640. // add checkbox HTML
  641. for(let i of settings.checkboxes){
  642. $('#fsfb-sect-checkbox').append(`<label><input id="${i.id}" type="checkbox"><p> ${i.title} </p></label>`);
  643. $( "#" + i.id).change(function(e) {
  644. changeSettings(this.id, $(this).is(':checked'), e);
  645. });
  646. }
  647.  
  648. // add import/export HTML
  649. $('#fsfb-sect-imexport').append(`<p class="hotkey-paragraph">Import/Export</p>`);
  650. for(let i of settings.export_import){
  651. $('#fsfb-sect-imexport').append(`<label><input id="${i.id}" type="checkbox"><p> ${i.title} </p></label>`);
  652. $( "#" + i.id).change(function() {
  653. changeSettings(this.id, $(this).is(':checked'));
  654. });
  655. }
  656. $('#fsfb-sect-imexport').append(`<div id="fsfb-ximport-cont"><div id="fsfb-export-btn" class="fsfb-eximport">Export</div><div id="fsfb-import-btn" class="fsfb-eximport">Import</div></div>`);
  657.  
  658. $('#fsfb-sect-theme').append(`<p class="hotkey-paragraph">Game Theme</p>`);
  659. for(let i of settings.theme){
  660. $('#fsfb-sect-theme').append(`<label class="fsfb-colors"><input id="${i.id}" type="checkbox"><p> ${i.title}</p><div style="background-color: black;"><input id="${i.id1}"type="color"></div></label>`);
  661. $( "#" + i.id).change(function() {
  662. changeSettings(this.id, $(this).is(':checked'));
  663. });
  664. $( "#" + i.id1).on('input', function() {
  665. changeSettings(this.id, this.value);
  666. $(this).parent().css('background-color', this.value); // bcs the regular [input="color"] looks rly shit, change color of overlayed div instead
  667. });
  668. }
  669. for(let i of settings.theme_boxes){
  670. $('#fsfb-sect-theme').append(`<label><input id="${i.id}" type="checkbox"><p> ${i.title} </p></label>`);
  671. $( "#" + i.id).change(function(e) {
  672. changeSettings(this.id, $(this).is(':checked'), e);
  673. });
  674. }
  675. // namecolor
  676. $('#fsfb-sect-namecolor').append(`<p class="hotkey-paragraph">Colored Name</p>`);
  677. for(let i of settings.name_color){
  678. if("color" in i){
  679.  
  680. $('#fsfb-sect-namecolor').append(`<label class="fsfb-colors"><input id="${i.id}" class="fsfb-ncustom" type="checkbox"><p> ${i.title}</p><div style="background-color: black;"><input id="${i.id1}"type="color"></div></label>`);
  681. $( "#" + i.id).change(function() {
  682. changeSettings(this.id, $(this).is(':checked'));
  683. });
  684. $( "#" + i.id1).on('input', function() {
  685. changeSettings(this.id, this.value);
  686. $(this).parent().css('background-color', this.value); // bcs the regular [input="color"] looks rly shit, change color of overlayed div instead
  687. });
  688. } else {
  689. $('#fsfb-sect-namecolor').append(`<label><input id="${i.id}" class="fsfb-ncustom" type="checkbox"><p> ${i.title} </p></label>`);
  690. $( "#" + i.id).change(function(e) {
  691. changeSettings(this.id, $(this).is(':checked'), e);
  692. });
  693. }
  694. }
  695.  
  696.  
  697.  
  698. // antilag
  699. $('#fsfb-sect-antilag').append(`<p class="hotkey-paragraph">Anti-Lag</p>`);
  700. for(let i of settings.anti_lag){
  701. $('#fsfb-sect-antilag').append(`<label><input id="${i.id}" type="checkbox"><p> ${i.title} </p></label>`);
  702. $( "#" + i.id).change(function(e) {
  703. changeSettings(this.id, $(this).is(':checked'), e);
  704. });
  705. }
  706.  
  707. $('#fsfb-sect-translate').append(`<p class="hotkey-paragraph">Chat Translate</p>`);
  708.  
  709. for(let i of settings.chat_translate){
  710. if(!('set' in i)){ //checkboxes
  711. $('#fsfb-sect-translate').append(`<label><input id="${i.id}" type="checkbox"><p> ${i.title} </p></label>`);
  712. $( "#" + i.id).change(function(e) {
  713. changeSettings(this.id, $(this).is(':checked'), e);
  714. });
  715. } else {
  716. $('#fsfb-sect-translate').append(`<p style="margin-top: 2px;">${i.title}</p><select id="${i.id}" class="fsfb-changelang"><option value="auto">Detect language</option><option value="af">Afrikaans</option><option value="sq">Albanian</option><option value="ar">Arabic</option><option value="hy">Armenian</option><option value="az">Aerbaijani</option><option value="eu">Basque</option><option value="be">Belarusian</option><option value="bn">Bengali</option><option value="bg">Bulgarian</option><option value="ca">Catalan</option><option value="zh-CN">Chinese (simpl)</option><option value="zh-TW">Chinese (trad)</option><option value="hr">Croatian</option><option value="cs">Czech</option><option value="da">Danish</option><option value="nl">Dutch</option><option value="en">English</option><option value="et">Estonian</option><option value="tl">Filipino</option><option value="fi">Finnish</option><option value="fr">French</option><option value="gl">Galician</option><option value="ka">Georgian</option><option value="de">German</option><option value="el">Greek</option><option value="ht">Haitian Creole</option><option value="iw">Hebrew</option><option value="hi">Hindi</option><option value="hu">Hungarian</option><option value="is">Icelandic</option><option value="id">Indonesian</option><option value="ga">Irish</option><option value="it">Italian</option><option value="ja">Japanese</option><option value="ko">Korean</option><option value="lv">Latvian</option><option value="lt">Lithuanian</option><option value="mk">Macedonian</option><option value="ms">Malay</option><option value="mt">Maltese</option><option value="no">Norwegian</option><option value="fa">Persian</option><option value="pl">Polish</option><option value="pt">Portuguese</option><option value="ro">Romanian</option><option value="ru">Russian</option><option value="sr">Serbian</option><option value="sk">Slovak</option><option value="sl">Slovenian</option><option value="es">Spanish</option><option value="sw">Swahili</option><option value="sv">Swedish</option><option value="th">Thai</option><option value="tr">Turkish</option><option value="uk">Ukrainian</option><option value="ur">Urdu</option><option value="vi">Vietnamese</option><option value="cy">Welsh</option><option value="yi">Yiddish</option></select>`);
  717. }
  718. };
  719.  
  720. $('.fsfb-changelang').on("change", function(){
  721. for(let i = 0; i < settings.chat_translate.length; i++){
  722. if(settings.chat_translate[i].id == this.id) settings.chat_translate[i].set = this.value;
  723. }
  724. saveSettings();
  725. });
  726.  
  727. $('#fsfb-sect-hotkeys').append(`<p class="hotkey-paragraph">Script Hotkeys</p>`);
  728.  
  729. const checkHotkeyClicked = (e, thing) => {
  730. if (e.target.id == thing.id && !thing.active){
  731. $('#' + thing.id).addClass('selected');
  732. thing.active = true;
  733. keysChanging = true; // prevent features from triggering when setting hotkey
  734. } else {
  735. thing.active = false;
  736. $('#' + thing.id).removeClass('selected');
  737. }
  738. }
  739. const checkNewHotkey = (e, thing) => {
  740. if (!thing.active) return;
  741. thing.key = e.keyCode;
  742. $('#' + thing.id).text(getName(e.keyCode)).removeClass('selected');
  743. thing.active = false;
  744. saveSettings();
  745. styleActiveSettings();
  746. e.preventDefault();
  747. }
  748. const checkFsHotkey = (e, thing) => {
  749. if (!thing.active) return;
  750. thing.key = e.keyCode;
  751. thing.keyName = e.key;
  752. $('#' + thing.id).text(getName(e.keyCode)).removeClass('selected');
  753. thing.active = false;
  754. saveSettings();
  755. styleActiveSettings();
  756. e.preventDefault();
  757. }
  758.  
  759. const checkPowerupClicked = e => {
  760. if(!quickBuying || !e?.originalEvent?.isTrusted || $(e.target).attr('class') == 'purchase-btn confirmation' || $(e.target).attr('class') == 'megaphone-btn') return;
  761. let id = e.target.id;
  762. if (id == 'fsfb-quickbuy-img' || id == 'fsfb-quickbuy') return void(quickBuying = true);
  763. const map = {
  764. Wall: 33,
  765. AntiFreeze: 35,
  766. AntiRecombine: 34,
  767. Shield: 38,
  768. FrozenVirus: 36,
  769. Recombine: 1,
  770. Speed: 2,
  771. Growth: 6,
  772. SpawnVirus: 7,
  773. SpawnMothercell: 8,
  774. SpawnPortal: 9,
  775. SpawnGoldOre: 10,
  776. Freeze: 5,
  777. '360Shot': 30,
  778. minion_nuker: 39,
  779. megaphone_shout: 14,
  780. freeze_yourself: 18,
  781. 'ripple-virus': 42
  782. }
  783. let pwID = map[id.replace(/^(inv|fsfb-)/gm, '')] ?? (() => {
  784. quickBuying = false;
  785. $('.inventory-box').removeClass('fsfb-shown').find('p').show();
  786. $('#fsfb-quickbuy').removeClass('activatedInv')
  787. curserMsg('Quick buy deactivated.', 'red');
  788. })();
  789. if (!quickBuying || !pwID) return;
  790. $('.confirm').attr('disabled', 'true'); // disable so user doesn't buy early - swal is slow to load text
  791. const waitUntil1 = (condition) => new Promise(resolve => {
  792. let interval = setInterval(() => {
  793.  
  794. if($('.sweet-alert h2').text() == ' Confirm ') return;
  795.  
  796. $('.confirm')[0].click();
  797. condition() && (clearInterval(interval), resolve());
  798. }, 25);
  799. setTimeout(() => { (clearInterval(interval), resolve()) }, 1e4);
  800. });
  801. setTimeout(() => {
  802. if(pwID == 14) return;
  803. $('.confirm')[0].addEventListener('click', async e => {
  804. if(!e.isTrusted || $('.confirm').text() == 'OK') return;
  805. $('.sweet-alert, .sweet-overlay').addClass('fsfb-hidden');
  806. setTimeout(async() => {
  807. await waitUntil1(() => !$('.sweet-alert').hasClass('visible'));
  808. if($('.sweet-alert').hasClass('visible')) return;
  809. await sleep(100);
  810. $('.sweet-alert, .sweet-overlay').removeClass('fsfb-hidden');
  811. }, 1e3);
  812. })
  813. }, 500);
  814. setTimeout(() => $('.confirm').removeAttr('disabled'), 600);
  815.  
  816. if(pwID == 14) $('.megaphone-btn')[0].click();
  817. else $(`.purchase-btn.confirmation[item="${pwID}"]`)[0].click();
  818.  
  819. $('.inventory-box').removeClass('fsfb-shown').find('p').show();
  820. $('#fsfb-quickbuy').removeClass('activatedInv')
  821. quickBuying = false;
  822. }
  823.  
  824.  
  825. for(let i of settings.hotkeys){
  826. $('#fsfb-sect-hotkeys').append(`<br><p>${i.title}</p><div id="${i.id}" class="fsfb-hotkey"></div>`);
  827. $('#' + i.id).on('contextmenu', e => {
  828. $('#' + i.id).text('').removeClass('selected');
  829. i.active = false;
  830. i.key = 0;
  831. saveSettings();
  832. styleActiveSettings();
  833. e.preventDefault();
  834. });
  835. }
  836.  
  837. // const typing = () => $('input, textarea').is(':focus');
  838. const typing = () => {
  839. const focused = document.querySelector(":focus");
  840. return focused === document.activeElement && ['TEXTAREA', 'INPUT'].includes(focused?.tagName) && (!document.hasFocus || document.hasFocus()) && !!(focused.type || focused.href || ~focused.tabIndex);
  841. };
  842.  
  843. const sleep = ms => new Promise(r => setTimeout(r, ms));
  844. const press = key => ['down', 'up'].forEach(i => unsafeWindow[`onkey${i}`]({ keyCode: key }));
  845.  
  846. let fsWaiting = false;
  847. const fastSplit = async(a) => { // a = true: was fast onesplit; a = false: was fast doublesplit
  848. if(fsWaiting) return;
  849. fsWaiting = true;
  850. setTimeout(() => void(fsWaiting = false), settings.fastsplit_hotkeys[a ? a === 1 ? 4 : 7 : 1].val + settings.fastsplit_hotkeys[a ? a === 1 ? 5 : 8 : 2].val);
  851. if([39, 37, 2, 4, 6].includes(currentServerId) || a || userPreferences.extraOneFastSplitDelay) await sleep(settings.fastsplit_hotkeys[a ? a === 1 ? 4 : 7 : 1].val);
  852. press(getKey("FreezeSelf"));
  853. await sleep(settings.fastsplit_hotkeys[a ? a === 1 ? 5 : 8 : 2].val);
  854. press(getKey("FreezeSelf"));
  855. }
  856.  
  857.  
  858.  
  859. let cursorLockActivated = false, holdAutoFeed = false, _onblur;
  860. const waitForBlur = () => {
  861. if(unsafeWindow.onblur != null){
  862. const oldBlur = unsafeWindow.onblur;
  863. unsafeWindow.onblur = function(){
  864. spamRec = spamSpeed = splittingbots = false;
  865. keys = {};
  866. if(!settings.checkboxes[3].active){
  867. $("#linesplit-markers div").hide();
  868. linesplitting = false;
  869. }
  870. return oldBlur.apply(this, arguments);
  871. }
  872. _onblur = unsafeWindow.onblur;
  873. } else {
  874. setTimeout(waitForBlur, 400);
  875. }
  876. };
  877. waitForBlur();
  878.  
  879. // hook for typing in chat w/ cursor lock
  880. const waitForKeyup = () => {
  881. if(unsafeWindow.onkeyup != null){
  882. const _keydown = unsafeWindow.onkeyup;
  883. unsafeWindow.onkeyup = function(){
  884. const keyCode = arguments[0]?.keyCode;
  885. if(arguments[0]?.target?.id === 'chtbox' && arguments[0]?.isTrusted && cursorLockActivated && keyCode === getKey('FixedMouse')) return;
  886. if(arguments[0]?.isTrusted && holdAutoFeed && [getKey('MacroFeed'), getKey('MultiFeed')].includes(keyCode)) return;
  887. return _keydown.apply(this, arguments);
  888. }
  889. } else {
  890. setTimeout(waitForKeyup, 400);
  891. }
  892. };
  893. waitForKeyup();
  894.  
  895. const waitForSetGraphics = () => {
  896. if(unsafeWindow.onkeyup != null){
  897. const _setGraphics = unsafeWindow.setGraphics;
  898. unsafeWindow.setGraphics = (a, b) => userPreferences.preventAutoLowGraphics && b ? $("#curser").hide() : _setGraphics(a, b);
  899. } else {
  900. setTimeout(waitForSetGraphics, 400);
  901. }
  902. };
  903. waitForSetGraphics();
  904.  
  905. const fsfbCustomBlur = function(){
  906. ['MacroSplit', ...(holdAutoFeed ? [] : ['MacroFeed', 'MultiFeed']), ...(cursorLockActivated ? [] : ['FixedMouse'])].forEach(id => unsafeWindow.onkeyup({keyCode: getKey(id)}));
  907. spamRec = spamSpeed = splittingbots = false;
  908. keys = {};
  909. if(!settings.checkboxes[3].active){
  910. $("#linesplit-markers div").hide();
  911. linesplitting = false;
  912. }
  913. }
  914.  
  915. const toggleHoldFeed = active => {
  916. holdAutoFeed = active ?? !holdAutoFeed;
  917. unsafeWindow.onblur = holdAutoFeed || cursorLockActivated ? fsfbCustomBlur : _onblur;
  918. unsafeWindow[`onkey${holdAutoFeed ? 'down' : 'up'}`]({ keyCode: getKey('MacroFeed') });
  919. }
  920.  
  921. const toggleCursorLock = active => {
  922. cursorLockActivated = active ?? !cursorLockActivated;
  923. unsafeWindow.onblur = holdAutoFeed || cursorLockActivated ? fsfbCustomBlur : _onblur;
  924. unsafeWindow[`onkey${cursorLockActivated ? 'down' : 'up'}`]({ keyCode: getKey('FixedMouse') });
  925. }
  926. unsafeWindow.fsfbCursorLock = toggleCursorLock;
  927.  
  928. const toggleSetting = index => {
  929. let el = $('#' + settings.quickSettings[index].set);
  930. if($('#fsfb-settings-main')[0].contains(el[0])) el.prop('checked', !el.prop('checked')).trigger('change');
  931. else el.unbind().click();
  932. }
  933.  
  934. Object.defineProperty(KeyboardEvent.prototype, 'keyCode', {
  935. get: function() {
  936. switch (this.key.toLowerCase()) {
  937. case settings.fastsplit_hotkeys[0]?.keyName.toLowerCase(): return getKey("Split");
  938. case settings.fastsplit_hotkeys[3]?.keyName.toLowerCase(): return getKey("DoubleSplit");
  939. case settings.fastsplit_hotkeys[6]?.keyName.toLowerCase(): return userPreferences.tripleFastSplitSetting ? getKey("TripleSplit") : this.which;
  940. default: return this.which;
  941. }
  942. }
  943. });
  944.  
  945. let slowfeeding = !1, linesplitting = !1, hiddenUI = !1, splittingbots = !1, spamRec = !1, spamSpeed = !1;
  946. const pressed = e => {
  947. const key = e.which ? e.which : e.keyCode;
  948. if(document.activeElement.type === 'textarea') e.stopImmediatePropagation();
  949. if(typing() || keysChanging || e.key == undefined || e.keyCode == undefined) return;
  950. if(key === 27 && quickBuying){ // esc pressed
  951. quickBuying = false;
  952. $('#fsfb-quickbuy').removeClass('activatedInv');
  953. curserMsg('Quick buy deactivated.', 'red');
  954. $('.inventory-box').removeClass('fsfb-shown').find('p').show();
  955. e.preventDefault();
  956. e.stopImmediatePropagation();
  957. }
  958. if(key === settings.hotkeys[0].key){ // 7 feed
  959. let i = 1;
  960. let interval = setInterval(() => {
  961. press(getKey("MacroFeed"));
  962. if(++i > 7) clearInterval(interval);
  963. }, 85);
  964. e.preventDefault();
  965. }
  966. if(key === settings.hotkeys[1].key && !settings.checkboxes[3].active){ // linesplit lock
  967. linesplitting = true;
  968. linesplit();
  969. $("#linesplit-markers div").show();
  970. e.preventDefault();
  971. }
  972. if(key === settings.hotkeys[1].key && settings.checkboxes[3].active){ // linesplit lock
  973. linesplitting = !linesplitting;
  974. if(linesplitting){
  975. $("#linesplit-markers div").show();
  976. linesplit();
  977. } else {
  978. $("#linesplit-markers div").hide();
  979. $('#canvas').trigger($.Event('mousemove', {clientX: mosX, clientY: mosY})); // return mouse to where the cursor is
  980. }
  981. e.preventDefault();
  982. }
  983. if(key === settings.hotkeys[2].key){ // macro split bots
  984. splittingbots = true;
  985. const splittingBots = () => {
  986. if(!splittingbots) return;
  987. press(getKey("SplitBots"));
  988. setTimeout(splittingBots, 50);
  989. }
  990. splittingBots();
  991. e.preventDefault();
  992. }
  993. if(key === settings.hotkeys[3].key){ // hide ui
  994. _replaceCSS('hideUI-css', (hiddenUI = !hiddenUI) ? '.hideUI{ display: none !important; }' : '');
  995. e.preventDefault();
  996. }
  997. if(key === settings.hotkeys[4].key){ // toggle cursor lock
  998. toggleCursorLock();
  999. e.preventDefault();
  1000. }
  1001. if(key === settings.hotkeys[5].key){ // check profile
  1002. const swal = $('.sweet-alert'),
  1003. swalText = swal.text();
  1004. if((swalText.includes('Level: ') || swalText.includes('The selected player is not logged in or is playing in invisible mode.')) && swalText.includes('Not valid!')) $('button.confirm').click();
  1005. if(mouseHoveringChat) $('#chtCanvas')[0].ondblclick({clientX: mosX, clientY: mosY, preventDefault: function(){}});
  1006. else {
  1007. let contextmenuShown = $('#contextMenu').css('display') == 'block';
  1008. let evt = new MouseEvent("contextmenu", {
  1009. bubbles: true,
  1010. cancelable: true,
  1011. view: unsafeWindow,
  1012. clientX: mosX,
  1013. clientY: mosY
  1014. });
  1015. document.body.dispatchEvent(evt);
  1016. if($('#contextPlayerSkin').css('background-color') == 'rgb(51, 51, 51)') curserMsg('Unable to show profile; no player was clicked on.', 'red');
  1017. if(!contextmenuShown) $('#contextMenu').hide();
  1018. $('#contextUserProfile').addClass('hover');
  1019. $('#contextMenu')[0].onclick({stopPropagation: function(){}});
  1020. }
  1021. e.preventDefault();
  1022. }
  1023. if(key === getKey("FixedMouse")){ // real cursor lock key is pressed
  1024. cursorLockActivated = false;
  1025. unsafeWindow.onblur = _onblur;
  1026. }
  1027. if(e.keyCode != 0 && e.key.toLowerCase() === settings.fastsplit_hotkeys[0]?.keyName.toLowerCase()){ // fast onesplit
  1028. fastSplit(0);
  1029. e.preventDefault();
  1030. }
  1031. if(e.keyCode != 0 && e.key.toLowerCase() === settings.fastsplit_hotkeys[3]?.keyName.toLowerCase()){ // fast doublesplit
  1032. fastSplit(1);
  1033. e.preventDefault();
  1034. }
  1035. if(e.keyCode != 0 && e.key.toLowerCase() === settings.fastsplit_hotkeys[6]?.keyName.toLowerCase() && userPreferences.tripleFastSplitSetting){ // fast triplesplit
  1036. fastSplit(2);
  1037. e.preventDefault();
  1038. }
  1039. if(key === settings.slowFeed[0].key){ // toggle feed
  1040. slowfeeding = !slowfeeding;
  1041. const feeding = () => {
  1042. if(!slowfeeding) return void(holdAutoFeed && toggleHoldFeed(false));
  1043. unsafeWindow?.uisdoa?.foprw?.() || settings.slowFeed[1].val === 0 || press(getKey("MacroFeed"));
  1044.  
  1045. settings.slowFeed[1].val === 0 ? toggleHoldFeed(slowfeeding) : setTimeout(feeding, settings.slowFeed[1].val);
  1046.  
  1047. }
  1048. feeding();
  1049. e.preventDefault();
  1050. }
  1051. if(key === settings.frozenvirus[0].key){
  1052. let fvEl = $('#invFrozenVirus'),
  1053. wasActive = fvEl.hasClass('activatedInv');
  1054. if(fvEl.css('display') === 'none') return void(curserMsg(`FSFB script can't click on the frozen virus powerup! Frozen viruses are needed before using this hotkey`, 'red'));
  1055. curserMsg();
  1056.  
  1057. wasActive || fvEl[0].onmousedown({ button: 0 });
  1058. press(getKey("MacroFeed"));
  1059. wasActive || setTimeout(() => fvEl[0].onmousedown({ button: 0 }), settings.frozenvirus[1].val);
  1060. }
  1061. if(key === settings.quickSettings[0].key){ // quick settings 1
  1062. toggleSetting(0);
  1063. e.preventDefault();
  1064. }
  1065. if(key === settings.quickSettings[1].key){ // quick settings 2
  1066. toggleSetting(1);
  1067. e.preventDefault();
  1068. }
  1069. if(key === settings.quickSettings[2].key){ // quick settings 3
  1070. toggleSetting(2);
  1071. e.preventDefault();
  1072. }
  1073. if(key === settings.quickSettings[3].key){ // quick settings 4
  1074. toggleSetting(3);
  1075. e.preventDefault();
  1076. }
  1077. if(key === settings.quickSettings[4].key){ // quick settings 5
  1078. toggleSetting(4);
  1079. e.preventDefault();
  1080. }
  1081. if(key === settings.quickSettings[5].key){ // quick settings 6
  1082. toggleSetting(5);
  1083. e.preventDefault();
  1084. }
  1085. if(!spamRec && uisdoa && settings.checkboxes[6].active && key === getKey("Recombine")){
  1086. spamRec = true;
  1087. const spammingRec = () => {
  1088. if(!spamRec) return;
  1089. // press(getKey("keyRecombine"));
  1090. if(unsafeWindow?.uisdoa?.foprc) uisdoa.foprc(1);
  1091. setTimeout(spammingRec, 10);
  1092. }
  1093. spammingRec();
  1094. e.preventDefault();
  1095. }
  1096. if(!spamSpeed && uisdoa && settings.checkboxes[6].active && key === getKey("Speed")){
  1097. spamSpeed = true;
  1098. const spammingSpeed = () => {
  1099. if(!spamSpeed) return;
  1100. // press(getKey("keySpeed"));
  1101. if(unsafeWindow?.uisdoa?.foprc) uisdoa.foprc(0);
  1102. setTimeout(spammingSpeed, 10);
  1103. }
  1104. spammingSpeed();
  1105. e.preventDefault();
  1106. }
  1107. }
  1108.  
  1109. const released = key => {
  1110. if(typing() || keysChanging) return;
  1111. if(key == settings.hotkeys[2].key) splittingbots = false; // macro split bots
  1112. if(key == settings.hotkeys[1].key && !settings.checkboxes[3].active){ // linesplit lock
  1113. linesplitting = false;
  1114. $('#canvas').trigger($.Event('mousemove', {clientX: mosX, clientY: mosY})); // return mouse to where the cursor is
  1115. $("#linesplit-markers div").hide();
  1116. }
  1117. if(spamRec && key === getKey("Recombine")) spamRec = false;
  1118. if(spamSpeed && key === getKey("Speed")) spamSpeed = false;
  1119. }
  1120.  
  1121.  
  1122. const slowfeedhotkey = settings.slowFeed[0];
  1123. // add slowfeed HTML
  1124. $('#fsfb-sect-slowfeed').append(`<p class="hotkey-paragraph">Auto-Feed</p>`)
  1125. .append(`<br><p>${slowfeedhotkey.title}</p><div id="${slowfeedhotkey.id}" class="fsfb-hotkey"></div>`)
  1126. .append(`<br><p>${settings.slowFeed[1].title}</p><input id="${settings.slowFeed[1].id}" class="fsfb-hotkey" onkeypress="return onlyNumberKey(event)" maxlength="3"></input>`);
  1127.  
  1128. $('#' + slowfeedhotkey.id).on('contextmenu', e => {
  1129. $('#' + slowfeedhotkey.id).text('').removeClass('selected');
  1130. slowfeedhotkey.active = false;
  1131. slowfeedhotkey.key = 0;
  1132. saveSettings();
  1133. styleActiveSettings();
  1134. e.preventDefault();
  1135. });
  1136.  
  1137. document.getElementById(settings.slowFeed[1].id).addEventListener("keypress", function(e){
  1138. setTimeout(() => { // goes too fast or smth
  1139. settings.slowFeed[1].val = +$('#' + settings.slowFeed[1].id).val();
  1140. saveSettings();
  1141. }, 5);
  1142. });
  1143.  
  1144. // add fastsplit HTML
  1145. $('#fsfb-sect-fastsplit').append(`<p class="hotkey-paragraph">Fast-Split</p>`);
  1146. // for(let i of settings.fastsplit_hotkeys){
  1147. for(let j = 0; j < settings.fastsplit_hotkeys.length; j++){
  1148. let i = settings.fastsplit_hotkeys[j];
  1149. $('#fsfb-sect-fastsplit').append('val' in i ? `<br><p>${i.title}</p><input id="${i.id}" class="fsfb-hotkey" onkeypress="return onlyNumberKey(event)" maxlength="3"></input>` : `<br><p>${i.title}</p><div id="${i.id}" class="fsfb-hotkey"></div>`);
  1150. if('val' in i){
  1151. document.getElementById(i.id).addEventListener("keypress", function(e){
  1152. setTimeout(() => { // goes too fast or smth
  1153. settings.fastsplit_hotkeys[j].val = +$('#' + i.id).val();
  1154. if($('#' + i.id).val() == "") settings.fastsplit_hotkeys[j].val = 0;
  1155. saveSettings();
  1156. }, 5);
  1157. });
  1158. } else {
  1159. $('#' + i.id).on('contextmenu', e => {
  1160. $('#' + i.id).text('').removeClass('selected');
  1161. i.active = false;
  1162. i.key = 0;
  1163. i.keyName = '';
  1164. saveSettings();
  1165. styleActiveSettings();
  1166. e.preventDefault();
  1167. });
  1168. }
  1169. }
  1170. $('#fsfb-sect-frzvrs').append(`<p class="hotkey-paragraph">Frozen-Virus</p>`)
  1171. .append(`<br><p>${settings.frozenvirus[0].title}</p><div id="${settings.frozenvirus[0].id}" class="fsfb-hotkey"></div>`)
  1172. .append(`<br><p>${settings.frozenvirus[1].title}</p><input id="${settings.frozenvirus[1].id}" class="fsfb-hotkey" onkeypress="return onlyNumberKey(event)" maxlength="3"></input>`);
  1173.  
  1174. $('#' + settings.frozenvirus[0].id).on('contextmenu', e => {
  1175. $('#' + settings.frozenvirus[0].id).text('').removeClass('selected');
  1176. settings.frozenvirus[0].active = false;
  1177. settings.frozenvirus[0].key = 0;
  1178. saveSettings();
  1179. styleActiveSettings();
  1180. e.preventDefault();
  1181. });
  1182.  
  1183. document.getElementById(settings.frozenvirus[1].id).addEventListener("keypress", function(e){
  1184. setTimeout(() => { // goes too fast or smth
  1185. settings.frozenvirus[1].val = +$('#' + settings.frozenvirus[1].id).val();
  1186. saveSettings();
  1187. }, 5);
  1188. });
  1189.  
  1190.  
  1191. // add quick settings HTML
  1192. $('#fsfb-sect-quickSettings').append(`<p class="hotkey-paragraph">Quick Settings</p>`);
  1193.  
  1194. for(let i of settings.quickSettings){
  1195. $('#fsfb-sect-quickSettings').append(`<select id="${i.id1}" class="fsfb-quickchange"><option value="cDark">Dark Theme</option><option value="cFancyGrid">Fancy Grid</option><option value="cSectionGrid">Section Grid</option><option value="cGrid">Gridlines</option><option value="cSkins">Skins</option><option value="cWearables">Wearables</option><option value="cNames">Show Names</option><option value="cMinionNames">Minion Names</option><option value="cLargeNames">Large Names</option><option value="cNameOutlines">Name Outline</option><option value="cMass">Show Mass</option><option value="cFood">Show Food</option><option value="cFoodHalf">Half Food</option><option value="cCellAnimations">Cell Anim</option><option value="cSkinAnimations">Skin Anim</option><option value="cMapBorder">Map Border</option><option value="cCustomBack">Custom BG</option><option value="aCustomBack">Sounds</option><option value="cZoom">Infinite Zoom</option><option value="cFixedZoom">Fixed Zoom</option><option value="cSlowMotion">Slow-Motion</option><option value="cMinionUi">Minion Panel</option><option value="cLeaderboard">Leaderboard</option><option value="cChat">Chat</option><option value="cChatSize">Chat Large</option><option value="cMinimap">Minimap</option><option value="cFPS">FPS/Ping</option><option value="cColors">Cell Colors</option><option value="cCellBorders">Cell Borders</option><option value="cCellSpikes">Cell Spikes</option><option value="cClassicViruses">Classic Virus</option><option value="cPolygonShapes">Polygon Cells</option><option value="cLineShapes">Line Cells</option><option value="cBubbleCells">Bubble Cells</option><option value="cVisibilityStatus">Prof Visiblity</option><option value="cAllowPartyInvite">Party Inv</option><option value="cAllowPartyAnimations">Party Anim</option><option value="cIconDRank">Dono Icon</option><option value="cGoldCrownChat">Gold Icon</option><option value="fsfb-revcell">Rev Order</option><option value="fsfb-portalstop">Portals Top</option><option value="fsfb-hideminions">Hide Minions</option><option value="fsfb-nominionskins">No Bot Skins</option><option value="fsfb-hideejected">Hide All Ej.</option><option value="fsfb-hidestaticej">Hide Static Ej.</option><option value="fsfb-nodeathanim">No Death Anim</option><option value="fsfb-hideshouts">Hide Shouts</option><option value="fsfb-tranchat">Chat Trans</option><option value="fsfb-nc-public">PubNameCol</option></select><div id="${i.id}" class="fsfb-hotkey"></div>`);
  1196. $('#' + i.id).on('contextmenu', e => {
  1197. $('#' + i.id).text('').removeClass('selected');
  1198. i.active = false;
  1199. i.key = 0;
  1200. saveSettings();
  1201. styleActiveSettings();
  1202. e.preventDefault();
  1203. });
  1204. };
  1205.  
  1206. $('.fsfb-quickchange').on("change", function(){
  1207. settings.quickSettings[+this.id.replace('fsfb-quick-select', '') - 1].set = this.value;
  1208. saveSettings();
  1209. });
  1210.  
  1211. // add UI scaling
  1212. $('#fsfb-sect-uiScale').append(`<p class="hotkey-paragraph">Game Scaling</p>`);
  1213. for(let i of settings.uiScaling){
  1214. $('#fsfb-sect-uiScale').append(`<div class="fsfb-slider"><p>${i.title}</p><input id="${i.id}" class="fsfb-slider" type="range" ${i.id == "fsfb-foodSize" ? `min="0.5" max="1.5" value="1" step="0.1"`: `min="1" max="9" value="5"`}></input></div>`);
  1215. // $('#fsfb-sect-uiScale').append(`<div class="fsfb-slider"><p>${i.title}</p><input id="${i.id}" class="fsfb-slider" type="range" ${i.id == "fsfb-foodSize" ? `min="0.5" max="1.5" value="1" step="0.1"`: `min="1" max="9" value="5"`}></input></div>`);
  1216. $( "#" + i.id).on('input', function() {
  1217. changeSettings(this.id, $(this).val());
  1218. });
  1219. };
  1220.  
  1221.  
  1222. let quickBuying = false;
  1223. ['megaphone_shout', 'minion_nuker', 'freeze_yourself', 'ripple-virus'].forEach(elId => $('#invCloak').after(`<div class="inventory-box" id="fsfb-${elId}" style="display: none;"></div>`));
  1224. $(settings.checkboxes[10] ? '#fsfb-megaphone_shout' : '#inv360Shot').after(`<div class="inventory-box" id="fsfb-quickbuy" style="display: none;"></div>`);
  1225. $('#fsfb-quickbuy').on('click', function(){
  1226. quickBuying = !quickBuying;
  1227. if (quickBuying){
  1228. $(this).addClass('activatedInv');
  1229. curserMsg('Quick buy activated, click the powerup you would like to buy.', 'green');
  1230. $('.inventory-box').addClass('fsfb-shown').find('p').hide();
  1231. $('#invCloak').removeClass('fsfb-shown');
  1232. $('#fsfb-quickbuy').removeClass('fsfb-shown');
  1233. } else {
  1234. $(this).removeClass('activatedInv');
  1235. curserMsg('Quick buy deactivated.', 'red');
  1236. $('.inventory-box').removeClass('fsfb-shown').find('p').show();
  1237. }
  1238. });
  1239.  
  1240.  
  1241.  
  1242. const styleActiveSettings = () => {
  1243.  
  1244. // css selector :has() isn't fully supported at the moment, so gotta use jquery for the time being :(
  1245.  
  1246. // #fsfb-settings-main p:has(+.fsfb-hotkey:not(:empty)) {
  1247. // color:#df901c;
  1248. // }
  1249. // #fsfb-settings-main .fsfb-hotkey:not(:empty) ~ p:has(+input.fsfb-hotkey):not(div.fsfb-hotkey:empty + * + p):not(div.fsfb-hotkey:empty + * + p + * + * + p) {
  1250. // color: #df901c;
  1251. // }
  1252.  
  1253. if(!userPreferences.stylizeActiveSettings) return;
  1254. $('#fsfb-settings-main p:has(+div.fsfb-hotkey), #fsfb-settings-main select:has(+div.fsfb-hotkey)').each(function(){
  1255. $(this)[$(this).is(':has(+.fsfb-hotkey:empty)') ? 'removeClass' : 'addClass']('fsfb-active-setting');
  1256. })
  1257. $('#fsfb-settings-main .fsfb-hotkey~ p:has(+input.fsfb-hotkey)').each(function(){
  1258. $(this)[$(this).is('div.fsfb-hotkey:empty + * + p') || $(this).is('div.fsfb-hotkey:empty + * + p + * + * + p') ? 'removeClass' : 'addClass']('fsfb-active-setting');
  1259. });
  1260. $('input[type="range"].fsfb-slider').each(function(){
  1261. $(this).prev()[this.value == this.getAttribute('value') ? 'removeClass': 'addClass']('fsfb-active-setting');
  1262. })
  1263. }
  1264.  
  1265. // add lag detection settings to things
  1266. let customCells = false;
  1267.  
  1268. $("#fsfb-sect-theme>label>input").addClass('fsfb-ncustom');
  1269. $('#fsfb-powsoverlay, #fsfb-mtchmass').addClass('fsfb-ncustom');
  1270. $('#fsfb-check-Hazard, #fsfb-check-border').removeClass('fsfb-ncustom');
  1271. $("#fsfb-revcell, #fsfb-portalstop, #fsfb-bublecell").removeClass('fsfb-ncustom');
  1272. $('#fsfb-foodSize').prev().addClass('fsfb-lag');
  1273.  
  1274. let antilagCells = false;
  1275.  
  1276. let fillCells = false;
  1277. $('#fsfb-bublecell, #fsfb-showmass, #fsfb-spikedcells, #fsfb-mtchmass, #fsfb-powsoverlay, #fsfb-anticloak, #fsfb-portalmass, #fsfb-nc-public').addClass('fsfb-lag');
  1278.  
  1279. $('#fsfb-powsoverlay, #fsfb-bublecell, #fsfb-anticloak').addClass('fsfb-nfill');
  1280.  
  1281. let onlyCells = false;
  1282.  
  1283. let strokeCells = false;
  1284. $('#fsfb-bublecell, #fsfb-powsoverlay').addClass('fsfb-nstroke');
  1285.  
  1286. let foodSizeOn = false;
  1287.  
  1288. // let drawCells = false;
  1289. // $('#fsfb-powsoverlay, #fsfb-portalmass').addClass('fsfb-ndraw');
  1290. let customCellsChanged = false;
  1291.  
  1292. let translateChanged = false, pwOverlayChanged = false;
  1293. const changeSettings = (ID, active, e) => { // a = active, e = event (optional)
  1294. for(let i of settings.uiScaling) if(i.id == ID) i.level = active;
  1295. for(let i of settings.checkboxes) if(i.id == ID) i.active = active;
  1296. for(let i of settings.export_import) if(i.id == ID) i.active = active;
  1297. for(let i of settings.theme_boxes) if(i.id == ID) i.active = active;
  1298. for(let i of settings.anti_lag) if(i.id == ID) i.active = active;
  1299. for(let i of settings.chat_translate){
  1300. if(i.id == ID){
  1301. if(ID == "fsfb-tranchat" && (typeof GM_xmlhttpRequest != 'function') && e?.originalEvent?.isTrusted){
  1302. curserMsg('Fsfb script is unable to access the GM_xmlhttpRequest function. Chat translate won\'t work without this. This is often caused by not using the tampermonkey extension (or not the latest version).', 'red', 1e4);
  1303. $('#' + ID).prop('checked', false);
  1304. return;
  1305. }
  1306. translateChanged = true;
  1307. i.active = active;
  1308. }
  1309. }
  1310. for(let i of settings.theme){
  1311. if(i.id == ID) i.active = active;
  1312. if(i.id1 == ID) i.color = active;
  1313. }
  1314. for(let i of settings.name_color){
  1315. if(i.id == ID) i.active = active;
  1316. if(i.id1 == ID) i.color = active;
  1317. }
  1318.  
  1319. if(ID == "fsfb-hideshouts") $('#megaholder')[`${active ? 'add' : 'remove'}Class`]('hideMegaphone');
  1320. if(ID == "fsfb-qBuy") $('#fsfb-quickbuy')[active ? 'show' : 'hide'](); //.css('display', a ? 'flex' : 'hide');
  1321. if(ID == "fsfb-pwsonerow"){
  1322. $('#fsfb-quickbuy').detach().appendTo(`#inventory${active ? 2 : 1}`);
  1323. [1, 2].forEach((i) => $("#inventory" + i).addClass("fsfb-inventories").css("order", active ? i : -i));
  1324. _replaceCSS("css-invsingleline", active ? `#inventory{ display: flex; position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%); } .fsfb-inventories { position: initial !important; transform: initial !important; }` : '');
  1325. }
  1326.  
  1327.  
  1328. let maxlen = $('#fsfb-nc-public').is(':checked') ? ($('#fsfb-box-ncs').is(':checked') ? 16 : 19) : 24;
  1329. $('#nick').attr('maxlength', maxlen);
  1330. if(ID == "fsfb-nc-public"){
  1331. if(!active) pubNameSwitch = true;
  1332. setTimeout(() => (pubNameSwitch = false), 25); // def nonoptimal, 2 lazy 2 fix
  1333. }
  1334.  
  1335. // client side colored name
  1336. if(["fsfb-box-nc", "fsfb-box-ncs", "fsfb-nc-color", "fsfb-nc-stroke", "fsfb-nc-public"].includes(ID) && nameColors?.set){
  1337. if(settings.name_color[0].active || ID === "fsfb-nc-public"){
  1338. if(active && ID === "fsfb-nc-public" && !settings.name_color[1].active){
  1339.  
  1340. nameColors.set(defaultColorsAmnt, "#FFFFFF");
  1341. nameStrokes.set(defaultColorsAmnt, "#000000");
  1342. } else {
  1343. nameColors.set(defaultColorsAmnt, settings.name_color[1].color);
  1344. nameStrokes.set(defaultColorsAmnt, settings.name_color[2].active ? settings.name_color[2].color : contrastColor(settings.name_color[1].color));
  1345. }
  1346. // warnings
  1347. if(playerIsAlive()){
  1348. if(ID == "fsfb-nc-public" && !active){
  1349. curserMsg("Respawn to deactivate FSFB public custom name.", "red", 4e3, false);
  1350. } else {
  1351. curserMsg(`Respawn to update your name color!\nNote: FSFB Public Colored Name is <b>ONLY</b> visible to other FSFB script users!`, 'orange', 8e3, true);
  1352. }
  1353. } else if(maxlen < 24 && ID == "fsfb-nc-public") {
  1354. curserMsg(`FSFB script's public custom name feature encodes the color in your clan tag; therefore, clan tags won't work with this feature enabled. The max nick length with the current settings is <b><u>${maxlen}</u></b>${settings.name_color[2].active ? `, deactivate Name Stroke to increase this to 19.` : '.'}\nPlease note: FSFB Public Colored Name is <b>ONLY</b> visible to other FSFB script users!`, "purple", 20e3, true);
  1355. }
  1356. } else {
  1357. if((ID === "fsfb-nc-color" && !active) || !settings.name_color[1].active){
  1358. nameColors.set(defaultColorsAmnt, "#FFFFFF");
  1359. nameStrokes.set(defaultColorsAmnt, "#000000"); // again won't revert bc lazy
  1360. } else {
  1361. nameColors.set(defaultColorsAmnt, settings.name_color[1].color);
  1362. nameStrokes.set(defaultColorsAmnt, settings.name_color[2].active ? settings.name_color[2].color : contrastColor(settings.name_color[1].color));
  1363. }
  1364. }
  1365. }
  1366.  
  1367. if(ID == "fsfb-bublecell" && $("#cBubbleCells").is(":checked") != active && e?.originalEvent?.isTrusted) $('#cBubbleCells').unbind().click();
  1368. if(ID == "fsfb-showmass" && $("#cMass").is(":checked") != active && e?.originalEvent?.isTrusted) $('#cMass').unbind().click();
  1369.  
  1370. if((ID == "fsfb-myskins" || ID == "fsfb-partyskins") && !$("#cSkins").is(":checked") && active) $('#cSkins').unbind().click();
  1371. if((ID == "fsfb-mynick" || ID == "fsfb-partynicks") && !$("#cNames").is(":checked") && active) $('#cNames').unbind().click();
  1372.  
  1373. if(ID == "fsfb-myskins" && active) $('#fsfb-partyskins').prop('checked', false).trigger('change');
  1374. if(ID == "fsfb-partyskins" && active) $('#fsfb-myskins').prop('checked', false).trigger('change');
  1375.  
  1376. if(ID == "fsfb-mynick" && active) $('#fsfb-partynicks').prop('checked', false).trigger('change');
  1377. if(ID == "fsfb-partynicks" && active) $('#fsfb-mynick').prop('checked', false).trigger('change');
  1378.  
  1379. if(ID == "fsfb-hideejected" && active) $('#fsfb-hidestaticej').prop('checked', false).trigger('change');
  1380. if(ID == "fsfb-hidestaticej" && active) $('#fsfb-hideejected').prop('checked', false).trigger('change');
  1381.  
  1382. if(ID == "fsfb-box-nc" && !active) $('#fsfb-box-ncs').prop('checked', false).trigger('change');
  1383.  
  1384.  
  1385. if(ID == "fsfb-powsoverlay") svSwitch = true;
  1386.  
  1387. let zoomLvl = "100%";
  1388. let map = {
  1389. 1: 50,
  1390. 2: 70,
  1391. 3: 80,
  1392. 4: 90,
  1393. 5: 100,
  1394. 6: 110,
  1395. 7: 125,
  1396. 8: 150,
  1397. 9: 200
  1398. }
  1399. if(ID == "fsfb-invSize") $('#inventory').css('zoom', (map[+active] ?? 100)+ '%');
  1400. if(ID == "fsfb-statsSize") $('#stats-container').css('zoom', (map[+active] ?? 100) + '%');
  1401.  
  1402.  
  1403. let prevCustomCells = customCells;
  1404.  
  1405. // lag settings
  1406. customCells = $(".fsfb-ncustom, #fsfb-nc-public").is(":checked") || $('#fsfb-foodSize').val() != '1'; // || userPreferences.whiteBorder4BlackCells;
  1407. fillCells = $('.fsfb-nfill').is(':checked');
  1408. strokeCells = $('.fsfb-nstroke').is(':checked');
  1409. onlyCells = $('#fsfb-myskins, #fsfb-partyskins, #fsfb-mynick, #fsfb-partynicks').is(':checked') || ($('#fsfb-box-nc').is(':checked') && !$('#fsfb-nc-public').is(':checked')) || userPreferences.rainbowNameColor;
  1410. antilagCells = $("#fsfb-sect-antilag>label>input").not('#fsfb-nodeathanim').is(':checked');
  1411. foodSizeOn = $('#fsfb-foodSize').val() != '1';
  1412.  
  1413. if(prevCustomCells != customCells && e?.originalEvent?.isTrusted) customCellsChanged = true;
  1414. // if(customCellsChanged && e?.originalEvent?.isTrusted) setTimeout(() => (customCellsChanged = false), 25);
  1415. if(customCellsChanged && e?.originalEvent?.isTrusted) setTimeout(() => (customCellsChanged = false), 25);
  1416.  
  1417. styleActiveSettings();
  1418. saveSettings();
  1419. }
  1420.  
  1421. // add event listeners
  1422. let mosX, mosY,
  1423. keys = {},
  1424. keysChanging = false,
  1425. mouseHoveringChat = false;
  1426.  
  1427.  
  1428. $(document).on('click', e => {
  1429. if(e.target.id.includes('fsfb')){
  1430. for(let i = 0; i < settings.hotkeys.length; i++) checkHotkeyClicked(e, settings.hotkeys[i]);
  1431. for(let i = 0; i < settings.fastsplit_hotkeys.length; i++) settings.fastsplit_hotkeys[i].val == null && checkHotkeyClicked(e, settings.fastsplit_hotkeys[i]);
  1432. for(let i = 0; i < settings.quickSettings.length; i++) checkHotkeyClicked(e, settings.quickSettings[i]);
  1433. checkHotkeyClicked(e, settings.slowFeed[0]); // slow feed
  1434. checkHotkeyClicked(e, settings.frozenvirus[0]);
  1435. }
  1436. checkPowerupClicked(e);
  1437. })
  1438. .on('mousemove', e => {
  1439. if(e.originalEvent == null || !e.originalEvent.isTrusted) return;
  1440. mouseHoveringChat = e.target.id == 'chtCanvas';
  1441. ({clientX: mosX, clientY: mosY} = e);
  1442. if (linesplitting) linesplit();
  1443. })
  1444.  
  1445. .on("keydown", e => {
  1446. // if(e.originalEvent == null || !e.originalEvent.isTrusted) return;
  1447. if(keysChanging){
  1448. for(let i = 0; i < settings.hotkeys.length; i++) checkNewHotkey(e, settings.hotkeys[i]);
  1449. for(let i = 0; i < settings.fastsplit_hotkeys.length; i++) checkFsHotkey(e, settings.fastsplit_hotkeys[i]);
  1450. for(let i = 0; i < settings.quickSettings.length; i++) checkNewHotkey(e, settings.quickSettings[i]);
  1451. checkNewHotkey(e, settings.slowFeed[0]); // slow feed
  1452. checkNewHotkey(e, settings.frozenvirus[0]);
  1453. }
  1454. if (!(e.keyCode in keys)){
  1455. keys[e.keyCode] = !0;
  1456. pressed(e);
  1457. }
  1458. keysChanging = false;
  1459. })
  1460. .on("keyup", e => {
  1461. if(e.originalEvent == null || !e.originalEvent.isTrusted) return;
  1462. delete keys[e.keyCode];
  1463. released(e.keyCode);
  1464. if(cursorLockActivated && e.keyCode == getKey("FixedMouse")){
  1465. e.stopImmediatePropagation();
  1466. e.preventDefault();
  1467. }
  1468. });
  1469.  
  1470. let factsArr = typeof facts_list == 'undefined' ? null : facts_list.replace(/^\n|\n$/gm, '').split(/\n/gm);
  1471. const randomFact = index => factsArr && (factsArr[index] ?? factsArr[~~(Math.random() * factsArr.length)]);
  1472.  
  1473.  
  1474. const hashCode = (str, shift) => {
  1475. let hash = 0;
  1476. for (let i = 0; i < str.length; i++) hash = (hash << shift) - hash + str.charCodeAt(i), hash |= 0;
  1477. return str.length == 0 ? 0 : hash;
  1478. };
  1479.  
  1480. const RNG = (min, max) => Math.random() * (max - min) + min;
  1481.  
  1482. // chat cmds
  1483. if(userPreferences.extraChatCommands){
  1484. const $chtbox = $('#chtbox');
  1485. $chtbox.on('keydown', e => {
  1486. if(e.keyCode != 13) return;
  1487.  
  1488. if(userPreferences.messageBanWarning && /a\s*g\s*a\s*r\s*p\s*o\s*w\s*e\s*r/gmi.test($chtbox.val())){
  1489. curserMsg("FSFB WARNING: FSFB script has censored your message as it has detected that your message may've contained a word/phrase that agma.io gives a 24 hour IP ban for. This FSFB feature can be disabled in the tampermonkey script settings.", 'red', 1e4);
  1490. $chtbox.val($chtbox.val().replace(/a\s*g\s*a\s*r\s*p\s*o\s*w\s*e\s*r/gmi, match => '*'.repeat(match.length)));
  1491. }
  1492.  
  1493. let newMsg = '', cmdVerif, customCmd = false, firstMatch = $chtbox.val().match(new RegExp(`(?<=((^|(^\/party +)|(^\/pm +\\S+ ))${escapeRegExp(userPreferences.chatPrefix)}))\\S+(\\s+\\S+)*(?=($|\\s+))`, 'gmi'));
  1494. if(firstMatch == null) return;
  1495. let[command, ...params] = firstMatch[0].split(/\s+/g);
  1496. const originalMsg = $chtbox.val().replace(new RegExp(`(?<=((^|(^\/party +)|(^\/pm +\\S+ ))))${escapeRegExp(userPreferences.chatPrefix)}${escapeRegExp(firstMatch[0])}(?=($|\\s+))`, 'gmi'), ''),
  1497. isolatedMsg = firstMatch[0].replace(new RegExp(command + '\\s', 'gi'), '');
  1498. coinsInfo();
  1499. xpInfo();
  1500.  
  1501. /* ~~~ example of external chat cmds (can be used by other scripts) ~~~ */
  1502. /*
  1503. externalChatCmds = [
  1504. {
  1505. commands: ['test1', 'test2', 'test3'],
  1506. callback: (command, isolatedMsg, params) => {
  1507. let newMsg = '';
  1508. return newMsg;
  1509. }
  1510. },
  1511. {
  1512. commands: ['eg1', 'eg2'],
  1513. callback: (cmd, isoMsg, params) => {
  1514. console.log(cmd, isoMsg, params);
  1515. alert('bru')
  1516. return '';
  1517. }
  1518. }
  1519. ]
  1520. */
  1521.  
  1522. let { externalChatCmds } = unsafeWindow;
  1523. if(externalChatCmds?.length){
  1524. for(let i of externalChatCmds){
  1525. if(i.commands.includes(command.toLowerCase())){
  1526. customCmd = true;
  1527. newMsg = i.callback(command.toLowerCase(), isolatedMsg, params);
  1528. }
  1529. }
  1530. }
  1531.  
  1532.  
  1533. if(!customCmd && (cmdVerif ??= true)){
  1534. switch(command.toLowerCase()){
  1535. case 'help':
  1536. $('#fsfb-extra-info')[0].click();
  1537. setTimeout(() => $('.fsfb-modal-body').scrollTop(1850), 200);
  1538. newMsg = '';
  1539. break;
  1540. case 'bots': case 'bot': case 'min': case 'mins': case 'minion': case 'minions': {
  1541. let minInfo = misc_settings.bots?.[currentUser], minsAmt, minsTimeRem;
  1542. $('#infoContent').children().each(function(){
  1543. if($(this).text().includes('Minion Time:')) minsTimeRem = $(this).find('span').text();
  1544. if($(this).text().includes('Minions:')) minsAmt = $(this).find('span').text();
  1545. });
  1546. if((minsChatAmt[currentUser] != null && minsChatAmt[currentUser]?.amt && !minsChatAmt[currentUser]?.started) && (minInfo == null || (minInfo && Date.now() > minInfo.currMs + minInfo.rem))){ /* || (minInfo && Date.now() > minInfo.currMs + minInfo.rem) */
  1547. newMsg = `Minion Pack Unstarted: ${minsChatAmt[currentUser].amt}`;
  1548. } else if(minsChatAmt[currentUser] != null && minsChatAmt[currentUser]?.started && minsChatAmt[currentUser]?.amt && minInfo == null ){
  1549. newMsg = `Minion Pack Activated: ${minsChatAmt[currentUser].amt}`;
  1550. } else if(!(minsAmt == '0' && minsTimeRem == '00:00:00') && minsChatAmt[currentUser] != null && minsChatAmt[currentUser].amt && minInfo != null && (minInfo.active || minsChatAmt[currentUser].started) && minInfo.rem - (Date.now() - minInfo.currMs) > 0){
  1551. newMsg = `Minion Pack Activated: ${minsChatAmt[currentUser].amt}, with ${msToTime(minInfo.rem - (Date.now() - minInfo.currMs))} remaining`;
  1552. } else if(!(minsAmt == '0' && minsTimeRem == '00:00:00') && minsAmt != null && minsTimeRem != null){
  1553. let timeArr = minsTimeRem.split(':'), msBotsTime = (3.6e6 * +timeArr[0]) + (6e4 * +timeArr[1]) + (1e3 * +timeArr[2]);
  1554. newMsg = `Minion Pack Activated: ${minsAmt}, with ${msToTime(msBotsTime)} remaining`;
  1555. } else {
  1556. newMsg = `Minion Pack Activated: none`;
  1557. }
  1558. break;
  1559. }
  1560. case 'pws': case 'pw': case 'powers': case 'power': case 'inv': case 'inventory': case 'pows': case 'powerups': {
  1561. curserMsg(`It's recommended to use ${userPreferences.chatPrefix + command}1, ${userPreferences.chatPrefix + command}2, and ${userPreferences.chatPrefix + command}3 instead, so your chat messages aren't cut-off by the chat maxlength`, 'red', 8e3);
  1562. updatePwCount();
  1563. newMsg = 'Inv: ';
  1564. for (let i = 0; i < 6; i++) {
  1565. newMsg = 'Inv: ';
  1566. for (let pw in pws) {
  1567. const check = index => i < index ? ' ' : '';
  1568. if (pws[pw] != '') newMsg += `${pws[pw]}${check(1)}${(i > 2 ? pw.slice(0, 6 - i) : pw)},${check(2)}`;
  1569. }
  1570. newMsg = newMsg.replace(/,[^,]*$/g, '');
  1571. if (newMsg.length <= 100) i = 6;
  1572. }
  1573. if (newMsg == 'Inv: ') newMsg = 'Inv: no powers';
  1574. break;
  1575. }
  1576. case 'totalpws': case 'totalpw': case 'totalpowers': case 'totalpower': case 'total': case 'totpw': case 'totalpows': case 'totalpowerups':
  1577. newMsg = `Total Powerups: ${$('.inventory-box>p').toArray().map(x => +x.innerText).reduce((a, b) => a + b).toLocaleString('en-US')}`
  1578. break;
  1579. case 'xplevel': case 'levelxp': case 'lvlxp': case 'xpcompleted': case 'xp':
  1580. newMsg = `XP Completed: ${currentPercent ? String(Math.round(currentPercent * currentLevel * 1e3, 1)).replace(/\B(?=(\d{3})+(?!\d))/g, ",") + "/" + (currentLevel * 1e3).toLocaleString('en-US') : "0/0"}`
  1581. break;
  1582. case 'level': case 'levels': case 'lvls': case 'lvl': case 'lvlcompleted': case 'lvlscompleted':
  1583. newMsg = `Level ${currentLevel}, with ${round(currentPercent * 100, 3)}% completed`
  1584. break;
  1585. case 'coin': case 'coins':
  1586. newMsg = `Coins: ${String(currentCoins).replace(/\B(?=(\d{3})+(?!\d))/g, ",")}`
  1587. break;
  1588. case 'hours': case 'hrs': case 'hour': case 'hr': case 'timeplayed':
  1589. newMsg = (isLogged() ? $('.timePlayed>span').text().replace(/\B(?=(\d{3})+(?!\d))/g, ",") : 'Time Played: 0, not logged in');
  1590. break;
  1591. case 'rank': case 'lvlrank':
  1592. newMsg = `My Rank: ${isLogged() ? $('.ranking.text-left>span').text().match(/(?<=^Your rank: )\d+$/gm)?.[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",") : '∞, not logged in'}`;
  1593. break;
  1594. case 'ping': case 'delay': case 'ms':
  1595. newMsg = `My Ping: ${$('#ping').text().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}`
  1596. break;
  1597. case 'fps': case 'frames':
  1598. newMsg = `My FPS: ${$('#fps').text().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}`
  1599. break;
  1600. case 'topmass': case 'highscore': case 'highmass': case 'highestmass':
  1601. newMsg = `My Top Mass: ${$('#topMass').text()}`
  1602. break;
  1603. case 'cells': case 'cellcount': case 'cell':
  1604. newMsg = `My Cell Count: ${$('#cellsAmount').text()}`
  1605. break;
  1606. case 'pw1': case 'pws1': case 'power1': case 'powers1': case 'inv1': case 'inventory1':
  1607. newMsg = getPowerMessage(1);
  1608. break;
  1609. case 'pw2': case 'pws2': case 'power2': case 'powers2': case 'inv2': case 'inventory2':
  1610. newMsg = getPowerMessage(2);
  1611. break;
  1612. case 'pw3': case 'pws3': case 'power3': case 'powers3': case 'inv3': case 'inventory3':
  1613. newMsg = getPowerMessage(3);
  1614. break;
  1615. case 'friends': case 'friend': case 'friendsonline': case 'friendonline':
  1616. newMsg = `Friends Online: ${$('#friendsLoggedInAmt').text() + $('#friendsTotalAmt').text()}`;
  1617. break;
  1618. case 'request': case 'requests': case 'friendrequest': case 'friendrequests': case 'friendreq': case 'req':
  1619. newMsg = `Friend Requests: ${$('#friendsRequestsAmt').text() === '' ? 'none' : $('#friendsRequestsAmt').text()}`;
  1620. break;
  1621. case 'gold': case 'goldmem': case 'goldmember': case 'golddays': case 'gm': {
  1622. const obj = accGoldMem[currentUser];
  1623. if(obj?.has == null){
  1624. newMsg = `Days of Goldmember Remaining: none`;
  1625. break;
  1626. }
  1627. newMsg = `Days Of Goldmember Remaining: ${obj.has || obj.days != null ? (obj.days + (obj.days == 1 ? ' Day' : ' Days')) : 'none'}`;
  1628. break;
  1629. }
  1630. case 'alive': case 'alivetime': case 'timealive':
  1631. newMsg = `Time Alive: ${playerIsAlive() ? msToTime(Date.now() - timeAlive) : 'not alive'}`;
  1632. break;
  1633. case 'mass': case 'currentmass':
  1634. newMsg = `Current Mass: ${playerIsAlive() ? currentMass.toLocaleString('en-US') : 'none, not alive'}`;
  1635. break;
  1636. case 'user': case 'username': case 'usr': case 'account': case 'acc':
  1637. newMsg = `My Username: ${currentUser == "Please Login First" ? "logged out" : currentUser}`
  1638. break;
  1639. case 'custom': case 'customs': case 'customskins': case 'totalcustoms':
  1640. if($('#publicSkinsPage').children().length == 0){
  1641. curserMsg(`Please load your custom skins before using this command`, 'red', 6e3);
  1642. newMsg = '';
  1643. break;
  1644. }
  1645. newMsg = `My Total Custom Skins: ${$('[id^="skinCustomImg"').length}, worth ${($('[id^="skinCustomImg"').length * 1e6).toLocaleString('en-US')}`
  1646. break;
  1647. case 'skins': case 'boughtskins': case 'ownedskins': case 'totalskins': {
  1648. if($('#skinsBuy [id^="skinContainer"]').length == 0){
  1649. curserMsg(`Please load your owned skins from the agma.io skin store`, 'red', 6e3);
  1650. newMsg = '';
  1651. break;
  1652. }
  1653. let ownedSkinsArr = [], edSkins = 0, totalValue = 0;
  1654. $('#skinsBuy [id^="skinUseBtn"]').each(function(){
  1655. ownedSkinsArr.push(+$(this)[0].id.match(/\d+$/gm)[0]);
  1656. })
  1657. for(let i of skinsArr){
  1658. if(ownedSkinsArr.includes(i.id)){
  1659. i.price > 2e6 ? ++edSkins : totalValue += i.price;
  1660. }
  1661. }
  1662. newMsg = `My Total Bought Skins: ${$('#skinsBuy [id^="skinUseBtn"').length}, worth ${totalValue.toLocaleString('en-US')} coins (${edSkins} lim. ed.)`;
  1663. break;
  1664. }
  1665. case 'ownedwearables': case 'wearables': case 'wears': case 'totalwearables': case 'totalwears': {
  1666. if(!$('#fsfb-wearsloaded').length){
  1667. curserMsg(`Please load your wearables before using this command`, 'red', 6e3);
  1668. newMsg = ''; // aft
  1669. break;
  1670. }
  1671. let wearsPrice = [0], edSkins = 0;
  1672. $('[id^="wearableUseBtn"]').each(function(){
  1673. if ($(this).parents().eq(0).siblings('p').text() == '(Limited Edition)') edSkins++;
  1674. wearsPrice.push(+$(this).parents().eq(0).siblings('span.win-price').text().replace(/,/g, ''));
  1675. });
  1676. newMsg = `My Total Wearables: ${$('[id^="wearableUseBtn"]').length}, worth ${sigma(wearsPrice).toLocaleString('en-US')} coins (${edSkins} lim. ed.)`;
  1677. break;
  1678. }
  1679. case 'cloak': case 'invis': case 'invisibility': {
  1680. let status, time;
  1681. $('#infoContent>p').each(function(){
  1682. if($(this).text().includes('Cloaked: ')) status = $(this).text().match(/(?<=Cloaked: ).+/gm);
  1683. if($(this).text().includes('Cloak Time: ')) time = $(this).text().match(/(?<=Cloak Time: ).+/gm);
  1684. })
  1685. newMsg = status == null || time == null ? `Cloak: inactive` : `Cloak ${status}, with ${time} remaining`;
  1686. break;
  1687. }
  1688. case 'addfriend': case 'add':
  1689. if(params?.length == 0){
  1690. curserMsg(`Please add a username after the command, such as: ${userPreferences.chatPrefix}${command} Fishyyy`, 'red', 6e3);
  1691. newMsg = '';
  1692. break;
  1693. }
  1694. unsafeWindow.friendAdd(params[0]);
  1695. break;
  1696. case 'partymembers': case 'partymember': case 'party':
  1697. newMsg = $('#partyContent').children().length - 1 > 0 ? `In a party, with ${$('#partyContent').children().length - 1} members` : `Party members: not in a party`;
  1698. break;
  1699. case 'players': case 'ply': case 'plyrs': case 'serverplayers': case 'totalplayers':{
  1700. let plyr_max = [0, 0]; // players[0] | maxplayers[1]
  1701. $('[id^="serverPlayers"]').each(function(){
  1702. plyr_max = plyr_max.map((n, i) => n + +this.innerText.split('/')[i]);
  1703. });
  1704. let serverBots = getServerValue('bots') ?? 0, totalbots = 0;
  1705. for(let server in svInfo){
  1706. totalbots += (svInfo[server].bots ?? 0);
  1707. }
  1708. newMsg = `Server Players: ${$('[id^="serverRow"].active>[id^="serverPlayers"]').text()}${serverBots ? ` (${serverBots} bots)` : ''}, Total Players: ${plyr_max[0].toLocaleString('en-US') + '/' + plyr_max[1].toLocaleString('en-US')} ${totalbots ? `(${totalbots} bots)` : ''}`;
  1709. break;
  1710. }
  1711. case 'server':
  1712. newMsg = `Currently playing in ${$('[id^="serverRow"].active>*').first().text()}`;
  1713. break;
  1714. case 'abil': case 'abils': case 'ability': case 'abilities': { // not finished
  1715. let arr = [], newStr = '';
  1716. $('.checkmark').each(function(){
  1717. if($(this).css('display') == 'block') arr.push($(this).siblings().eq(1).attr('item'));
  1718. })
  1719. if(misc_settings.abil?.[currentUser] != null || arr.length){
  1720. const abil = misc_settings.abil?.[currentUser],
  1721. map = {
  1722. 18: 'Freeze',
  1723. 22: 'Invis Cloak',
  1724. 20: '2x Spawn',
  1725. 23: '2x Exp'
  1726. }
  1727. if(currentUser == "Please Login First"){
  1728. newMsg = `Active Abilities: none`;
  1729. break;
  1730. }
  1731. for(let i of arr) newStr += map[i] + (abil?.[i] != null && 8.64e7 - (Date.now() - abil[i]) > 0 ? (' with ' + msToTime(8.64e7 - (Date.now() - abil[i])) + ' left, ') : ', ');
  1732. newMsg = `Active Abilities: ${newStr == '' ? 'none' : newStr}`;
  1733. newMsg = newMsg.replace(/,[^,]*$/g, '');
  1734. } else {
  1735. newMsg = `Active Abilities: none`;
  1736. }
  1737. break;
  1738. }
  1739. case 'xpproj': case 'xpprojected': case 'projectedxp': case 'projxp': case 'levelprojected': case 'lvlproj': case 'lvlprojected': {
  1740. const projectedHr = lastHrXP.length > 0 ? sigma(getProperty(lastHrXP.slice(-5), "gained")) * 12 : 0;
  1741. newMsg = `Next Hour Projected XP: ${xpStatsInPercentages ? round(convertToPerc(projectedHr, currentLevel) * 100, 2) + '%' : round(projectedHr).toLocaleString('en-US')}`;
  1742. break;
  1743. }
  1744. case 'projcoins': case 'projcoin': case 'projectedcoin': case 'projectedcoins': case 'coinsproj': case 'coinproj': case 'coinprojected': case 'coinsprojected': {
  1745. const projectedHr = lastHrCoins.length > 5 ? Math.round(sigma(getProperty(lastHrCoins.slice(-5), "gained")) * 12) : 0;
  1746. newMsg = `Next Hour Projected Coins: ${projectedHr.toLocaleString('en-US')}`;
  1747. break;
  1748. }
  1749. case 'xpremaining': case 'xprem': case 'remainingxp': case 'remxp': {
  1750. const xpRemaining = currentLevel ? currentLevel * 1e3 - currentPercent * currentLevel * 1e3 : 0,
  1751. newMsg = `XP Remanining: ${xpStatsInPercentages ? round(convertToPerc(xpRemaining, currentLevel) * 100, 2) + '%' : round(xpRemaining).toLocaleString('en-US')}`;
  1752. break;
  1753. }
  1754. case 'coinsremaining': case 'coinsrem': case 'remainingcoins': case 'remcoins': {
  1755. const coinsRemaining = currentCoins ? 25e4 - currentCoins % 25e4 : 0;
  1756. newMsg = `Coins Remanining: ${coinsRemaining.toLocaleString('en-US')}`;
  1757. break;
  1758. }
  1759. case 'xplasthour': case 'lasthourxp': case 'hrxp': case 'xphr': case 'hourxp': case 'xphour': {
  1760. const lastHr = lastHrXP.length > 0 ? sigma(getProperty(lastHrXP, "gained")) : 0;
  1761. newMsg = `XP Last Hour: ${xpStatsInPercentages ? round(convertToPerc(lastHr, currentLevel) * 100, 2) + '%' : round(lastHr).toLocaleString('en-US')}`;
  1762. break;
  1763. }
  1764. case 'coinslasthour': case 'lasthourcoins': case 'hrcoins': case 'coinshr': case 'hourcoins': case 'coinshour': {
  1765. const lastHr = lastHrCoins.length > 0 ? Math.round(sigma(getProperty(lastHrCoins, "gained"))) : 0
  1766. newMsg = `Coins Last Hour: ${lastHr.toLocaleString('en-US')}`;
  1767. break;
  1768. }
  1769. case 'xplastmin': case 'xplastminute': case 'lastminxp': case 'lastminutexp': case 'minxp': case 'minutexp': case 'xpmin': {
  1770. const lastMin = lastMinXP.length > 0 ? sigma(getProperty(lastMinXP, "gained")) : 0;
  1771. newMsg = `XP Last Minute: ${xpStatsInPercentages ? round(convertToPerc(lastMin, currentLevel) * 100, 2) + '%' : round(lastMin).toLocaleString('en-US')}`;
  1772. break;
  1773. }
  1774. case 'coinslastmin': case 'coinslastminute': case 'lastmincoins': case 'lastminutecoins': case 'coinsxp': case 'minutecoins': case 'coinsmin': {
  1775. const lastMin = lastMinCoins.length > 0 ? Math.round(sigma(getProperty(lastMinCoins, "gained"))) : 0;
  1776. newMsg = `Coins Last Minute: ${lastMin.toLocaleString('en-US')}`;
  1777. break;
  1778. }
  1779. case 'xplast12s': case 'xplast12sec': case 'xplast12seconds': case 'last12secondsxp': case 'lastminutexp': case 'xp12s': case '12sxp': case 'xp12sec': {
  1780. const last12sec = lastMinXP.length > 0 ? lastMinXP[lastMinXP.length - 1].gained : 0;
  1781. newMsg = `XP Last 12 Seconds: ${xpStatsInPercentages ? round(convertToPerc(last12sec, currentLevel) * 100, 2) + '%' : round(last12sec).toLocaleString('en-US')}`;
  1782. break;
  1783. }
  1784. case 'xpsession': case 'sessionxp': case 'xpsesh': case 'sesh': case 'seshxp': case 'online': {
  1785. const sessionXP = currentXP && accounts[currentUser] ? currentXP - accounts[currentUser].xp : 0;
  1786. newMsg = `Session XP: ${xpStatsInPercentages ? round(currentLevel && accounts[currentUser] ? ((round(currentPercent, 3) + currentLevel) - accounts[currentUser].lvl) * 100 : 0, 2) + '%' : round(sessionXP).toLocaleString('en-US')}, Session Length: ${msToTime(Date.now() - scriptStartXP)}`;
  1787. break;
  1788. }
  1789. case 'lifetimexp': case 'xplifetime':
  1790. newMsg = `Lifetime XP: ${round(currentXP ?? 0).toLocaleString('en-US')}`;
  1791. break;
  1792. case 'coinssession': case 'sessioncoins': case 'coinssesh': case 'seshcoins': {
  1793. const sessionCoins = currentCoins && accounts[currentUser] ? Math.round(currentCoins - accounts[currentUser].coins): 0;
  1794. newMsg = `Session Coins: ${sessionCoins.toLocaleString('en-US')}, Session Length: ${msToTime(Date.now() - scriptStartCoins)}`;
  1795. break;
  1796. }
  1797. case 'ratewaifu': case 'waifu': case 'waifurating': case 'waifurate': case 'howwaifu':
  1798. cmdVerif = false;
  1799. if(params?.length == 0){
  1800. if(currentUser == "Please Login First"){
  1801. newMsg = `My Waifu Rating: 0 / 10`;
  1802. break;
  1803. }
  1804. newMsg = `My Waifu Rating: ${Math.round(+String(Math.round(hashCode(currentUser, 5) * 102.2)).slice(-3, -1) / 10)} / 10`;
  1805. break;
  1806. }
  1807. newMsg = `${params[0]}'s Waifu Rating: ${Math.round(+String(Math.round(hashCode(params[0], 5) * 102.2)).slice(-3, -1) / 10)} / 10`;
  1808. break;
  1809. case 'ratepro': case 'pro': case 'prorating': case 'prorate': case 'howpro':
  1810. cmdVerif = false;
  1811. if(params?.length == 0){
  1812. if(currentUser == "Please Login First"){
  1813. newMsg = `I am 0% pro`;
  1814. break;
  1815. }
  1816. newMsg = `I am ${Math.round(+String(Math.round(hashCode(currentUser, 5) * 194.3)).slice(-4, -1) / 10)}% pro`;
  1817. break;
  1818. }
  1819. newMsg = `${params[0]} is ${Math.round(+String(Math.round(hashCode(params[0], 5) * 194.3)).slice(-4, -1) / 10)}% pro`;
  1820. break;
  1821. case 'ratedog': case 'dog': case 'dograting': case 'dograte': case 'howdog':
  1822. cmdVerif = false;
  1823. if(params?.length == 0){
  1824. if(currentUser == "Please Login First"){
  1825. newMsg = `I am 0% dog`;
  1826. break;
  1827. }
  1828. newMsg = `I am ${Math.round(+String(Math.round(hashCode(currentUser, 6) * 189.3)).slice(-4, -1) / 10)}% dog`;
  1829. break;
  1830. }
  1831. newMsg = `${params[0]} is ${Math.round(+String(Math.round(hashCode(params[0], 6) * 189.3)).slice(-4, -1) / 10)}% dog`;
  1832. break;
  1833. case 'rateking': case 'king': case 'kingrating': case 'kingrate': case 'howking':
  1834. cmdVerif = false;
  1835. if(params?.length == 0){
  1836. if(currentUser == "Please Login First"){
  1837. newMsg = `I am 0% king`;
  1838. break;
  1839. }
  1840. newMsg = `I am ${Math.round(+String(Math.round(hashCode(currentUser, 5) * 389.3)).slice(-4, -1) / 10)}% king`;
  1841. break;
  1842. }
  1843. newMsg = `${params[0]} is ${Math.round(+String(Math.round(hashCode(params[0], 5) * 389.3)).slice(-4, -1) / 10)}% king`;
  1844. break;
  1845. case 'dice': case 'die': case 'roll': case 'rolldice': {
  1846. const sides = params?.length == 0 || isNaN(+params[0]) ? 6 : +params[0];
  1847. newMsg = `Rolled a dice with ${sides.toLocaleString('en-US')} sides, landed on ${Math.round(RNG(1, sides)).toLocaleString('en-US')}`;
  1848. break;
  1849. }
  1850. case 'rng': case 'random': case 'randomnumber': case 'number': case 'num': {
  1851. const min = params?.length < 1 || isNaN(+params[0]) ? 0 : +params[0];
  1852. const max = params?.length < 2 || isNaN(+params[1]) ? min + 10 : +params[1];
  1853. if(min > max){
  1854. curserMsg(`Please make sure your minimum (${min}) is less than your maximum (${max})`, 'red', 5e3);
  1855. newMsg = '';
  1856. break;
  1857. }
  1858. newMsg = `Generated a random number between ${min.toLocaleString('en-US')} and ${max.toLocaleString('en-US')}, chose: ${Math.round(RNG(min, max)).toLocaleString('en-US')}`;
  1859. break;
  1860. }
  1861. case 'ratefriends': case 'friendsrating': case 'friendsrate': case 'howfriends':
  1862. cmdVerif = false;
  1863. if(params?.length == 0){
  1864. if(currentUser == "Please Login First"){
  1865. newMsg = `I am 0% friends with a frog`;
  1866. break;
  1867. }
  1868. newMsg = `I am ${Math.round(+String(Math.round(hashCode(currentUser, 4) * 283.7)).slice(-4, -1) / 10)}% friends with a frog`;
  1869. break;
  1870. }
  1871. if(params?.length == 1){
  1872. if(currentUser == "Please Login First"){
  1873. newMsg = `I am 0% friends with a ${params[0]}`;
  1874. break;
  1875. }
  1876. newMsg = `I am ${Math.round(+String(Math.round(hashCode(currentUser, 4) * 283.7) + Math.round((hashCode(params[0], 5) * 405.2))).slice(-4, -1) / 10)}% friends with a ${params[0]}`;
  1877. break;
  1878. } else {
  1879. newMsg = `${params[0]} is ${Math.round(+String(Math.round(hashCode(params[0], 4) * 283.7) + Math.round((hashCode(params[0], 5) * 405.2))).slice(-4, -1) / 10)}% friends with ${params[1]}`;
  1880. break;
  1881. }
  1882. case 'rateenemies': case 'enemiesrating': case 'enemiesrate': case 'howenemies': case 'enemies':
  1883. cmdVerif = false;
  1884. if(params?.length == 0){
  1885. if(currentUser == "Please Login First"){
  1886. newMsg = `I am 0% enemies with a frog`;
  1887. break;
  1888. }
  1889. newMsg = `I am ${Math.round(+String(Math.round(hashCode(currentUser, 4) * 164.45)).slice(-5, -2) / 10)}% enemies with a frog`;
  1890. break;
  1891. }
  1892. if(params?.length == 1){
  1893. if(currentUser == "Please Login First"){
  1894. newMsg = `I am 0% enemies with a ${params[0]}`;
  1895. break;
  1896. }
  1897. newMsg = `I am ${Math.round(+String(Math.round(hashCode(currentUser, 4) * 164.45) + Math.round((hashCode(params[0], 5) * 405.2))).slice(-5, -2) / 10)}% enemies with a ${params[0]}`;
  1898. break;
  1899. } else {
  1900. newMsg = `${params[0]} is ${Math.round(+String(Math.round(hashCode(params[0], 4) * 164.45) + Math.round((hashCode(params[0], 5) * 405.2))).slice(-5, -2) / 10)}% enemies with ${params[1]}`;
  1901. break;
  1902. }
  1903. case 'flip': case 'coinflip': case 'heads': case 'tails': case 'flipcoin': {
  1904. newMsg = `Coin flipped! Landed on ${Math.round(RNG(0, 1)) ? 'heads' : 'tails'}`;
  1905. break;
  1906. }
  1907. case 'script': case 'version': case 'fsfb': case 'v':
  1908. newMsg = `Using fsfb script! Version ${version}`
  1909. break;
  1910. case 'time': case 'localtime': case 'localetime': case 'date':
  1911. newMsg = `My Time: ${new Date().toLocaleString()}`
  1912. break;
  1913. case 'leaderboard': case 'leader': case 'lb':
  1914. newMsg = `My leaderboard position: ${!playerIsAlive() || leaderboardPos == null ? 'none, not alive' : leaderboardPos}`;
  1915. break;
  1916. case 'altcaps': case 'altcap': case 'altscaps': case 'altscap':
  1917. newMsg = isolatedMsg.toLowerCase().split('').map((v, i) => i % 2 == 0 ? v : v.toUpperCase()).join('');
  1918. cmdVerif = false;
  1919. break;
  1920. case 'sparkles': case 'sprk':
  1921. newMsg = '✨' + isolatedMsg + '✨';
  1922. cmdVerif = false;
  1923. break;
  1924. case 'cfix': case 'canvasfix': {
  1925. document.querySelectorAll('canvas').forEach(canvas => ({ innerWidth: canvas.width, innerHeight: canvas.height } = unsafeWindow));
  1926. // const canvas = document.querySelector('#canvas');
  1927. // ({ innerWidth: canvas.width, innerHeight: canvas.height } = unsafeWindow);
  1928. curserMsg('Canvas was reset.', 'green', 5e3);
  1929. newMsg = '';
  1930. break;
  1931. }
  1932. case 'solo': case 'soloserver': // message from Miracle Scripts (another great agma script) - https://greasyfork.org/scripts/391142
  1933. newMsg = ':warning: SOLO SERVER :warning: No teaming!! No hay equipo!! Pas d\'équipe!! Kein Teaming!! لا فريق';
  1934. cmdVerif = false;
  1935. break;
  1936. case 'facts': case 'fact': case 'funfact': {
  1937. const fact = randomFact();
  1938. newMsg = fact ? randomFact() : '';
  1939. fact ?? curserMsg(`Fsfb is unable to access the list of facts. Possible cause: not using tampermonkey or not using the latest version of tampermonkey.`, 'red', 6e3);
  1940. break;
  1941. }
  1942. case 'fastsplit': case 'fs': case 'fastsplits': case 'fastsplitdelay': case 'delay': {
  1943. const fs = settings.fastsplit_hotkeys;
  1944. newMsg = `My fast onesplit delays: ${fs[1].val}, ${fs[2].val}; fast double: ${fs[4].val}, ${fs[5].val}; fast triple: ${fs[7].val}, ${fs[8].val}`;
  1945. break;
  1946. }
  1947. case "dailyprogress": case "dailychallenge": case "progress": case "challengeprogress": case "challenge": case "challenges": {
  1948. let progress = +$("#challengeProgress").text();
  1949. let goal = +$("#challengeGoal").text();
  1950. let percent = ((progress / goal) * 100).toFixed(1);
  1951. newMsg = `Daily Challenge Progress: ${progress.toLocaleString('en-US')} / ${goal.toLocaleString('en-US')} (${percent}% completed)`;
  1952. break;
  1953. }
  1954. case "sp": case "sorapoint": case "sorapoints": case "sps": {
  1955. let soraPoints = +$('.sora-points-inv.chall-mythic').text();
  1956. newMsg = `Sora Points: ${soraPoints.toLocaleString('en-US')}`;
  1957. break;
  1958. }
  1959. case "keys": case "key": case "challengekeys": case "challengekey": {
  1960. let challengeKeys = +$('.mystery-keys.chall-mythic').text();
  1961. newMsg = `Challenge Keys: ${challengeKeys.toLocaleString('en-US')}`;
  1962. break;
  1963. }
  1964. case "stars": case "challengestars": case "challengestar": case "star": {
  1965. let challengeStars = +$('.challenge-stars.chall-mythic').text();
  1966. newMsg = `Challenge Stars: ${challengeStars.toLocaleString('en-US')}`;
  1967. break;
  1968. }
  1969. case "lastshout": case "lshout":
  1970. $chtbox.blur();
  1971. if(shouts.length == 0){
  1972. swal({
  1973. title: "No shouts detected.",
  1974. type: "error"
  1975. });
  1976. } else {
  1977. let shout = shouts[shouts.length-1];
  1978. let wasRemoved = false;
  1979. if(shout.isModerator == true && shouts.length >= 2){
  1980. shout = shout[shouts.length-2];
  1981. wasRemoved = true;
  1982. }
  1983.  
  1984. swal({
  1985. title: "Last shout info:",
  1986. text: `
  1987. Nickname: ${shout.name} \n
  1988. Message: ${shout.message} \n
  1989. Translated: ${shout.messageTranslated} \n
  1990. Time: ${(new Date(shout.time)).toString()} \n
  1991. Was Removed: ${wasRemoved ? "Yes" : "No"}
  1992. `,
  1993. type: "info"
  1994. });
  1995. newMsg = "";
  1996.  
  1997. }
  1998. $chtbox.blur();
  1999. break;
  2000. case "allshouts": case "dumpshouts": {
  2001. $chtbox.blur();
  2002. console.log("Collected shouts:");
  2003. for(let shout of shouts){
  2004. console.log(`
  2005. Nickname: ${shout.name}
  2006. Message: ${shout.message}
  2007. Translated: ${shout.messageTranslated}
  2008. Time: ${(new Date(shout.time)).toString()}
  2009.  
  2010. `)
  2011. newMsg = "";
  2012. }
  2013. console.log("Total: ", shouts.length , "shouts");
  2014. swal({
  2015. title: "Dumped " + shouts.length + " shouts into console.",
  2016. type: "info"
  2017. });
  2018. break;
  2019. }
  2020. default:
  2021. newMsg = $chtbox.val();
  2022. return;
  2023. }
  2024. }
  2025. // (unsafeWindow.kfjsdafl != null) ? $chtbox.val(newMsg) : $chtbox.val(''), console.log(newMsg);;
  2026. $chtbox.val(newMsg == '' ? '' : originalMsg + (newMsg?.[cmdVerif ? 'replace' : '']?.(/[youaie](?!.: )/gmi, m => cmap[m]) || newMsg));
  2027. })
  2028. }
  2029.  
  2030. // check if player is alive
  2031. let playerAlive = false, timeAlive;
  2032. const playerIsAlive = () => playerAlive && $('#advert').css('display') != 'none' ? false : playerAlive;
  2033. unsafeWindow.playerIsAlive = playerIsAlive;
  2034.  
  2035.  
  2036. const _setNick = unsafeWindow.setNick;
  2037. unsafeWindow.setNick = function(){
  2038. if(userPreferences.messageBanWarning && /a\s*g\s*a\s*r\s*p\s*o\s*w\s*e\s*r/gmi.test(arguments[0])){
  2039. curserMsg("FSFB WARNING: FSFB script has censored your message as it has detected that your nickname may've contained a word/phrase that agma.io gives a 24 hour IP ban for. This FSFB feature can be disabled in the tampermonkey script settings.", 'red', 1e4);
  2040. const newNick = (arguments[0].replace(/a\s*g\s*a\s*r\s*p\s*o\s*w\s*e\s*r/gmi, match => '*'.repeat(match.length)));
  2041. arguments[0] = newNick;
  2042. document.getElementById('nick').value = newNick;
  2043. }
  2044. if(settings.name_color[0].active && settings.name_color[1].active && arguments[0] != '' && (!/^\[(?:\W{3}|\W{6})\]/gmi.test(arguments[0]) || arguments[0] === document.querySelector('#nick')?.value)){ // check if name already has color tag
  2045. const tag = `[${encodeCustomNameColor(settings.name_color[1].color)}${settings.name_color[2].active ? encodeCustomNameColor(settings.name_color[2].color) : ''}]`;
  2046. arguments[0] = tag + arguments[0];
  2047. }
  2048.  
  2049. if(arguments[1] || !playerAlive) timeAlive = Date.now(); // respawned
  2050. playerAlive = true;
  2051. setTimeout(() => { svSwitch = true }, 1000);
  2052. return _setNick.apply(this, arguments);
  2053. }
  2054.  
  2055. const _closeAdvert = unsafeWindow.closeAdvert
  2056. unsafeWindow.closeAdvert = function(){
  2057. playerAlive = false;
  2058. return _closeAdvert.apply(this, arguments);
  2059. }
  2060.  
  2061. const getPowerMessage = line => {
  2062. let obj = {};
  2063. [1, 2, 3].forEach(n => (obj[`string${n}`] = `Inv (${n}/?): `));
  2064. updatePwCount();
  2065. const newPws = {
  2066. Recombine: pws.rec,
  2067. Speed: pws.spd,
  2068. Growth: pws.grw,
  2069. Virus: pws.vrs,
  2070. Mothercell: pws.mtcl,
  2071. Portal: pws.prtl,
  2072. 'Gold Block': pws.gblk,
  2073. Freeze: pws.fz,
  2074. Push: pws.psh,
  2075. Wall: pws.wall,
  2076. 'Anti-Freeze': pws.afz,
  2077. 'Anti-Recombine': pws.arc,
  2078. Shield: pws.shld,
  2079. 'Frozen Virus': pws.fvs
  2080. }
  2081. for(let i in newPws){
  2082. let add = newPws[i] == '' ? '' : `${newPws[i]} ${i}, `;
  2083. if(obj.string1.length + add.length <= 100) obj.string1 += add;
  2084. else if(obj.string2.length + add.length <= 100) obj.string2 += add;
  2085. else obj.string3 += add;
  2086. }
  2087. if(obj.string1 == `Inv (1/?): ` && line == 1) return 'Inv (1/1): no powers';
  2088. if(obj['string' + line] == `Inv (${line}/?): `){
  2089. curserMsg(`This inventory line doesn't exist! Try a smaller number`, 'red', 6e3);
  2090. return '';
  2091. }
  2092. let totalLines = 1;
  2093. if(obj.string3 == 'Inv (3/?): ' && obj.string2 != 'Inv (2/?): ') totalLines = 2;
  2094. else if(obj.string3 != 'Inv (3/?): ' && obj.string2 != 'Inv (2/?): ') totalLines = 3;
  2095. return obj['string' + line].replace(/,[^,]*$/g, '').replace(/\?/g, totalLines);
  2096. }
  2097.  
  2098. let pws = {rec: '', spd: '', grw: '', vrs: '', mtcl: '', prtl: '', gblk: '', fz: '', psh: '', wall: '', afz: '', arc: '', shld: '', fvs: ''};
  2099. const updatePwCount = () => {
  2100. $('.inventory-box').each(function(){
  2101. const map = {
  2102. Wall : 'wall',
  2103. AntiFreeze: 'afz',
  2104. AntiRecombine: 'arc',
  2105. Shield: 'shld',
  2106. FrozenVirus: 'fvs',
  2107. Recombine: 'rec',
  2108. Speed: 'spd',
  2109. Growth: 'grw',
  2110. SpawnVirus: 'vrs',
  2111. SpawnMothercell: 'mtcl',
  2112. SpawnPortal: 'prtl',
  2113. SpawnGoldOre: 'gblk',
  2114. Freeze: 'fz',
  2115. '360Shot': 'psh'
  2116. }
  2117. if(map[$(this)[0]?.id.slice(3)] != null) pws[map[$(this)[0].id.slice(3)]] = $(this).css('display') != 'none' ? $(this).children().eq(0).text() || '1' : '';
  2118. })
  2119. }
  2120.  
  2121. $('#fsfb-export-btn').on('click', () => {
  2122. if(!$('#fsfb-sect-imexport>label>input').is(':checked')) return void(curserMsg('You need to select at least one setting to export!', 'red'));
  2123. if($('#fsfb-custom-bg').is(':checked')) curserMsg('Exporting settings with a custom background is likely to increase the file size', 'red', 8e3);
  2124. let script_settings = {},
  2125. script_themes = {};
  2126. for (let i in settings) { // put the settings & themes into different objects
  2127. if (i == "theme" || i == "theme_boxes" || i == "name_color") script_themes[i] = settings[i];
  2128. else if (i != "export_import") script_settings[i] = settings[i];
  2129. }
  2130. let bgImg = null;
  2131. const downloadFile = () => {
  2132. let obj = {
  2133. selected: {
  2134. game_settings: $('#fsfb-game-settings').is(':checked'),
  2135. game_controls: $('#fsfb-game-controls').is(':checked'),
  2136. game_background: $('#fsfb-custom-bg').is(':checked'),
  2137. script_settings: $('#fsfb-script-settings').is(':checked'),
  2138. script_theme: $('#fsfb-theme-settings').is(':checked')
  2139. },
  2140. game_settings: localStorage.settings,
  2141. game_controls: localStorage.hotkeys,
  2142. game_background: bgImg,
  2143. script_settings: script_settings,
  2144. script_theme: script_themes
  2145. }
  2146. // if the setting is turned off, then dont need to export it - set it to null
  2147. for(let i in obj){
  2148. if(i != 'selected' && !obj.selected[i]) obj[i] = null;
  2149. }
  2150. const a = document.createElement('a'),
  2151. file = new Blob([JSON.stringify(obj)], {type: "text/plain"});
  2152. a.href = URL.createObjectURL(file);
  2153. a.download = "fsfb script settings";
  2154. a.click();
  2155. URL.revokeObjectURL(a.href); // download a txt file of exported settings
  2156. }
  2157. if($('#fsfb-custom-bg').is(':checked')){
  2158. let db, req = unsafeWindow.indexedDB.open("AgmaDB", 1);
  2159. req.onsuccess = function (x) {
  2160. db = req.result;
  2161. db.onclose = (c) => { db = null; }
  2162. db.onversionchange = (c) => { db.close(), db = null; }
  2163. let _ = db.transaction("general", "readonly").objectStore("general").get("cbgDataURL");
  2164. _.onsuccess = () => {
  2165. bgImg = _.result;
  2166. downloadFile();
  2167. }
  2168. }, req.onupgradeneeded = function (c) {
  2169. let req = c.target.result;
  2170. if (!req.objectStoreNames.contains("general")) {
  2171. req.createObjectStore("general");
  2172. downloadFile();
  2173. } else downloadFile();
  2174. };
  2175. } else {
  2176. downloadFile();
  2177. }
  2178. });
  2179.  
  2180. $('#fsfb-import-btn').on('click', () => {
  2181. if(!$('#fsfb-sect-imexport>label>input').is(':checked')) return void(curserMsg('You need to select at least one setting to import!', 'red'));
  2182. if($('#fsfb-custom-bg').is(':checked')) curserMsg('Pasting in settings that include a background image is likely to cause initial lag', 'red', 0);
  2183. swal({
  2184. title: "Import Settings",
  2185. text: "Add your exported settings below and press OK to continue.",
  2186. type: "input",
  2187. showCancelButton: true,
  2188. closeOnConfirm: false,
  2189. animation: "slide-from-top",
  2190. inputPlaceholder: "Paste exported settings here"
  2191. },
  2192. function(inputVal){
  2193. if (inputVal == null) return false;
  2194. if (inputVal == "") {
  2195. swal.showInputError("Please don't leave the input empty!");
  2196. return false
  2197. }
  2198. try {
  2199. let val = JSON.parse(inputVal);
  2200. if(val.selected.script_settings && $('#fsfb-script-settings').is(':checked')){
  2201. for (let i in val.script_settings) {
  2202. for (let j in val.script_settings[i]) {
  2203. for(let x in settings){
  2204. for(let y in settings[x]){
  2205. if(val.script_settings[i][j].id == settings[x][y].id) settings[x][y] = val.script_settings[i][j];
  2206. }
  2207. }
  2208. }
  2209. }
  2210. }
  2211. if(val.selected.script_theme && $('#fsfb-theme-settings').is(':checked')){
  2212. for (let i in val.script_theme) {
  2213. for (let j in val.script_theme[i]) {
  2214. for(let x in settings){
  2215. for(let y in settings[x]){
  2216. if(val.script_theme[i][j].id == settings[x][y].id) settings[x][y] = val.script_theme[i][j];
  2217. }
  2218. }
  2219. }
  2220. }
  2221. }
  2222. if(val.selected.game_settings && $('#fsfb-game-settings').is(':checked')) localStorage.setItem('settings', val.game_settings);
  2223. if(val.selected.game_controls && $('#fsfb-game-controls').is(':checked')) localStorage.setItem('hotkeys', val.game_controls);
  2224. if(val.selected.game_background && $('#fsfb-custom-bg').is(':checked')){
  2225. let db, req = unsafeWindow.indexedDB.open("AgmaDB", 1);
  2226. req.onsuccess = function (x) {
  2227. db = req.result;
  2228. db.onclose = (c) => { db = null; }
  2229. db.onversionchange = (c) => { db.close(), db = null; }
  2230. let _ = db.transaction("general", "readwrite").objectStore("general").put(val.game_background, "cbgDataURL");
  2231. }, req.onupgradeneeded = function (c) {
  2232. let req = c.target.result;
  2233. if (!req.objectStoreNames.contains("general")) {
  2234. req.createObjectStore("general");
  2235. }
  2236. };
  2237. }
  2238. // if any agma controls were imported, need to refresh bc it's set using localstorage
  2239. if((val.selected.game_settings && $('#fsfb-game-settings').is(':checked')) || (val.selected.game_controls && $('#fsfb-game-controls').is(':checked')) || (val.selected.game_background && $('#fsfb-custom-bg').is(':checked'))){
  2240. swal({
  2241. title: "Please Refresh!",
  2242. text: "Refreshing the page is required for your imported agma settings to take effect",
  2243. type: "warning",
  2244. });
  2245. } else swal({ title: "Settings Successfully Imported!", type: "success" });
  2246. saveSettings();
  2247. styleActiveSettings();
  2248. updateScriptSettingsUI();
  2249. } catch (error){
  2250. swal({
  2251. title: "Something went wrong!",
  2252. text: "Please make sure you've entered in valid settings",
  2253. type: "error"
  2254. });
  2255. }
  2256. });
  2257.  
  2258. });
  2259.  
  2260. $('#fsfb-settings-right').append(`<div class="fa fa-2x fa-info-circle" id="fsfb-extra-info" data-toggle="modal" data-target=".fsfb-bug-modal"></div>`)
  2261.  
  2262. if(userPreferences.hideAds){
  2263. localStorage.ad_l_time = "9e99"; // smth like time since last ad
  2264. $('[id^="agma-io_"], [id^="adWrapper"], #preroll').addClass("fsfb-removeAds"); // move ads way off the screen
  2265. } else if(localStorage.ad_l_time == "9e99")localStorage.ad_l_time = Date.now();
  2266.  
  2267. let {innerWidth: width, innerHeight: height} = unsafeWindow;
  2268. $(unsafeWindow).on('resize', () => ({innerWidth: width, innerHeight: height} = unsafeWindow));
  2269.  
  2270. let pointMove;
  2271. const linesplit = () => {
  2272. if(!linesplitting) return;
  2273. let closest, points = [{n: "top", x: width / 2, y: 0, nx: width / 2, ny: -10e6}, {n: "bottom", x: width / 2, y: height, nx: width / 2, ny: 10e6}, {n: "left", x: 0, y: height / 2, nx: -10e6, ny: height / 2}, {n: "right", x: width, y: height / 2, nx: 10e6, ny: height / 2}];
  2274. if(userPreferences.linesplitClosestSide){
  2275. let closestSide = [mosY / height, (height - mosY) / height, mosX / width, (width - mosX) / width]; // top, bottom, left, right
  2276. closest = points[closestSide.indexOf(Math.min(...closestSide))];
  2277. } else {
  2278. let distance = p => Math.sqrt(Math.pow(mosX - p.x, 2) + Math.pow(mosY - p.y, 2)),
  2279. closestPoint = points.reduce((a, b) => distance(a) < distance(b) ? a : b);
  2280. for (let i = 0; i < points.length; i++) {
  2281. if (closestPoint.x == points[i].x && closestPoint.y == points[i].y) closest = points[i]
  2282. }
  2283. }
  2284. pointMove = {x: closest.nx, y: closest.ny};
  2285. $('#canvas').trigger($.Event('mousemove', { clientX: closest.nx, clientY: closest.ny }));
  2286. $("#linesplit-markers div").css('background-color', 'transparent');
  2287. $('#linesplit-' + closest.n).css('background-color', '#e25615');
  2288. }
  2289.  
  2290. let confBtns = document.getElementsByClassName('purchase-btn confirmation');
  2291. const btnsArr = Array.from(document.getElementsByClassName('purchase-btn confirmation'));
  2292.  
  2293. const changeHTML = (index, price, id, name) => {
  2294. setTimeout(() => {
  2295. const amtDropdown = document.getElementById('shopAmountDropdown')
  2296. document.getElementsByClassName('sweet-alert showSweetAlert')[0].childNodes[7].firstChild.textContent = 'If you click "Buy", you will purchase this item. It will cost ' + price.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + ' in total.';
  2297. const dropdownChange = () => {
  2298. if (amtDropdown.value == "custom") return buyCstmAmt(price, id, name);
  2299. let priceSum = (amtDropdown.value * price).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
  2300. document.getElementsByClassName('sweet-alert showSweetAlert')[0].childNodes[7].firstChild.textContent = 'If you click "Buy", you will purchase this item. It will cost ' + priceSum + ' in total.';
  2301. };
  2302. amtDropdown.addEventListener('change', dropdownChange);
  2303. }, 50);
  2304. };
  2305. const buyCstmAmt = (price, id, name) => {
  2306. swal({
  2307. title: "Enter Purchase Amount",
  2308. text: "<span>How many <b>" + name + "</b> would you like to buy?</span>",
  2309. html: true,
  2310. type: "input",
  2311. showCancelButton: true,
  2312. closeOnConfirm: false,
  2313. inputPlaceholder: "Input amount here"
  2314. },
  2315. function(input){
  2316. let pwAmt = +input,
  2317. priceTotal = pwAmt * price;
  2318. if (input == null) return false;
  2319. if (input == "") {
  2320. swal.showInputError("Please don't leave the input empty!");
  2321. return false
  2322. }
  2323. if(!/^[0-9]+$/.test(input) || !(+input >>> 0 === parseFloat(+input))){
  2324. swal.showInputError("Please only enter positive integers!");
  2325. return false
  2326. }
  2327. swal({
  2328. title: ' Confirm ',
  2329. text: '<p>If you click "Buy", you will purchase this item. It will cost ' + priceTotal.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + ' in total.<br><small>You chose to purchase ' + pwAmt.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + ' <b>' + name + '</b></small></p>',
  2330. html: true,
  2331. type: 'warning',
  2332. showCancelButton: true,
  2333. closeOnConfirm: true,
  2334. confirmButtonColor: '#4caf51',
  2335. confirmButtonText: 'Yes, confirm purchase',
  2336. cancelButtonText: 'No, cancel purchase'
  2337. }, function(confirmed){
  2338. if(confirmed && $('.confirm').is(':visible')) buyPw(id, pwAmt);
  2339. })
  2340.  
  2341. });
  2342. };
  2343. // buy a certain amount of powers including > 255
  2344. const buyPw = (shopID, pwAmt) => {
  2345. if (pwAmt < 1) return;
  2346. if (pwAmt > 255) {
  2347. for (let i = 0; i < ~~(pwAmt / 255); i++) setTimeout(() => purchaseItem(shopID, 255), 500 * i + 250);
  2348. purchaseItem(shopID, pwAmt % 255);
  2349. } else purchaseItem(shopID, pwAmt);
  2350. };
  2351.  
  2352.  
  2353. if(userPreferences.improvedShop){
  2354. // add event listeners to dropdown buttons
  2355. for (let i = 0; i < confBtns.length; i++) {
  2356. confBtns[i].onclick = function () {
  2357. setTimeout(() => {
  2358. if (document.getElementById('shopAmountDropdown') != null) document.getElementById('shopAmountDropdown').innerHTML += '<option value="20">20</option> <option value="50">50</option> <option value="100">100</option> <option value="250">250</option> <option value="custom">Pick</option>';
  2359. }, 5);
  2360. }
  2361. }
  2362. // add event listeners to shop buttons
  2363. for (let i = 0; i < 16; i++) {
  2364. if (i != 10 && i != 11){
  2365. btnsArr[i].addEventListener('click', function(e){
  2366. if(!e.isTrusted && !quickBuying) return;
  2367. let index = i;
  2368. changeHTML(index, btnsArr[index].getAttribute('price'), btnsArr[index].getAttribute('item'), $('.purchase-btn.confirmation[item="' + btnsArr[index].getAttribute('item') + '"]').prev().find('h3').eq(0).text());
  2369. });
  2370. }
  2371. }
  2372. }
  2373.  
  2374.  
  2375. // listen for when a min pack is bought
  2376. let minBoughtAmt = {};
  2377. if(userPreferences.extraChatCommands){
  2378. let lastClickedPrice, currentPrice, lastID;
  2379. const confirmClicked = () => {
  2380. setTimeout(() => {
  2381. if($('.sweet-alert h2').text() != "Success!" || lastClickedPrice != currentPrice) return;
  2382. const map = {
  2383. 1: '10 Bots 1 Hour',
  2384. 2: '40 Bots 1 Hour',
  2385. 3: '50 Bots 2 Hours',
  2386. 4: '80 Bots 1 Hour',
  2387. 5: '100 Bots 4 Hours',
  2388. 6: '125 Bots 8 Hours',
  2389. 7: '300 Bots 24 Hours',
  2390. 8: '100 MASS Bots 1 Hour',
  2391. 9: '100 Bots 24 Hours',
  2392. 10: '125 Bots 48 Hours',
  2393. 11: '300 Bots 72 Hours',
  2394. 12: '100 MASS Bots 24 Hours'
  2395. }
  2396. minBoughtAmt[currentUser] = {...minsChatAmt[currentUser], ... {chatAmt: map[lastID], started: false}};
  2397. }, 900);
  2398. };
  2399. $('.purchase-btn2.confirm-minion[item]').on('click', function () {
  2400. lastClickedPrice = this.getAttribute('price').replace(/,/g, '');
  2401. lastID = this.getAttribute('item');
  2402. $('.confirm').attr('disabled', 'true'); // disable so user doesn't buy early - swal is slow to load text
  2403. setTimeout(() => {
  2404. $('.confirm').removeAttr('disabled');
  2405. currentPrice = $('.sweet-alert.showSweetAlert.visible p').eq(0).text().replace(/\D+/g, '');
  2406. }, 750);
  2407. setTimeout(() => $('.confirm')[0].addEventListener('click', confirmClicked), 500);
  2408. })
  2409. }
  2410.  
  2411. // context menu: click on skin -> skin ID to clipboard, click on name -> name to clipboard
  2412. $('#contextPlayer').on('click', e => {
  2413. if(!userPreferences.rightClickCopyInfo) return;
  2414. if($('#contextPlayerSkin').width() + $('#contextPlayerSkin').offset().left + 5 > e.pageX){ // bcs #contextMenu event :dog:
  2415. // cell was clicked
  2416. if($('#contextPlayerSkin').css('background-image') != "none"){
  2417. let skinID = $('#contextPlayerSkin').css('background-image').match(/(?<=\/skins\/)[0-9]+/gm)[0]; // get the skin image, then match only the skin's ID
  2418. navigator.clipboard.writeText(skinID).then(function() {
  2419. curserMsg('Skin ID of ' + skinID + ' was copied to your clipboard.', 'green');
  2420. }, function() {
  2421. curserMsg('Something went wrong. Nothing was added to your clipboard.', 'red');
  2422. });
  2423. } else if($('#contextPlayerSkin').css('background-color') == 'rgb(51, 51, 51)') curserMsg('No player selected. Nothing was added to your clipboard.', 'red');
  2424. else curserMsg('No skin equipped. Nothing was added to your clipboard.', 'red');
  2425. } else { // name was clicked
  2426. if($('#contextPlayerSkin').css('background-color') == 'rgb(51, 51, 51)') curserMsg('No player selected. Nothing was added to your clipboard.', 'red');
  2427. else {
  2428. navigator.clipboard.writeText($('#contextPlayerName').text()).then(function() {
  2429. curserMsg('Nickname: "' + $('#contextPlayerName').text() + '" was copied to your clipboard', 'green');
  2430. }, function() {
  2431. curserMsg("Something went wrong. Nothing was added to your clipboard.", "red");
  2432. });
  2433. }
  2434. }
  2435. });
  2436.  
  2437.  
  2438. // little bar at the top of the screen that tells u stuff
  2439. let curserTimeout;
  2440. function curserMsg(msg, color, time, html){
  2441. let colorTable = {
  2442. "green": "rgb(0, 192, 0)",
  2443. "red": "rgb(255, 0, 0)",
  2444. "gray": "rgb(153, 153, 153)",
  2445. "yellow": "rgb(255, 170, 0)",
  2446. "orange": "rgb(255, 149, 0)",
  2447. "lightgray": "rgb(194, 194, 194)",
  2448. "white": "rgb(255, 255, 255)",
  2449. "purple": "rgb(190, 138, 255)"
  2450. }
  2451. color = colorTable[color];
  2452. clearTimeout(curserTimeout);
  2453. $('#curser')[(html ?? false) ? "html" : "text"](msg).show().css('color', color)
  2454. if(time != 0) curserTimeout = setTimeout(() => $('#curser').fadeOut(400), time ?? 4e3);
  2455. }
  2456. unsafeWindow.curserMsg = curserMsg;
  2457.  
  2458. let minTimeRemaining = 0;
  2459. const startMin = unsafeWindow.strMin;
  2460. unsafeWindow.strMin = function(){
  2461. minsStart();
  2462. return startMin.apply(this, arguments);
  2463. }
  2464. let minsChatAmt = {},
  2465. accGoldMem = {};
  2466. const minsStart = async() => {
  2467. let minAmt, minsStarted = false;
  2468. const waitUntil1 = (condition) => new Promise(resolve => {
  2469. let interval = setInterval(() => {
  2470. $('#infoContent').children().each(function(){
  2471. if($(this).text().includes('Minion Time:')) minsStarted = true;
  2472. })
  2473. condition() && (clearInterval(interval), resolve());
  2474. }, 100);
  2475. setTimeout(() => { (clearInterval(interval), resolve()); }, 1e4);
  2476. });
  2477. await waitUntil1(() => minsStarted == true);
  2478. if(!minsStarted) return;
  2479. $('#infoContent').children().each(function(){
  2480. if($(this).text().includes('Minion Time:')) minTimeRemaining = $(this).find('span').text();
  2481. if($(this).text().includes('Minions:')) minAmt = $(this).find('span').text();
  2482. })
  2483. let timeArr = minTimeRemaining.split(':'), msBotsTime = (3.6e6 * +timeArr[0]) + (6e4 * +timeArr[1]) + (1e3 * +timeArr[2]);
  2484. misc_settings.bots[currentUser] = {...misc_settings.bots[currentUser], ...{active: true, amt: minAmt, chatAmt: null, rem: msBotsTime, currMs: Date.now()}};
  2485. setStorage("fsfb-misc", misc_settings);
  2486. }
  2487.  
  2488. // ability time remaining
  2489. if(userPreferences.showRemainingAbilityTime){
  2490. let lastID;
  2491. const abilityIds = [18, 20, 22, 23];
  2492. abilityIds.forEach(id => {
  2493. const h5 = $(`.purchase-btn.confirmation[item="${id}"]`).parents().eq(0).find('div h5');
  2494. h5.clone().insertAfter(h5).addClass('fsfb-fake').hide();
  2495.  
  2496. const checkmarkImg = $(`.purchase-btn.confirmation[item="${id}"]`).parent().find(".checkmark:first");
  2497.  
  2498. $(`.purchase-btn[item="${id}"]`).on('click', function () {
  2499. lastID = this.getAttribute('item');
  2500.  
  2501. const hadAbilityBefore = checkmarkImg.is(":visible");
  2502.  
  2503. setTimeout(() => {
  2504. const isVisibleNow = $(`.purchase-btn.confirmation[item="${id}"]`).parent().find(".checkmark:first").is(":visible");
  2505. if(!hadAbilityBefore && isVisibleNow){
  2506. // purchase successful, set timer
  2507. misc_settings.abil[currentUser] = {...misc_settings.abil[currentUser], ...{[lastID] : Date.now()}};
  2508. setStorage("fsfb-misc", misc_settings);
  2509. }
  2510. }, 2500)
  2511. });
  2512. });
  2513. }
  2514.  
  2515. // sort wearables by owned
  2516. const waitUntil = condition => new Promise(resolve => {
  2517. let interval = setInterval(() => {
  2518. condition() && (clearInterval(interval), resolve());
  2519. }, 100);
  2520. setTimeout(() => { (clearInterval(interval), resolve()) }, 15e3);
  2521. });
  2522. if(userPreferences.sortWearablesByOwned){
  2523. $('#wearablesTab').on('click', async() => {
  2524. await waitUntil(() => $('#phpWearables li').length > 55);
  2525. if($('#phpWearables li').length <= 55) return;
  2526. $($('[id^="wearableUseBtn"]').get().reverse()).each(function(){
  2527. $($(this).parents().get(2)).insertBefore($("#phpWearables li:eq(0)"));
  2528. })
  2529. $('#phpWearables').append('<div id="fsfb-wearsloaded"></div>');
  2530. });
  2531. }
  2532. // https://stackoverflow.com/questions/2424191/how-do-i-make-an-element-draggable-in-jquery
  2533. $.fn.draggable = function(){
  2534. var $this = this,
  2535. ns = 'draggable_'+(Math.random()+'').replace('.',''),
  2536. mm = 'mousemove.'+ns,
  2537. mu = 'mouseup.'+ns,
  2538. $w = $(unsafeWindow),
  2539. isFixed = ($this.css('position') === 'fixed'),
  2540. adjX = 0, adjY = 0;
  2541.  
  2542. $this.mousedown(function(ev){
  2543. var pos = $this.offset();
  2544. if (isFixed) {
  2545. adjX = $w.scrollLeft(); adjY = $w.scrollTop();
  2546. }
  2547. var ox = (ev.pageX - pos.left), oy = (ev.pageY - pos.top);
  2548. $this.data(ns,{ x : ox, y: oy });
  2549. $w.on(mm, function(ev){
  2550. ev.preventDefault();
  2551. ev.stopPropagation();
  2552. if (isFixed) {
  2553. adjX = $w.scrollLeft(); adjY = $w.scrollTop();
  2554. }
  2555. var offset = $this.data(ns);
  2556. $this.css({left: Math.round(ev.pageX - adjX - offset.x), top: Math.round(ev.pageY - adjY - offset.y)});
  2557. });
  2558. $w.on(mu, function(){
  2559. $w.off(mm + ' ' + mu).removeData(ns);
  2560. });
  2561. });
  2562. return this;
  2563. };
  2564.  
  2565.  
  2566. /* xp/coins statistics */
  2567.  
  2568. const updateTimeXP = 12e3; // xp bar updates every 12 seconds, don't change
  2569. let lastMinXP = [];
  2570. let lastHrXP = [];
  2571. let currentPercent, currentLevel, currentXP, currentCoins;
  2572.  
  2573. unsafeWindow.logStatsScriptXP = !1;
  2574. unsafeWindow.logStatsScriptCoins = !1;
  2575. let scriptStartCoins = Date.now();
  2576. let scriptStartXP = Date.now();
  2577. let accounts = {};
  2578. const guiDisplay = "none";
  2579. let coinsHTMLactive = false;
  2580.  
  2581. const updateTimeCoins = 6e3;
  2582. let lastMinCoins = [];
  2583. let lastHrCoins = [];
  2584.  
  2585. // add stats box html
  2586. const statsBody = document.createElement('div');
  2587. statsBody.setAttribute('id', 'stats-container');
  2588. statsBody.style.display = guiDisplay;
  2589. statsBody.innerHTML = `
  2590. <div id="stats-main">
  2591. <div id="stats-title">
  2592. <title id="stats-extra-info">XP Stats - Updating Every 12s</title>
  2593. <div>
  2594. <div title="Toggle Percentages Shown" id="stats-perc-btn" class="fa fa-percent"></div>
  2595. <div title="Toggle Stats Shown" id="stats-change-shown" class="fa fa-eye-slash"></div>
  2596. <div title="Reset Stats" class="fa fa-refresh" id="stats-reset-btn"></div>
  2597. </div>
  2598. </div>
  2599. <div>
  2600. <table id="stats-table">
  2601. <tbody>
  2602. <tr>
  2603. <td><label><input type="checkbox">Lvl Completed:</label></td>
  2604. <td>0/0</td>
  2605. </tr>
  2606. <tr>
  2607. <td><label><input type="checkbox">Remaining:</label></td>
  2608. <td>100,000</td>
  2609. </tr>
  2610. <tr>
  2611. <td><label><input type="checkbox">Projected (hr):</label></td>
  2612. <td>0</td>
  2613. </tr>
  2614. <tr>
  2615. <td><label><input type="checkbox">Last Hour:</label></td>
  2616. <td>100,000</td>
  2617. </tr>
  2618. <tr>
  2619. <td><label><input type="checkbox">Last Minute:</label></td>
  2620. <td>100,000</td>
  2621. </tr>
  2622. <tr>
  2623. <td><label><input type="checkbox">Last 12s:</label></td>
  2624. <td>100,000</td>
  2625. </tr>
  2626. <tr>
  2627. <td><label><input type="checkbox">Minute Mean:</label></td>
  2628. <td>100,000</td>
  2629. </tr>
  2630. <tr>
  2631. <td><label><input type="checkbox">Minute Median:</label></td>
  2632. <td>100,000</td>
  2633. </tr>
  2634. <tr>
  2635. <td><label><input type="checkbox">Minute Sd:</label></td>
  2636. <td>100,000</td>
  2637. </tr>
  2638. <tr>
  2639. <td><label><input type="checkbox">Latest Outliers:</label></td>
  2640. <td>100,000</td>
  2641. </tr>
  2642. <tr>
  2643. <td><label><input type="checkbox">Session XP:</label></td>
  2644. <td>100,000</td>
  2645. </tr>
  2646. <tr>
  2647. <td><label><input type="checkbox">Session Length:</label></td>
  2648. <td>100,000</td>
  2649. </tr>
  2650. <tr>
  2651. <td><label><input type="checkbox">Lifetime XP:</label></td>
  2652. <td>100,000</td>
  2653. </tr>
  2654. </tbody>
  2655. </table>
  2656. </div>
  2657. </div>`;
  2658. document.querySelector('body').append(statsBody);
  2659.  
  2660. $("#stats-container").draggable();
  2661. let statsboxPos = misc_settings?.statsPos ?? {top: $("#stats-container")[0].style.top, left: $("#stats-container")[0].style.left};
  2662. if(userPreferences.saveStatsBoxPosition && statsboxPos) $("#stats-container").css({'top' : statsboxPos.top, 'left' : statsboxPos.left});
  2663.  
  2664. const convertToPerc = (xpAmt, lvl = 0) => isNaN(xpAmt / (lvl * 1000)) ? 0 : xpAmt / (lvl * 1000);
  2665.  
  2666. $('#stats-reset-btn').on('click', () => {
  2667. if(coinsHTMLactive){
  2668. lastMinCoins = [];
  2669. lastHrCoins = [];
  2670. for(let i in accounts) accounts[i].coins = 0;
  2671. if(accounts[currentUser] !== null && currentUser !== 'Please Login First') accounts[currentUser].coins = currentCoins;
  2672. scriptStartCoins = Date.now();
  2673. } else {
  2674. lastMinXP = [];
  2675. lastHrXP = [];
  2676. for(let i in accounts){
  2677. accounts[i].xp = 0;
  2678. accounts[i].lvl = 0;
  2679. }
  2680. if(accounts[currentUser] !== null && currentUser !== 'Please Login First'){
  2681. accounts[currentUser].xp = currentXP;
  2682. accounts[currentUser].lvl = round(currentPercent, 3) + currentLevel;
  2683. }
  2684. scriptStartXP = Date.now();
  2685. }
  2686. updateUI();
  2687. });
  2688. let xpStatsInPercentages = false;
  2689. $('#stats-perc-btn').on('click', () => {
  2690. xpStatsInPercentages = !xpStatsInPercentages;
  2691. updateUI();
  2692. });
  2693.  
  2694. let changingShownStats = false;
  2695. $('#stats-change-shown').on('click', () => {
  2696. changingShownStats = !changingShownStats;
  2697. if(changingShownStats){
  2698. $('#stats-table tr').show();
  2699. _replaceCSS('stats-input-css', '#stats-table input{ display: unset; }');
  2700. } else {
  2701. for(let i in misc_settings.statsSettings[coinsHTMLactive ? 'coins' : 'xp']){
  2702. misc_settings.statsSettings[coinsHTMLactive ? 'coins' : 'xp'][i] = $(`#stats-${i} input[type="checkbox"]`).is(':checked');
  2703. $('#stats-' + i)[$(`#stats-${i} input[type="checkbox"]`).is(':checked') ? 'show' : 'hide']();
  2704. }
  2705. setStorage("fsfb-misc", misc_settings);
  2706. _replaceCSS('stats-input-css', '#stats-table input{ display: none; }');
  2707. }
  2708. });
  2709.  
  2710. class StatLog {
  2711. constructor(val, lvl, user, arr) {
  2712. this.type = this.findWhich(arr); // mostly for debugging
  2713. this.id = this.getID(arr);
  2714. this.user = user;
  2715. this.amount = val;
  2716. this.gained = this.calcGain(val, arr, this.id);
  2717. this.lvl = lvl;
  2718. // this.timestamp = Date.now(); // mostly for debugging
  2719. }
  2720. findWhich(arr) {
  2721. return ((arr == lastMinXP || arr == lastHrXP ? "xp " : "coins " ) + (arr == lastHrXP || arr == lastHrCoins ? "hour" : "minute"));
  2722. }
  2723. calcGain(val, arr, id){
  2724. const prevObj = arr[arr.length - 1];
  2725. if(prevObj && arr == lastHrXP && id == 1) return round(sigma(getProperty(lastMinXP, "gained")), 3);
  2726. if(prevObj && arr == lastHrCoins && id == 1) return round(sigma(getProperty(lastMinCoins, "gained")), 3);
  2727. return prevObj && val - prevObj.amount >= 0 && prevObj.user == this.user && prevObj.amount != 0 ? round(val - prevObj.amount, 3) : 0;
  2728. }
  2729. getID(arr) {
  2730. return arr[arr.length - 1] ? arr[arr.length - 1].id + 1 : 1;
  2731. }
  2732.  
  2733. }
  2734.  
  2735. const xpInfo = () => {
  2736. currentPercent = $('.progress-bar[role=progressbar]')[0].style.width.slice(0, -1) / 100;
  2737. currentLevel = +$('#level.user-level')[0].textContent;
  2738. currentXP = (levelSum(currentLevel) + currentLevel * currentPercent) * 1e3;
  2739. }
  2740. const coinsInfo = () => {
  2741. currentCoins = +($('#coinsDash')[0].textContent.replace(/ /g, ''));
  2742. }
  2743.  
  2744. const updateUI = () => {
  2745. if(changingShownStats) return;
  2746. if(!coinsHTMLactive){
  2747. const xpHr = lastHrXP.length,
  2748. xpMin = lastMinXP.length,
  2749. lvlCompleted = currentPercent ? String(Math.round(currentPercent * currentLevel * 1e3, 1)).replace(/\B(?=(\d{3})+(?!\d))/g, ",") + "/" + (currentLevel * 1e3).toLocaleString('en-US') : "0/0",
  2750. xpRemaining = currentLevel ? currentLevel * 1e3 - currentPercent * currentLevel * 1e3 : 0,
  2751. projectedHr = xpHr > 0 ? sigma(getProperty(lastHrXP.slice(-5), "gained")) * 12 : 0,
  2752. lastHr = xpHr > 0 ? sigma(getProperty(lastHrXP, "gained")) : 0,
  2753. lastHrCompleted = xpHr > 0 ? xpHr : 0,
  2754. lastMin = xpMin > 0 ? sigma(getProperty(lastMinXP, "gained")) : 0,
  2755. lastMinCompleted = xpMin > 0 ? xpMin : 0,
  2756. lastMinTotal = 6e4 / updateTimeXP,
  2757. last12sec = xpMin > 0 ? lastMinXP[lastMinXP.length - 1].gained : 0,
  2758. xBar = xpHr > 0 ? mean(getProperty(lastHrXP, "gained")) : 0,
  2759. xTilde = xpHr > 0 ? median(getProperty(lastHrXP, "gained")) : 0,
  2760. standardDev = xpHr > 0 ? standardDeviation(getProperty(lastHrXP, "gained")) : 0,
  2761. outliers = xpHr > 0 ? checkOutliers(getProperty(lastHrXP, "gained")) : 0,
  2762. sessionXP = currentXP && accounts[currentUser] ? currentXP - accounts[currentUser].xp : 0,
  2763. sessionLength = msToTime(Date.now() - scriptStartXP),
  2764. lifetimeXP = currentXP ? Math.round(currentXP) : 0,
  2765. updateTime = updateTimeXP;
  2766. document.getElementById('stats-table').innerHTML = `
  2767. <tbody>
  2768. <tr id="stats-lvlcomp">
  2769. <td><label><input type="checkbox">Lvl Completed:</label></td>
  2770. <td>${lvlCompleted.toLocaleString('en-US')}</td>
  2771. </tr>
  2772. <tr id="stats-rem">
  2773. <td><label><input type="checkbox">Remaining:</label></td>
  2774. <td>${xpStatsInPercentages ? round(convertToPerc(xpRemaining, currentLevel) * 100, 2) + '%' : round(xpRemaining).toLocaleString('en-US')}</td>
  2775. </tr>
  2776. <tr id="stats-projhr">
  2777. <td><label><input type="checkbox">Projected (hr):</label></td>
  2778. <td>${xpStatsInPercentages ? round(convertToPerc(projectedHr, currentLevel) * 100, 2) + '%' : round(projectedHr).toLocaleString('en-US')}</td>
  2779. </tr>
  2780. <tr id="stats-lasthr">
  2781. <td><label><input type="checkbox">Last Hour:</label></td>
  2782. <td>${xpStatsInPercentages ? round(convertToPerc(lastHr, currentLevel) * 100, 2) + '%' : round(lastHr).toLocaleString('en-US')}<span class="stats-completed">(${lastHrCompleted}/60)</span></td>
  2783. </tr>
  2784. <tr id="stats-lastmin">
  2785. <td><label><input type="checkbox">Last Minute:</label></td>
  2786. <td>${xpStatsInPercentages ? round(convertToPerc(lastMin, currentLevel) * 100, 2) + '%' : round(lastMin).toLocaleString('en-US')}<span class="stats-completed">(${lastMinCompleted + "/" + lastMinTotal})</span></td>
  2787. </tr>
  2788. <tr id="stats-lastsec">
  2789. <td><label><input type="checkbox">Last 12s:</label></td>
  2790. <td>${xpStatsInPercentages ? round(convertToPerc(last12sec, currentLevel) * 100, 2) + '%' : round(last12sec).toLocaleString('en-US')}</td>
  2791. </tr>
  2792. <tr id="stats-mean">
  2793. <td><label><input type="checkbox">Minute Mean:</label></td>
  2794. <td>${xpStatsInPercentages ? round(convertToPerc(xBar, currentLevel) * 100, 2) + '%' : round(xBar).toLocaleString('en-US')}</td>
  2795. </tr>
  2796. <tr id="stats-median">
  2797. <td><label><input type="checkbox">Minute Median:</label></td>
  2798. <td>${xpStatsInPercentages ? round(convertToPerc(xTilde, currentLevel) * 100, 2) + '%' : round(xTilde).toLocaleString('en-US')}</td>
  2799. </tr>
  2800. <tr id="stats-sd">
  2801. <td><label><input type="checkbox">Minute Sd:</label></td>
  2802. <td>${xpStatsInPercentages ? round(convertToPerc(standardDev, currentLevel) * 100, 2) + '%' : round(standardDev).toLocaleString('en-US')}</td>
  2803. </tr>
  2804. <tr id="stats-sesh">
  2805. <td><label><input type="checkbox">Session XP:</label></td>
  2806. <td>${xpStatsInPercentages ? round(currentLevel && accounts[currentUser] ? ((round(currentPercent, 3) + currentLevel) - accounts[currentUser].lvl) * 100 : 0, 2) + '%' : round(sessionXP).toLocaleString('en-US')}</td>
  2807. </tr>
  2808. <tr id="stats-seshlength">
  2809. <td><label><input type="checkbox">Session Length:</label></td>
  2810. <td id="stats-sesh-length">${sessionLength}</td>
  2811. </tr>
  2812. <tr id="stats-lifetime">
  2813. <td><label><input type="checkbox">Lifetime XP:</label></td>
  2814. <td>${lifetimeXP.toLocaleString('en-US')}</td>
  2815. </tr>
  2816. </tbody>`;
  2817. for(let i in misc_settings.statsSettings.xp){
  2818. $('#stats-' + i)[misc_settings.statsSettings.xp[i] ? 'show' : 'hide']();
  2819. $('#stats-' + i + ' input[type="checkbox"').prop("checked", misc_settings.statsSettings.xp[i]);
  2820. }
  2821. $('#stats-extra-info').text(`XP Stats - Updating Every ${updateTime / 1e3}s`).css('color', '#00bbff');
  2822. $('#stats-sesh-length').text(msToTime(Date.now() - scriptStartXP));
  2823. $('#stats-perc-btn').show();
  2824. } else {
  2825. const coinsHr = lastHrCoins.length,
  2826. coinsMin = lastMinCoins.length,
  2827. coinGoalCompleted = currentCoins ? currentCoins.toLocaleString('en-US') + "/" + Math.ceil(currentCoins / 25e4).toLocaleString('en-US') * 25e4 : 0,
  2828. coinsRemaining = currentCoins ? 25e4 - currentCoins % 25e4 : 0,
  2829. projectedHr = coinsHr > 5 ? Math.round(sigma(getProperty(lastHrCoins.slice(-5), "gained")) * 12) : 0,
  2830. lastHr = coinsHr > 0 ? Math.round(sigma(getProperty(lastHrCoins, "gained"))) : 0,
  2831. lastHrCompleted = coinsHr > 0 ? coinsHr : 0,
  2832. lastMin = coinsMin > 0 ? Math.round(sigma(getProperty(lastMinCoins, "gained"))) : 0,
  2833. lastMinCompleted = coinsMin > 0 ? coinsMin : 0,
  2834. lastMinTotal = 6e4 / updateTimeCoins,
  2835. last12sec = coinsMin > 0 ? getProperty(lastHrCoins.slice(-5), "amount")[0] : 0,
  2836. xBar = coinsHr > 0 ? Math.round(mean(getProperty(lastHrCoins, "gained"))) : 0,
  2837. xTilde = coinsHr > 0 ? Math.round(median(getProperty(lastHrCoins, "gained"))) : 0,
  2838. standardDev = coinsHr > 0 ? Math.round(standardDeviation(getProperty(lastHrCoins, "gained"))) : 0,
  2839. outliers = coinsHr > 0 ? checkOutliers(getProperty(lastHrCoins, "gained")) : 0,
  2840. sessionXP = currentCoins && accounts[currentUser] ? Math.round(currentCoins - accounts[currentUser].coins): 0,
  2841. sessionLength = msToTime(Date.now() - scriptStartCoins),
  2842. updateTime = updateTimeCoins;
  2843. document.getElementById('stats-table').innerHTML = `
  2844. <tbody>
  2845. <tr id="stats-rem">
  2846. <td><label><input type="checkbox">Remaining:</label></td>
  2847. <td>${coinsRemaining.toLocaleString('en-US')}</td>
  2848. </tr>
  2849. <tr id="stats-projhr">
  2850. <td><label><input type="checkbox">Projected (hr):</label></td>
  2851. <td>${projectedHr.toLocaleString('en-US')}</td>
  2852. </tr>
  2853. <tr id="stats-lasthr">
  2854. <td><label><input type="checkbox">Last Hour:</label></td>
  2855. <td>${lastHr.toLocaleString('en-US')}<span class="stats-completed">(${lastHrCompleted}/60)</span></td>
  2856. </tr>
  2857. <tr id="stats-lastmin">
  2858. <td><label><input type="checkbox">Last Minute:</label></td>
  2859. <td>${lastMin.toLocaleString('en-US')}<span class="stats-completed">(${lastMinCompleted + "/" + lastMinTotal})</span></td>
  2860. </tr>
  2861. <tr id="stats-mean">
  2862. <td><label><input type="checkbox">Minute Mean:</label></td>
  2863. <td>${xBar.toLocaleString('en-US')}</td>
  2864. </tr>
  2865. <tr id="stats-median">
  2866. <td><label><input type="checkbox">Minute Median:</label></td>
  2867. <td>${xTilde.toLocaleString('en-US')}</td>
  2868. </tr>
  2869. <tr id="stats-sd">
  2870. <td><label><input type="checkbox">Minute Sd:</label></td>
  2871. <td>${standardDev.toLocaleString('en-US')}</td>
  2872. </tr>
  2873. <tr id="stats-sesh">
  2874. <td><label><input type="checkbox">Session Coins:</label></td>
  2875. <td>${sessionXP.toLocaleString('en-US')}</td>
  2876. </tr>
  2877. <tr id="stats-seshlength">
  2878. <td><label><input type="checkbox">Session Length:</label></td>
  2879. <td id="stats-sesh-length">${sessionLength}</td>
  2880. </tr>
  2881. </tbody>`;
  2882. for(let i in misc_settings.statsSettings.coins){
  2883. $('#stats-' + i)[misc_settings.statsSettings.coins[i] ? 'show' : 'hide']();
  2884. $('#stats-' + i + ' input[type="checkbox"').prop("checked", misc_settings.statsSettings.coins[i]);
  2885. }
  2886. $('#stats-extra-info').text(`Coin Stats - Updating Every ${updateTime / 1e3}s`).css('color', '#ffc800');
  2887. $('#stats-sesh-length').text(msToTime(Date.now() - scriptStartCoins));
  2888. $('#stats-perc-btn').hide();
  2889. }
  2890. }
  2891.  
  2892. $('.progress-bar').eq(1).parent()[0].style.cursor = "pointer";
  2893.  
  2894. if(userPreferences.coinXPstats){
  2895. $('.progress-bar').eq(1).parent().on("click", () => {
  2896. const statsCont = $('#stats-container');
  2897. if(statsCont[0].style.display == "none") statsCont.fadeIn(400);
  2898. else if(!coinsHTMLactive) statsCont.fadeOut(400);
  2899. coinsHTMLactive = false;
  2900. updateUI();
  2901. }), [$(".dash-coin.dcTopBar").eq(0), $("#coinsTopLeft"), $(".progress-bar-coins").eq(1)].forEach(el => {
  2902. el.on('click', (e) => {
  2903. const statsCont = $('#stats-container');
  2904. if(statsCont[0].style.display == "none") statsCont.fadeIn(400);
  2905. else if(coinsHTMLactive) statsCont.fadeOut(400);
  2906. coinsHTMLactive = true;
  2907. updateUI();
  2908. e.stopImmediatePropagation();
  2909. });
  2910. });
  2911. }
  2912.  
  2913. // copy chat msgs
  2914. if(userPreferences.rightClickCopyChat){
  2915. $('#contextSpectate').after(`<li id="contextCopyChat" class="contextmenu-item enabled"><div class="fa fa-clipboard fa-2x context-icon"></div><p>Copy Chat Messages</p></li>`);
  2916. $('#contextCopyChat').on('click', () => {
  2917. let arr = chatmsgs, str = "";
  2918. if(arr != null){
  2919. for(let i of arr.reverse()) str += `${new Date(i.time).toLocaleTimeString()} ${i.name}: ${i.message}\n`;
  2920. navigator.clipboard.writeText(str).then(function() {
  2921. curserMsg('Chat messages were successfully added to clipboard.', 'green');
  2922. }, function() {
  2923. curserMsg('Something went wrong. Nothing was added to your clipboard.', 'red');
  2924. });
  2925. }
  2926. $('#contextMenu').hide();
  2927. });
  2928. }
  2929.  
  2930.  
  2931.  
  2932. // add linesplit bubbles
  2933. $('body').append(`<div id="linesplit-markers"><div id="linesplit-top"></div><div id="linesplit-right"></div><div id="linesplit-bottom"></div><div id="linesplit-left"></div></div>`); // linesplit html
  2934. // add class to all elements that need to be hidden
  2935. setTimeout(() => $('#stats-container, #inventory, #chat, #minionUi, #infection_remain_zombie, #party, #challengeInfoBox, #gamemodeBox, #infoBox, #brGameContainer, #infGameContainer, #curser, #leaderboard, #minimap, #btnFriends, .innerBoxDashboard2, #fpsBox, #settingsBtn, #megaholder, #keyboard-layout, div[style^="position: fixed; right: 20px; bottom: 230px; z-index: 998;"], #linesplit_overlay, #fushykng, #art-panel').addClass("hideUI"), 4e3);
  2936.  
  2937. // apparently sora added delay to declining requests for some reason, so prob won't fix this feature
  2938. // const addFriendDecline = () => {
  2939. // if(!userPreferences.friendDeclineAll || currentUser == 'Please Login First') return;
  2940. // $('#friendAcceptAll').text('Reject All').addClass('fsfb-temp').clone().insertAfter($('#friendAcceptAll')).attr('style', 'right: 93px;').text('Accept All').removeClass('fsfb-temp');
  2941. // $('.fsfb-temp').attr('id', 'friendRejectAll').removeAttr('onclick').removeClass('fsfb-temp');
  2942. // $('#friendRejectAll').on('click', () => {
  2943. // $('#requestList>.friend>.btn-friends.remove').each(function(i){ $(this)[0].click() })
  2944. // });
  2945. // }
  2946.  
  2947. // if(userPreferences.friendDeclineAll){ // $('#friendAcceptAll').length
  2948. // $('#btnFriends').on('click', async() => {
  2949. // await waitUntil(() => $('#friendAcceptAll').length > 0);
  2950. // if($('#friendAcceptAll').length == 0) return;
  2951. // await sleep(50);
  2952. // addFriendDecline();
  2953. // })
  2954. // }
  2955.  
  2956. let pushFn = Array.prototype.push,
  2957. spliceFn = Array.prototype.splice,
  2958. prop = null,
  2959. specialCells = !0,
  2960. customDc = false,
  2961. cellProto,
  2962. avgFps = 0,
  2963. fpsArr = [],
  2964. svSwitch = false,
  2965. pubNameSwitch = false,
  2966. entArr = null,
  2967. chatmsgs,
  2968. hideMinionMaxSize = 80;
  2969.  
  2970. let r1Portal = {
  2971. portal: null,
  2972. lastMass: 0,
  2973. lastMassChange: 0,
  2974. lastValue: 0,
  2975. room: 1
  2976. }, r2Portal = {
  2977. portal: null,
  2978. lastMass: 0,
  2979. lastMassChange: 0,
  2980. lastValue: 0,
  2981. room: 2
  2982. };
  2983.  
  2984. let svInfo = {
  2985. "default": {
  2986. ejPortalMass: 12,
  2987. r1Id: 1,
  2988. r2Id: 7,
  2989. r3Id: null,
  2990. r1StartMass: 500,
  2991. r2StartMass: 500,
  2992. entities: [],
  2993. serverType: "normal"
  2994. },
  2995. 1: { // POPSPLIT
  2996. entities: [
  2997. // A1
  2998. {type: 1, x: 2500, y: 2500, size: 45},
  2999. // r1
  3000. {type: 0, x: 3400, y: 15300, size: 195},
  3001. {type: 1, x: 2500, y: 15000, size: 45},
  3002. {type: 2, x: 3000, y: 14500, size: 35},
  3003. {type: 3, x: 2700, y: 14600, size: 29},
  3004. // r2
  3005. {type: 0, x: 12000, y: 15500, size: 195},
  3006. {type: 1, x: 11000, y: 15000, size: 29},
  3007. {type: 2, x: 12600, y: 14900, size: 35},
  3008. {type: 2, x: 12000, y: 15200, size: 35},
  3009. {type: 2, x: 11300, y: 14900, size: 35},
  3010. {type: 3, x: 12800, y: 14500, size: 29}
  3011. ],
  3012. bots: 4
  3013. },
  3014. 2: { // SLOWSPLIT
  3015. ejPortalMass: 20,
  3016. r1Id: 1,
  3017. r2Id: 14, // rightmost portal
  3018. r3Id: 6,
  3019. r1StartMass: 500,
  3020. r2StartMass: 500,
  3021. entities: [
  3022. // A1
  3023. {type: 1, x: 2500, y: 2500, size: 45},
  3024. // r1
  3025. {type: 0, x: 7400, y: 21300, size: 195},
  3026. {type: 1, x: 3500, y: 21000, size: 45},
  3027. {type: 2, x: 5000, y: 20500, size: 35},
  3028. {type: 3, x: 3700, y: 20600, size: 29},
  3029. // r2
  3030. {type: 0, x: 14000, y: 22000, size: 195},
  3031. {type: 1, x: 11000, y: 21000, size: 29},
  3032. {type: 2, x: 11300, y: 20900, size: 35},
  3033. {type: 2, x: 12000, y: 21200, size: 35},
  3034. {type: 2, x: 12600, y: 20900, size: 35},
  3035. {type: 3, x: 12800, y: 20500, size: 29},
  3036. // r2 (2nd?)
  3037. {type: 0, x: 22000, y: 21500, size: 195},
  3038. {type: 2, x: 21300, y: 21000, size: 45}
  3039. ]
  3040. },
  3041. 3: { // Dodgeball NA
  3042. entities: [],
  3043. bots: 7
  3044. },
  3045. 4: { // FASTSPLIT
  3046. ejPortalMass: 20,
  3047. r1Id: 1,
  3048. r2Id: 14, // rightmost portal
  3049. r3Id: 6,
  3050. r1StartMass: 500,
  3051. r2StartMass: 500,
  3052. entities: [
  3053. // A1
  3054. {type: 1, x: 2500, y: 2500, size: 45},
  3055. // r1
  3056. {type: 0, x: 7400, y: 21300, size: 195},
  3057. {type: 1, x: 3500, y: 21000, size: 45},
  3058. {type: 2, x: 5000, y: 20500, size: 35},
  3059. {type: 3, x: 3700, y: 20600, size: 29},
  3060. // r2
  3061. {type: 0, x: 14000, y: 22000, size: 195},
  3062. {type: 1, x: 11000, y: 21000, size: 29},
  3063. {type: 2, x: 11300, y: 20900, size: 35},
  3064. {type: 2, x: 12000, y: 21200, size: 35},
  3065. {type: 2, x: 12600, y: 20900, size: 35},
  3066. {type: 3, x: 12800, y: 20500, size: 29},
  3067. // r2 (2nd?)
  3068. {type: 0, x: 22000, y: 21500, size: 195},
  3069. {type: 2, x: 21300, y: 21000, size: 35}
  3070. ],
  3071. bots: 1
  3072. },
  3073. 5: { // SPLITRUN
  3074. entities: [
  3075. // A1
  3076. {type: 1, x: 2500, y: 2500, size: 45},
  3077. // r1
  3078. {type: 0, x: 3400, y: 15300, size: 195},
  3079. {type: 1, x: 2500, y: 15000, size: 45},
  3080. {type: 2, x: 3000, y: 14500, size: 35},
  3081. {type: 3, x: 2700, y: 14600, size: 29},
  3082. // r2
  3083. {type: 0, x: 12000, y: 15500, size: 195},
  3084. {type: 1, x: 11000, y: 15000, size: 29},
  3085. {type: 2, x: 12600, y: 14900, size: 35},
  3086. {type: 2, x: 11300, y: 14900, size: 35},
  3087. {type: 2, x: 12000, y: 15200, size: 35},
  3088. {type: 3, x: 12800, y: 14500, size: 29}
  3089. ]
  3090. },
  3091. 6: { // XINSTA
  3092. ejPortalMass: 12,
  3093. r1Id: 1,
  3094. r2Id: 6,
  3095. r1StartMass: 500,
  3096. r2StartMass: 500,
  3097. entities: [
  3098. // A1
  3099. {type: 1, x: 2500, y: 2500, size: 45},
  3100. // r1
  3101. {type: 0, x: 3400, y: 26300, size: 195},
  3102. {type: 1, x: 2500, y: 26000, size: 45},
  3103. {type: 2, x: 3000, y: 25500, size: 45},
  3104. {type: 3, x: 2700, y: 25600, size: 29},
  3105. // r2
  3106. {type: 0, x: 15000, y: 26500, size: 195},
  3107. {type: 1, x: 14000, y: 26000, size: 29},
  3108. {type: 2, x: 14300, y: 25900, size: 45},
  3109. {type: 2, x: 15000, y: 26200, size: 45},
  3110. {type: 2, x: 15600, y: 25900, size: 45},
  3111. {type: 3, x: 15800, y: 25500, size: 29}
  3112. ], bots: 6
  3113. },
  3114. 7: { // XY
  3115. entities: [
  3116. // A1
  3117. {type: 1, x: 2500, y: 2500, size: 45},
  3118. // r1
  3119. {type: 0, x: 3400, y: 15300, size: 195},
  3120. {type: 1, x: 2500, y: 15000, size: 45},
  3121. {type: 2, x: 3000, y: 14500, size: 35},
  3122. {type: 3, x: 2700, y: 14600, size: 29},
  3123. // r2
  3124. {type: 0, x: 12000, y: 15500, size: 195},
  3125. {type: 1, x: 11000, y: 15000, size: 29},
  3126. {type: 2, x: 11300, y: 14900, size: 35},
  3127. {type: 2, x: 12000, y: 15200, size: 35},
  3128. {type: 2, x: 12600, y: 14900, size: 35},
  3129. {type: 3, x: 12800, y: 14500, size: 29}
  3130. ], bots: 5
  3131. },
  3132. 8: { // INSTANT EU
  3133. entities: [
  3134. // A1
  3135. {type: 1, x: 2500, y: 2500, size: 45},
  3136. // r1
  3137. {type: 0, x: 3400, y: 15300, size: 195},
  3138. {type: 1, x: 2500, y: 15000, size: 45},
  3139. {type: 2, x: 3000, y: 14500, size: 35},
  3140. {type: 3, x: 2700, y: 14600, size: 29},
  3141. // r2
  3142. {type: 0, x: 12000, y: 15500, size: 195},
  3143. {type: 1, x: 11000, y: 15000, size: 29},
  3144. {type: 2, x: 11300, y: 14900, size: 35},
  3145. {type: 2, x: 12000, y: 15200, size: 35},
  3146. {type: 2, x: 12600, y: 14900, size: 35},
  3147. {type: 3, x: 12800, y: 14500, size: 29}
  3148. ]
  3149. },
  3150. 9: { // CR EU
  3151. entities: [
  3152. // A1
  3153. {type: 1, x: 2500, y: 2500, size: 45},
  3154. // r1
  3155. {type: 0, x: 3400, y: 27300, size: 195},
  3156. {type: 1, x: 2500, y: 27000, size: 45},
  3157. {type: 2, x: 3000, y: 26500, size: 35},
  3158. {type: 3, x: 2700, y: 26600, size: 29},
  3159. // r2
  3160. {type: 0, x: 12000, y: 27500, size: 195},
  3161. {type: 1, x: 11000, y: 27000, size: 29},
  3162. {type: 2, x: 11300, y: 26900, size: 35},
  3163. {type: 2, x: 12000, y: 27200, size: 35},
  3164. {type: 2, x: 12600, y: 26900, size: 35},
  3165. {type: 3, x: 12800, y: 26500, size: 29}
  3166. ], bots: 8
  3167. },
  3168. 11: { // GIGANTIC 1
  3169. entities: [
  3170. {type: 1, x: 2500, y: 2500, size: 45},
  3171. {type: 3, x: 5000, y: 33000, size: 45},
  3172. {type: 1, x: 18000, y: 18000, size: 45},
  3173. {type: 3, x: 24000, y: 12000, size: 45}
  3174. ],
  3175. serverType: "gigantic"
  3176. },
  3177. 12: { // GIANT NA
  3178. entities: [
  3179. {type: 1, x: 2500, y: 2500, size: 45},
  3180. {type: 3, x: 5000, y: 33000, size: 45},
  3181. {type: 1, x: 18000, y: 18000, size: 45},
  3182. {type: 3, x: 24000, y: 12000, size: 45}
  3183. ],
  3184. serverType: "gigantic"
  3185. },
  3186. 13: { // SS EU
  3187. ejPortalMass: 13.5,
  3188. r1Id: 12, //Lower room
  3189. r2Id: 11,
  3190. r1StartMass: 500,
  3191. r2StartMass: 500,
  3192. entities: [
  3193. // r1
  3194. {type: 0, x: 1500, y: 27500, size: 195},
  3195. {type: 1, x: 14000, y: 32000, size: 45},
  3196. {type: 3, x: 13200, y: 33500, size: 45},
  3197. {type: 4, x: 12500, y: 32200, size: 142},
  3198. {type: 4, x: 14500, y: 32200, size: 142},
  3199. // r2
  3200. {type: 0, x: 16000, y: 33500, size: 195},
  3201. {type: 1, x: 500, y: 24000, size: 45},
  3202. {type: 3, x: 2500, y: 24000, size: 45},
  3203. {type: 4, x: 900, y: 22000, size: 142},
  3204. {type: 4, x: 500, y: 15000, size: 224},
  3205. // r3 (?)
  3206. {type: 4, x: 1200, y: 5500, size: 224},
  3207. {type: 4, x: 2000, y: 3000, size: 224},
  3208. {type: 4, x: 4000, y: 6000, size: 224},
  3209. {type: 4, x: 4500, y: 3000, size: 224},
  3210. // on map
  3211. {type: 4, x: 8000, y: 3500, size: 224},
  3212. {type: 4, x: 10000, y: 4500, size: 224},
  3213. {type: 4, x: 16000, y: 3000, size: 224},
  3214. {type: 4, x: 15400, y: 2400, size: 224},
  3215. {type: 4, x: 7500, y: 19000, size: 224},
  3216. {type: 4, x: 19200, y: 14000, size: 224},
  3217. {type: 4, x: 24400, y: 24000, size: 224},
  3218. {type: 4, x: 17500, y: 14000, size: 142},
  3219. {type: 4, x: 30000, y: 16000, size: 142}
  3220. ],
  3221. serverType: "supersonic"
  3222. },
  3223. 14: { // SS NA
  3224. ejPortalMass: 13.5,
  3225. r1Id: 12, //Lower room
  3226. r2Id: 11,
  3227. r1StartMass: 500,
  3228. r2StartMass: 500,
  3229. entities: [
  3230. // r1
  3231. {type: 0, x: 1500, y: 27500, size: 195},
  3232. {type: 1, x: 14000, y: 32000, size: 45},
  3233. {type: 3, x: 13200, y: 33500, size: 45},
  3234. {type: 4, x: 12500, y: 32200, size: 142},
  3235. {type: 4, x: 14500, y: 32200, size: 142},
  3236. // r2
  3237. {type: 0, x: 16000, y: 33500, size: 195},
  3238. {type: 1, x: 500, y: 24000, size: 45},
  3239. {type: 3, x: 2500, y: 24000, size: 45},
  3240. {type: 4, x: 900, y: 22000, size: 142},
  3241. {type: 4, x: 500, y: 15000, size: 224},
  3242. // r3 (?)
  3243. {type: 4, x: 1200, y: 5500, size: 224},
  3244. {type: 4, x: 2000, y: 3000, size: 224},
  3245. {type: 4, x: 4000, y: 6000, size: 224},
  3246. {type: 4, x: 4500, y: 3000, size: 224},
  3247. // on map
  3248. {type: 4, x: 8000, y: 3500, size: 224},
  3249. {type: 4, x: 10000, y: 4500, size: 224},
  3250. {type: 4, x: 16000, y: 3000, size: 224},
  3251. {type: 4, x: 15400, y: 2400, size: 224},
  3252. {type: 4, x: 7500, y: 19000, size: 224},
  3253. {type: 4, x: 19200, y: 14000, size: 224},
  3254. {type: 4, x: 24400, y: 24000, size: 224},
  3255. {type: 4, x: 17500, y: 14000, size: 142},
  3256. {type: 4, x: 30000, y: 16000, size: 142}
  3257. ],
  3258. serverType: "supersonic"
  3259. },
  3260. 16: { // BR NA
  3261. entities: [],
  3262. bots: 7
  3263. },
  3264. 17: { // CR AS
  3265. entities: [
  3266. // A1
  3267. {type: 1, x: 2500, y: 2500, size: 45},
  3268. // r1
  3269. {type: 0, x: 3400, y: 27300, size: 195},
  3270. {type: 1, x: 2500, y: 27000, size: 45},
  3271. {type: 2, x: 3000, y: 26500, size: 35},
  3272. {type: 3, x: 2700, y: 26600, size: 29},
  3273. // r2
  3274. {type: 0, x: 12000, y: 27500, size: 195},
  3275. {type: 1, x: 11000, y: 27000, size: 29},
  3276. {type: 2, x: 11300, y: 26900, size: 35},
  3277. {type: 2, x: 12000, y: 27200, size: 35},
  3278. {type: 2, x: 12600, y: 26900, size: 35},
  3279. {type: 3, x: 12800, y: 26500, size: 29}
  3280. ]
  3281. },
  3282. 18: { // GIGA 1
  3283. entities: [
  3284. {type: 1, x: 2500, y: 2500, size: 45},
  3285. {type: 3, x: 5000, y: 33000, size: 45},
  3286. {type: 1, x: 18000, y: 18000, size: 45},
  3287. {type: 3, x: 24000, y: 12000, size: 45}
  3288. ],
  3289. serverType: "gigantic"
  3290. },
  3291. 19: { // GIGANTIC 2
  3292. entities: [
  3293. {type: 1, x: 2500, y: 2500, size: 45},
  3294. {type: 3, x: 5000, y: 33000, size: 45},
  3295. {type: 1, x: 18000, y: 18000, size: 45},
  3296. {type: 3, x: 24000, y: 12000, size: 45}
  3297. ],
  3298. serverType: "gigantic"
  3299. },
  3300. 20: { // CR NA
  3301. entities: [
  3302. // A1
  3303. {type: 1, x: 2500, y: 2500, size: 45},
  3304. // r1
  3305. {type: 0, x: 3400, y: 27300, size: 195},
  3306. {type: 1, x: 2500, y: 27000, size: 45},
  3307. {type: 2, x: 3000, y: 26500, size: 35},
  3308. {type: 3, x: 2700, y: 26600, size: 29},
  3309. // r2
  3310. {type: 0, x: 12000, y: 27500, size: 195},
  3311. {type: 1, x: 11000, y: 27000, size: 29},
  3312. {type: 2, x: 11300, y: 26900, size: 35},
  3313. {type: 2, x: 12000, y: 27200, size: 35},
  3314. {type: 2, x: 12600, y: 26900, size: 35},
  3315. {type: 3, x: 12800, y: 26500, size: 29}
  3316. ]
  3317. },
  3318. 21: { // EU SF BR
  3319. entities: [],
  3320. bots: 7
  3321. },
  3322. 23: { // GIGANTIC 3
  3323. entities: [
  3324. {type: 1, x: 2500, y: 2500, size: 45},
  3325. {type: 3, x: 5000, y: 33000, size: 45},
  3326. {type: 1, x: 18000, y: 18000, size: 45},
  3327. {type: 3, x: 24000, y: 12000, size: 45}
  3328. ],
  3329. serverType: "gigantic"
  3330. },
  3331. 24: { // GIGANTIC 4
  3332. entities: [
  3333. {type: 1, x: 2500, y: 2500, size: 45},
  3334. {type: 3, x: 5000, y: 33000, size: 45},
  3335. {type: 1, x: 18000, y: 18000, size: 45},
  3336. {type: 3, x: 24000, y: 12000, size: 45}
  3337. ],
  3338. serverType: "gigantic"
  3339. },
  3340. 25: { // GIANT 2 NA
  3341. entities: [
  3342. {type: 1, x: 2500, y: 2500, size: 45},
  3343. {type: 3, x: 5000, y: 33000, size: 45},
  3344. {type: 1, x: 18000, y: 18000, size: 45},
  3345. {type: 3, x: 24000, y: 12000, size: 45}
  3346. ],
  3347. serverType: "gigantic"
  3348. },
  3349. 26: { // GIGA 2
  3350. entities: [
  3351. {type: 1, x: 2500, y: 2500, size: 45},
  3352. {type: 3, x: 5000, y: 33000, size: 45},
  3353. {type: 1, x: 18000, y: 18000, size: 45},
  3354. {type: 3, x: 24000, y: 12000, size: 45}
  3355. ],
  3356. serverType: "gigantic"
  3357. },
  3358. 37: { // MEGASPLIT EU
  3359. entities: [],
  3360. bots: 25
  3361. },
  3362. 38: { // Solo Agf
  3363. ejPortalMass: 12,
  3364. r1Id: 1,
  3365. r2Id: 6,
  3366. r1StartMass: 500,
  3367. r2StartMass: 400,
  3368. entities: [
  3369. // A1
  3370. {type: 1, x: 2500, y: 2500, size: 45},
  3371. // room 1
  3372. {type: 0, x: 3500, y: 11500, size: 195},
  3373. {type: 1, x: 2500, y: 11500, size: 45},
  3374. {type: 2, x: 3000, y: 11000, size: 35},
  3375. {type: 3, x: 2700, y: 11100, size: 29},
  3376. // room 2
  3377. {type: 0, x: 9000, y: 11800, size: 180},
  3378. {type: 1, x: 8200, y: 10500, size: 29},
  3379. {type: 2, x: 8300, y: 10900, size: 35},
  3380. {type: 2, x: 9000, y: 11200, size: 35},
  3381. {type: 2, x: 9600, y: 10900, size: 35},
  3382. {type: 3, x: 9800, y: 10500, size: 29}
  3383. ], bots: 9
  3384. },
  3385. 39: { // MEGASPLIT AS
  3386. entities: [
  3387. ],
  3388. bots: 12
  3389. },
  3390. 40: { // INFECTION EU
  3391. entities: [],
  3392. bots: 15
  3393. },
  3394. 41: { // INFECTION NA
  3395. entities: [],
  3396. bots: 20
  3397. },
  3398. 42: { // GIANT 3 NA
  3399. entities: [
  3400. {type: 1, x: 2500, y: 2500, size: 45},
  3401. {type: 3, x: 5000, y: 33000, size: 45},
  3402. {type: 1, x: 18000, y: 18000, size: 45},
  3403. {type: 3, x: 24000, y: 12000, size: 45}
  3404. ],
  3405. serverType: "gigantic"
  3406. },
  3407. 43: { // Instant AS
  3408. entities: [
  3409. // A1
  3410. {type: 1, x: 2500, y: 2500, size: 45},
  3411. // r1
  3412. {type: 0, x: 3400, y: 15300, size: 195},
  3413. {type: 1, x: 2500, y: 15000, size: 45},
  3414. {type: 2, x: 3000, y: 14500, size: 35},
  3415. {type: 3, x: 2700, y: 14600, size: 29},
  3416. // r2
  3417. {type: 0, x: 12000, y: 15500, size: 195},
  3418. {type: 1, x: 11000, y: 15000, size: 29},
  3419. {type: 2, x: 11300, y: 14900, size: 35},
  3420. {type: 2, x: 12000, y: 15200, size: 35},
  3421. {type: 2, x: 12600, y: 14900, size: 35},
  3422. {type: 3, x: 12800, y: 14500, size: 29}
  3423. ], bots: 3
  3424. }
  3425. };
  3426.  
  3427. let noPortalSvIdList = [11, 19, 23, 24, 37, 36, 31, 29, 40, 41, 16, 15, 21, 35, 12, 25, 42, 28, 32, 22, 18, 26, 30, 39];
  3428. let currentServerId = 0;
  3429.  
  3430. function getServerValue(value) {
  3431. return (svInfo[currentServerId] && svInfo[currentServerId][value]) ? svInfo[currentServerId][value] : svInfo.default[value]
  3432. }
  3433.  
  3434. try{
  3435. for(let { isCurrent, id } of JSON.parse(localStorage.gameservers)){
  3436. if(isCurrent) currentServerId = id;
  3437. }
  3438. } catch {console.warn("FSFB: Failed to grab current server id.")};
  3439.  
  3440. function setHideMinionSize() {
  3441. switch(getServerValue("serverType")){
  3442. case "gigantic":
  3443. hideMinionMaxSize = 120;
  3444. break;
  3445. case "supersonic":
  3446. hideMinionMaxSize = 150;
  3447. break;
  3448. case "normal":
  3449. hideMinionMaxSize = 80;
  3450. break;
  3451. default:
  3452. hideMinionMaxSize = 80;
  3453. break;
  3454. }
  3455. }
  3456. setHideMinionSize();
  3457.  
  3458. let ss = unsafeWindow.setserver;
  3459. unsafeWindow.setserver = (sv, sn) => {
  3460. playerAlive = false;
  3461. setHideMinionSize();
  3462. r1Portal.portal = null;
  3463. r2Portal.portal = null;
  3464. svSwitch = true;
  3465. ss(sv, sn);
  3466. if(sn) currentServerId = sn.includes('AS | Instant') ? 43 : +sv.match(/(?<=s)\d+(?=\.agma\.io)/gm)?.[0];
  3467. }
  3468.  
  3469. function createCell(posX, posY, type, nSize){
  3470. if(!cellProto) return null;
  3471.  
  3472. let color,
  3473. colorDimmed = "#FFFFFF",
  3474. size = 0,
  3475. imageId = 0,
  3476. spikes = null;
  3477.  
  3478. switch(type){
  3479. case 0:
  3480. color = "#622373";
  3481. colorDimmed = "#4e1c5c";
  3482. size = nSize ? nSize : 200;
  3483. imageId = 1;
  3484. break;
  3485. case 1:
  3486. color = "#ff0000";
  3487. colorDimmed = "#cc0001";
  3488. size = nSize ? nSize : 32;
  3489. spikes = {x: posX, y: posY, s: size, p: size};
  3490. imageId = 2;
  3491. break;
  3492. case 2:
  3493. color = "#76ff54";
  3494. colorDimmed = "#66b319";
  3495. size = nSize ? nSize : 35;
  3496. imageId = 3;
  3497. break;
  3498. case 3:
  3499. color = "#ffd000";
  3500. colorDimmed = "#ccb300";
  3501. size = nSize ? nSize : 32;
  3502. spikes = {x: posX, y: posY, s: size, p: size};
  3503. imageId = 4;
  3504. break;
  3505. case 4:
  3506. color = "#00a2e8";
  3507. colorDimmed = "#0081b9";
  3508. size = nSize ? nSize : 150;
  3509. imageId = 5;
  3510. break;
  3511. default:
  3512. color = "#FFFFFF";
  3513. size = 500;
  3514. };
  3515.  
  3516. let cell = new cellProto.constructor();
  3517.  
  3518. cell[prop[41]] = imageId;
  3519. cell[prop[19]] = null;
  3520. cell[prop[50]] = 0;
  3521. cell[prop[40]] = spikes ? 1 : 0;
  3522. cell[prop[26]] = null;
  3523. cell[prop[52]] = false;
  3524. cell[prop[53]] = false;
  3525. cell[prop[39]] = [];
  3526. cell[prop[57]] = 0;
  3527. cell[prop[45]] = false;
  3528. cell[prop[37]] = true;
  3529. cell[prop[24]] = null; // name cache
  3530. cell[prop[44]] = false;
  3531. cell[prop[56]] = false;
  3532. cell[prop[47]] = false;
  3533. cell[prop[25]] = null;
  3534. cell[prop[35]] = Date.now();
  3535. cell[prop[51]] = 0;
  3536. cell[prop[42]] = null;
  3537. cell.clanCache = null;
  3538. cell.clanPart = null;
  3539. cell.color = color;
  3540. cell[prop[46]] = 69;
  3541. cell[prop[38]] = spikes;
  3542. cell[prop[33]] = 1;
  3543. cell[prop[36]] = 0;
  3544. cell[prop[31]] = posX;
  3545. cell[prop[32]] = posY;
  3546. cell[prop[3]] = 0;
  3547. cell.id = 1e9;
  3548. cell[prop[21]] = null;
  3549. cell[prop[20]] = null;
  3550. cell.massCache = null;
  3551. cell[prop[11]] = size;
  3552. cell.nSize = size;
  3553. cell.name = null;
  3554. cell.namePart = null;
  3555. cell.nameSize = 0;
  3556. cell.oid = 0;
  3557. cell.ox = posX;
  3558. cell.oy = posY;
  3559. cell[prop[58]] = 0;
  3560. cell.rotation = 0;
  3561. cell.shape = 0;
  3562. cell.size = size;
  3563. cell.skinId = 0;
  3564. cell.strokeSize = size + 4;
  3565. cell.textDrawn = null;
  3566. cell.transform = null;
  3567. cell[prop[18]] = true;
  3568. cell[prop[2]] = colorDimmed ? colorDimmed : dimmColor(color);
  3569. cell[prop[17]] = null;
  3570. cell.x = posX;
  3571. cell[prop[23]] = null;
  3572. cell.y = posY;
  3573. cell[prop[22]] = null;
  3574. cell[prop[54]] = false;
  3575. cell[prop[34]] = Date.now();
  3576. cell[prop[55]] = true;
  3577. return cell;
  3578. }
  3579.  
  3580.  
  3581. const nameColors = {}, nameStrokes = {};
  3582.  
  3583. let nameToIdMap = {};
  3584. let defaultColorsAmnt = 1;
  3585. let colorIntComplete = false;
  3586. let addedNameColors = false;
  3587. let addedStrokeColors = false;
  3588.  
  3589. let FSFB_PRIV_CUSTOM_ERROR = false;
  3590.  
  3591. function contrastColor(hex){
  3592. let r = parseInt(hex.substring(1, 3), 16) / 255;
  3593. let g = parseInt(hex.substring(3, 5), 16) / 255;
  3594. let b = parseInt(hex.substring(5, 7), 16) / 255;
  3595.  
  3596. let max = Math.max(r, g, b), min = Math.min(r, g, b);
  3597. let h, s, l = (max + min) / 2;
  3598.  
  3599. if(max == min){
  3600. h = s = 0; // achromatic
  3601. } else {
  3602. let d = max - min;
  3603. s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
  3604. switch(max){
  3605. case r: h = (g - b) / d + (g < b ? 6 : 0); break;
  3606. case g: h = (b - r) / d + 2; break;
  3607. case b: h = (r - g) / d + 4; break;
  3608. }
  3609. h /= 6;
  3610. }
  3611.  
  3612. let adjustedLum = 0.2126 * r + 0.7152 * g + 0.0722 * b; // 0 == darkest black; 1 == lightest white
  3613. let lightChange = 0.5 - adjustedLum;
  3614.  
  3615. l += lightChange >= 0 ? Math.max(lightChange, 0.3) : Math.min(lightChange, -0.4); // very subtle difference but makes extreme colors more visible
  3616.  
  3617. return hslToHex(h * 360, s * 100, l * 100);
  3618. }
  3619.  
  3620. Object.defineProperty(Array.prototype, "fsfb_was_here", {
  3621. get: function () {
  3622. if(this[1] === "#FFD700"){
  3623. defaultColorsAmnt = this.length;
  3624. nameColors.get = () => this;
  3625. nameColors.add = color => this.push(color);
  3626. nameColors.set = (index, color) => void(this[index] = color);
  3627. addedNameColors = true;
  3628. nameColors?.get?.()?.length === defaultColorsAmnt && nameColors.add(settings.name_color[1].color);
  3629. return "#FFFFFF";
  3630. }
  3631. if(this[1] === "#5C4D00"){
  3632. nameStrokes.get = () => this;
  3633. nameStrokes.add = stroke => this.push(stroke);
  3634. nameStrokes.set = (index, color) => void(this[index] = color);
  3635. addedStrokeColors = true;
  3636. nameStrokes?.get?.()?.length === defaultColorsAmnt && nameStrokes.add(settings.name_color[2].active ? settings.name_color[2].color : contrastColor(settings.name_color[1].color));
  3637. return "#000000";
  3638. }
  3639. return "#FFFFFF"; // ¯\_(ツ)_/¯
  3640. }
  3641. });
  3642. function customize(c){
  3643. // customize cell stuff
  3644. cellProto = Object.getPrototypeOf(c);
  3645. uisdoa && (unsafeWindow.__cellProto = cellProto);
  3646. // this should stay independent unless sora changes the structure of cell class
  3647. const methods = [];
  3648. let a = c;
  3649. while (a = Reflect.getPrototypeOf(a)) {
  3650. const keys = Reflect.ownKeys(a);
  3651. keys.forEach((k) => methods.push(k));
  3652. }
  3653.  
  3654. let dc_fn_name = methods[7];
  3655. let dc = cellProto[dc_fn_name];
  3656. Object.defineProperty(cellProto, '_drCl', { value: dc });
  3657. Object.defineProperty(cellProto, dc_fn_name, { value: function(){
  3658. if(!customCells && !customCellsChanged && !antilagCells) return dc.apply(this, arguments);
  3659.  
  3660. let cell = this,
  3661. cT = cell.c$,
  3662. cellColor = cell.color;
  3663.  
  3664.  
  3665. if (antilagCells && (cT === 0 || cT === 3) &&
  3666. (settings.anti_lag[0].active && cell[prop[52]] && cell.nSize <= hideMinionMaxSize) ||
  3667. (cT === 3 && (settings.anti_lag[2].active || (settings.anti_lag[3].active && !cell[prop[37]])) && cell.color !== "#000101")){
  3668. return (cell.hidden = true);
  3669. } else if(cell.hidden){
  3670. cell.hidden = false;
  3671. }
  3672.  
  3673. if(cT === 0 && !('oType' in cell)){ // second makes sure that the type wasnt changed to playerCell (mothercell showmass)
  3674. // * --- name color --- *
  3675. if(!addedNameColors || !addedStrokeColors){
  3676. cell.oNameColorId = cell[prop[51]];
  3677. cell[prop[51]] = "fsfb_was_here";
  3678. } else if(!colorIntComplete && cell[prop[51]] === "fsfb_was_here"){
  3679. cell[prop[51]] = cell.oNameColorId;
  3680. colorIntComplete = true; // MIGHT be problematic w current implementation but can worry ab later
  3681. }
  3682. if(addedNameColors && addedStrokeColors && (pubNameSwitch || settings.name_color[0].active) && !cell[prop[52]] && / (?:\W{3}|\W{6}) /gmi.test(cell?.clanPart)){
  3683. let supposedColorId = nameToIdMap?.[cell.clanPart];
  3684. if(pubNameSwitch && decodeCustomNameColor(cell.clanPart, 0) != null){
  3685. // TODO: To get actual color check which box is active (getting by property is more complicated)
  3686. cell[prop[51]] = 0; //cell.oNameColorId; // ? atm reverts to 0
  3687. } else if(supposedColorId){
  3688. cell[prop[51]] = supposedColorId;
  3689. } else {
  3690. let color_id = decodeCustomNameColor(cell.clanPart, 0);
  3691. let stroke_id = decodeCustomNameColor(cell.clanPart, 1);
  3692. let brevName = cell.clanPart.length === 5;
  3693. if(color_id != null && (brevName || stroke_id != null)){
  3694. nameToIdMap = {...nameToIdMap, ...{[cell.clanPart]: nameColors.get().length}}
  3695.  
  3696. if(cell[prop[51]] < defaultColorsAmnt){
  3697. cell.oNameColorId = cell[prop[51]];
  3698. }
  3699.  
  3700. cell[prop[51]] = nameColors.get().length;
  3701.  
  3702. nameColors.add(getColorById(color_id));
  3703. nameStrokes.add(brevName ? contrastColor(getColorById(color_id)) : getColorById(stroke_id));
  3704. };
  3705. }
  3706. }
  3707.  
  3708.  
  3709. if(cell[prop[52]]){
  3710. if(settings.anti_lag[1].active){
  3711. cell[prop[18]] = false;
  3712. }
  3713. }
  3714. if(settings.theme_boxes[1].active){
  3715. if(!('oOwnCell' in cell)) cell.oOwnCell = cell[prop[45]];
  3716. cell[prop[45]] = true;
  3717. }
  3718.  
  3719. if(settings.theme_boxes[6].active){
  3720. if(!('oSpiked' in cell)) cell.oSpiked = cell[prop[56]];
  3721. cell[prop[56]] = settings.theme_boxes[6].active;
  3722. } else if('oSpiked' in cell){
  3723. cell[prop[56]] = cell.oSpiked;
  3724. }
  3725.  
  3726.  
  3727. if(onlyCells || customCellsChanged){
  3728. if(!settings.name_color[0].active && (userPreferences.rainbowNameColor || settings.name_color[1].active) && addedNameColors && addedStrokeColors && (!("oOwnCell" in cell) ? cell[prop[45]] : cell.oOwnCell)){
  3729. if(nameColors.get().length > defaultColorsAmnt){
  3730. if(userPreferences.rainbowNameColor){
  3731. const color = hslToHex(Math.floor(Date.now() / userPreferences.rainbowNameSpeed + 180) % 360, 100, 50);
  3732. nameColors.set(defaultColorsAmnt, color);
  3733. nameStrokes.set(defaultColorsAmnt, dimmColor(color));
  3734. }
  3735. cell[prop[51]] = defaultColorsAmnt;
  3736. } else {
  3737. // error
  3738. if(!FSFB_PRIV_CUSTOM_ERROR) (FSFB_PRIV_CUSTOM_ERROR = true) && console.error("fsfb error, private custom name color not functioning correctly!", nameColors.length);
  3739. cell[prop[51]] = 0;
  3740. }
  3741. // cell[prop[51]] = defaultColorsAmnt;// -> this fails when no color is put in the array!!!
  3742. }
  3743. if(settings.theme_boxes[2].active){
  3744. if(!('oHasImage' in cell)) cell.oHasImage = cell[prop[18]];
  3745. cell[prop[18]] = (!("oOwnCell" in cell) ? cell[prop[45]] : cell.oOwnCell) ? cell[prop[18]] : false;
  3746.  
  3747. } else if(settings.theme_boxes[3].active){
  3748. if(!('oHasImage' in cell)) cell.oHasImage = cell[prop[18]];
  3749. cell[prop[18]] = cell[prop[45]] || cell[prop[53]] ? cell[prop[18]] : false;
  3750.  
  3751. } else if('oHasImage' in cell){
  3752. cell[prop[18]] = cell.oHasImage;
  3753. }
  3754.  
  3755. if(settings.theme_boxes[4].active){
  3756. if(!('oName' in cell)) cell.oName = cell.name;
  3757. cell.name = (!("oOwnCell" in cell) ? cell[prop[45]] : cell.oOwnCell) ? cell.name : "";
  3758.  
  3759. } else if(settings.theme_boxes[5].active){
  3760. if(!('oName' in cell)) cell.oName = cell.name;
  3761. cell.name = cell[prop[45]] || cell[prop[53]] ? cell.name : "";
  3762.  
  3763. } else if('oName' in cell){
  3764. cell.name = cell.oName;
  3765. }
  3766. }
  3767. } else if(cT === 1){
  3768. if(!('oSize' in cell)) cell.oSize = cell.nSize; // food normally doesnt have an oSize; ensures that mothercell food is correct
  3769. if(foodSizeOn){
  3770. cell.nSize = cell.oSize * settings.uiScaling[1].level;
  3771. cell.size = cell.oSize * settings.uiScaling[1].level;
  3772. } else if(customCellsChanged) {
  3773. cell.size = cell.oSize;
  3774. cell.nSize = cell.oSize;
  3775. }
  3776. if(settings.theme[0].active){
  3777. if(!('oColor' in cell)) cell.oColor = cell.color;
  3778. cell.color = settings.theme[0].color;
  3779. } else if('oColor' in cell){
  3780. cell.color = cell.oColor;
  3781. }
  3782. } else if(cT === 2){
  3783. if(settings.theme[1].active){
  3784. if(!('oColor' in cell)) cell.oColor = cell.color;
  3785. cell.color = settings.theme[1].color;
  3786. } else if('oColor' in cell){
  3787. cell.color = cell.oColor;
  3788. }
  3789. if(settings.theme[1].active || settings.theme[2].active){ // dimmed color / stroke
  3790. if(!('oColorDimmed' in cell)) cell.oColorDimmed = cell[prop[2]];
  3791. cell[prop[2]] = settings.theme[2].active ? settings.theme[2].color : settings.theme_boxes[0].active && agmaSettings.sBubbleCells ? settings.theme[1].color : dimmColor(settings.theme[1].color); // if no stroke color is set, it will just be a darker version of the virusColor
  3792. } else if('oColorDimmed' in cell){
  3793. cell[prop[2]] = cell.oColorDimmed;
  3794. }
  3795. } else if(cT === 9){
  3796. if(settings.theme[3].active){
  3797. if(!('oColor' in cell)) cell.oColor = cell.color;
  3798. cell.color = settings.theme[3].color;
  3799. } else if('oColor' in cell){
  3800. cell.color = cell.oColor;
  3801. }
  3802. if(settings.theme[3].active || settings.theme[4].active){ // dimmed color / stroke
  3803. if(!('oColorDimmed' in cell)) cell.oColorDimmed = cell[prop[2]];
  3804. cell[prop[2]] = settings.theme[4].active ? settings.theme[4].color : settings.theme_boxes[0].active && agmaSettings.sBubbleCells ? settings.theme[3].color : dimmColor(settings.theme[3].color);
  3805. } else if('oColorDimmed' in cell){
  3806. cell[prop[2]] = cell.oColorDimmed;
  3807. }
  3808.  
  3809. if(settings.checkboxes[9].active){
  3810. cell[prop[46]] = 0;
  3811. cell.oType = 9;
  3812. cell[prop[45]] = true;
  3813. cell.oOwnCell = false;
  3814. dc.apply(this, arguments);
  3815. cell[prop[46]] = 9;
  3816. return;
  3817. }
  3818. }
  3819. return dc.apply(this, arguments);
  3820. }});
  3821.  
  3822.  
  3823. Object.defineProperty(cellProto, prop[46], {
  3824. get: function() {
  3825. return this.c$;
  3826. },
  3827. set: function(val) {
  3828. if((val === 0 || val === 3) && this.color === "#000000"){
  3829. this.color = "#000101";
  3830. } else if(val === 0 && this.color === "#622373"){
  3831. this.color = "#622374"; // give purple cells a slightly diff color to make them detectable in .stroke fn
  3832. }
  3833. this.c$ = val;
  3834. }
  3835. });
  3836.  
  3837. customDc = true;
  3838. }
  3839.  
  3840. function dimmColor(color) {
  3841. var r = (Math.floor(parseInt(color.substring(1, 3), 16) * 0.5)).toString(16),
  3842. g = (Math.floor(parseInt(color.substring(3, 5), 16) * 0.5)).toString(16),
  3843. b = (Math.floor(parseInt(color.substring(5, 7), 16) * 0.5)).toString(16);
  3844. if (r.length === 1) r = "0" + r;
  3845. if (g.length === 1) g = "0" + g;
  3846. if (b.length === 1) b = "0" + b;
  3847. return "#" + r + g + b
  3848. }
  3849.  
  3850. const newSortFunc = function(oldFunc){
  3851. if(settings.theme_boxes[8].active){
  3852. return function(a, b){
  3853. const oldFuncApplied = oldFunc.apply(this, arguments),
  3854. aVal = a.c$,
  3855. bVal = b.c$;
  3856. return ((settings.theme_boxes[7].active ? -oldFuncApplied : oldFuncApplied) > 0 || aVal === 4) && bVal !== 4 ? 1 : aVal === 4 && bVal === 4 ? 0 : -1;
  3857. }
  3858. } else if(settings.theme_boxes[7].active){
  3859. return function(a, b){
  3860. return -oldFunc.apply(this, arguments);
  3861. }
  3862. } else {
  3863. return oldFunc;
  3864. }
  3865. }
  3866.  
  3867. const _sort = Array.prototype.sort;
  3868. Array.prototype.sort = function(oldFunc) {
  3869. return oldFunc == null || typeof this[0]?.color !== "string" ? _sort.apply(this, arguments) : _sort.call(this, newSortFunc(oldFunc));
  3870. }
  3871.  
  3872. // translate megaphone shouts
  3873. let shouts = [];
  3874.  
  3875. var jqueryAnimate = $.fn.animate;
  3876. $.fn.animate = function(){
  3877. if(arguments?.[0]?.["margin-right"] === "10px"){
  3878. // shout event
  3879. //console.log("shout");
  3880. (async () => {
  3881. let megaphoneText = $("#megaphone_text").text();
  3882. let translatedText = await Request(megaphoneText, settings.chat_translate[3].set, settings.chat_translate[4].set); // use same languages as chat
  3883.  
  3884. let name = $("#megaphone_name").text(),
  3885. color = $("#megaphone_name").css("color");
  3886. let isTournament = color == 'rgb(255, 153, 34)' && name == 'Tournament';
  3887. let isModerator = color == 'rgb(128, 0, 128)' && name == 'Friendly';
  3888.  
  3889. shouts.push({
  3890. name: $("#megaphone_name").text(),
  3891. message: megaphoneText,
  3892. messageTranslated: translatedText || "FSFB: Translation failed.",
  3893. time: Date.now(),
  3894. isShout: true, // dont translate again in push intercept... lol
  3895. isTournament: isTournament,
  3896. isModerator: isModerator
  3897. })
  3898. })();
  3899. }
  3900. return jqueryAnimate.apply(this, arguments);
  3901. };
  3902.  
  3903. // translation
  3904.  
  3905. var UA = navigator.userAgent;
  3906. var googleDomain = "translate.google.com";
  3907. var dictURL = "https://" + googleDomain + "/translate_a/single?client=t";
  3908.  
  3909. function init_google_value_tk() {
  3910. var url = "https://" + googleDomain + "/translate_a/element.js";
  3911. GM_xmlhttpRequest({
  3912. method: "GET",
  3913. url: url,
  3914. onreadystatechange: function(resp) {
  3915. if (resp.readyState == 4) {
  3916. clearTimeout(setTimeout(function() {
  3917. this.abort();
  3918. }, 2000));
  3919. if (resp.status == 200) {
  3920. init_google_value_tk_parse(resp.responseText);
  3921. }
  3922. }
  3923. }
  3924. });
  3925. }
  3926.  
  3927. function init_google_value_tk_parse(responseText) {
  3928. var res = /c\._ctkk='(.+?)'/i.exec(responseText);
  3929. if (res != null) {
  3930. setStorage('google_value_tk', res[1]);
  3931. };
  3932. }
  3933.  
  3934. const Request = async(txt, sl = 'auto', tl = 'auto') => {
  3935. return new Promise((resolve, reject) => {
  3936. function parse(gTradStringArray) {
  3937. var arr = JSON.parse(gTradStringArray);
  3938. var translation = '';
  3939. for (let i = 0; i < arr[0].length; i++) {
  3940. if (typeof arr[0][i][0] != 'undefined' && arr[0][i][0] != null) translation += arr[0][i][0];
  3941. }
  3942. resolve(translation);
  3943. }
  3944. var tk = googleTK(txt);
  3945. var Url = dictURL +
  3946. "&hl=auto" +
  3947. "&sl=" + sl + "&tl=" + tl +
  3948. "&dt=bd&dt=ex&dt=ld&dt=md&dt=qca&dt=rw&dt=rm&dt=ss&dt=t&dt=at&ie=UTF-8&oe=UTF-8&otf=2&trs=1&inputm=1&ssel=0&tsel=0&source=btn&kc=3" +
  3949. "&tk=" + tk +
  3950. "&q=" + encodeURI(txt);
  3951. var method = 'POST';
  3952. var Data = '';
  3953. var Hdr = {
  3954. "User-Agent": UA,
  3955. "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
  3956. "Accept-Encoding": "gzip, deflate"
  3957. }
  3958. var Q = Url.split('&q=');
  3959. Url = Q[0];
  3960. Data = '&q=' + Q[1];
  3961. Hdr["Content-Length"] = Data.length + '';
  3962. Hdr["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8";
  3963. GM_xmlhttpRequest({
  3964. method: method,
  3965. url: Url,
  3966. data: Data,
  3967. headers: Hdr,
  3968. onload: function(resp) {
  3969. try {
  3970. parse(resp.responseText)
  3971. } catch (e) {
  3972. unsafeWindow.fsfbLogTranslateErrors && console.error("FSFB:", e);
  3973. resolve(null);
  3974. }
  3975. }
  3976. });
  3977. });
  3978. }
  3979.  
  3980. let dURIC = unsafeWindow.decodeURIComponent,
  3981. opt = [0x92933AFC, 0x75408D32];
  3982. unsafeWindow.decodeURIComponent = function(x){
  3983. if(x === "") x = opt[Math.round(Math.random())].toString();
  3984. return dURIC(x);
  3985. }
  3986.  
  3987. // return token for the new API
  3988. function googleTK(text) {
  3989. // view-source:https://translate.google.com/translate/releases/twsfe_w_20160620_RC00/r/js/desktop_module_main.js && TKK from HTML
  3990. var uM = getStorage('google_value_tk');
  3991. if (uM == 'undefined' || uM == null) {
  3992. init_google_value_tk();
  3993. uM = "427110.1469889687";
  3994. } else if (Number(uM.split('.')[0]) !== Math.floor(Date.now() / 3600000)) {
  3995. init_google_value_tk();
  3996. };
  3997. var cb = "&";
  3998. var k = "";
  3999. var Gf = "=";
  4000. var Vb = "+-a^+6";
  4001. var t = "a";
  4002. var Yb = "+";
  4003. var Zb = "+-3^+b+-f";
  4004. var jd = ".";
  4005. var sM = function(a) {
  4006. return function() {
  4007. return a
  4008. }
  4009. }
  4010. var tM = function(a, b) {
  4011. for (var c = 0; c < b.length - 2; c += 3) {
  4012. let d = b.charAt(c + 2);
  4013. d = d >= t ? d.charCodeAt(0) - 87 : Number(d);
  4014. d = b.charAt(c + 1) == Yb ? a >>> d : a << d;
  4015. a = b.charAt(c) == Yb ? a + d & 4294967295 : a ^ d
  4016. }
  4017. return a
  4018. };
  4019. var vM = function(a) {
  4020. var b;
  4021. if (null !== uM) {
  4022. b = uM;
  4023. } else {
  4024. b = sM(String.fromCharCode(84));
  4025. var c = sM(String.fromCharCode(75));
  4026. b = [b(), b()];
  4027. b[1] = c();
  4028. b = (uM = unsafeWindow[b.join(c())] || k) || k
  4029. }
  4030. let d = sM(String.fromCharCode(116));
  4031. c = sM(String.fromCharCode(107));
  4032. d = [d(), d()];
  4033. d[1] = c();
  4034. c = cb + d.join(k) + Gf;
  4035. d = b.split(jd);
  4036. b = Number(d[0]) || 0;
  4037.  
  4038. for (var e = [], f = 0, g = 0; g < a.length; g++) {
  4039. var m = a.charCodeAt(g);
  4040. 128 > m ? e[f++] = m : (2048 > m ? e[f++] = m >> 6 | 192 : (55296 == (m & 64512) && g + 1 < a.length && 56320 == (a.charCodeAt(g + 1) & 64512) ? (m = 65536 + ((m & 1023) << 10) + (a.charCodeAt(++g) & 1023), e[f++] = m >> 18 | 240, e[f++] = m >> 12 & 63 | 128) : e[f++] = m >> 12 | 224, e[f++] = m >> 6 & 63 | 128), e[f++] = m & 63 | 128)
  4041. }
  4042. a = b || 0;
  4043. for (f = 0; f < e.length; f++) {
  4044. a += e[f];
  4045. a = tM(a, Vb);
  4046. };
  4047. a = tM(a, Zb);
  4048. a ^= Number(d[1]) || 0;
  4049. 0 > a && (a = (a & 2147483647) + 2147483648);
  4050. a %= 1E6;
  4051. return a.toString() + jd + (a ^ b);
  4052. };
  4053. return vM(text);
  4054. }
  4055.  
  4056. let skinsArr, translatedCache = {}, entsAdded = false, addChatMsg;
  4057.  
  4058. Array.prototype.push = function(){
  4059. if(this?.length && typeof this?.[0]?.approved === 'boolean' && typeof this?.[0]?.type === 'number' && typeof this?.[0]?.zIndex === 'undefined') skinsArr = this;
  4060. if(this?.length && typeof this?.[0]?.id === "number" && typeof this?.[0]?.color === "string"){
  4061. // if(customCells){
  4062. let cell = this[this.length - 1],
  4063. [pushedCell] = arguments;
  4064. if(!prop){
  4065. prop = Object.keys(cell);
  4066. uisdoa && (unsafeWindow.__prop = Object.keys(cell));
  4067. if(prop.length != 59 || prop[28] != "massCache"){
  4068. console.error("FSFB Scripts error, contact authors: ", prop.length, prop[28]);
  4069. }
  4070. }
  4071. if((pushedCell[prop[36]] && settings.anti_lag[4].active) || (settings.anti_lag[0].active && pushedCell.hidden)) return;
  4072.  
  4073. if(pushedCell.id === getServerValue("r1Id")){
  4074. r1Portal.portal = pushedCell;
  4075. } else if(pushedCell.id === getServerValue("r2Id")){
  4076. r2Portal.portal = pushedCell;
  4077. }
  4078. !customDc && customize(cell);
  4079.  
  4080. if(entsAdded && !settings.checkboxes[8].active){
  4081. for(let i = this.length - 1; i >= 0; --i) {
  4082. if(this[i].id == 1e9){
  4083. this.splice(i, 1);
  4084. entsAdded = false;
  4085. }
  4086. }
  4087. }
  4088. if((svSwitch || !entsAdded) && settings.checkboxes[8].active && this[0][prop[47]] && this.length > 1){
  4089. for(let i = 0; i < getServerValue("entities").length; i++){
  4090. let ent = getServerValue("entities")[i];
  4091. pushFn.apply(this, [createCell(ent.x, ent.y, ent.type, ent.size)]);
  4092. }
  4093. svSwitch = false;
  4094. entsAdded = true;
  4095. }
  4096. }
  4097.  
  4098. let applied = pushFn.apply(this, arguments);
  4099. if(!(arguments[0]?.isShout) && this?.length && typeof this?.[0]?.message === 'string' && typeof this?.[0]?.name === 'string'){ //&& typeof this?.[0]?.goldMember === 'number' && typeof this?.[0]?.cache === 'object'){
  4100. chatmsgs = this;
  4101. if(arguments[0]?.message && !/[youaie](?!.: )/gmi.test(arguments[0].message)) Object.entries(cmap).forEach(([key, val]) => (arguments[0].message = arguments[0].message.replace(new RegExp(val, 'g'), key)));
  4102. if(userPreferences.removeColorTagsInChat && /^\[(?:\W{3}|\W{6})\]/gmi.test(arguments[0].name) && decodeCustomNameColor(...arguments[0].name.match(/^\[(?:\W{3}|\W{6})\]/gmi), 0) != null) {
  4103. arguments[0].name = arguments[0].name.replace(/^\[(?:\W{3}|\W{6})\]/gmi, '');
  4104. }
  4105. (async() => {
  4106. if(settings.chat_translate[0].active && (settings.chat_translate[1].active || arguments[0][Object.keys(arguments[0])[0]])){
  4107. let originalMsg = arguments[0]?.untranslated ?? arguments[0].message,
  4108. translatedMsg = translatedCache[settings.chat_translate[3].set + settings.chat_translate[4].set]?.[originalMsg] ?? await Request(originalMsg, settings.chat_translate[3].set, settings.chat_translate[4].set);
  4109. if(translatedMsg != null) translatedCache[settings.chat_translate[3].set + settings.chat_translate[4].set] = {...translatedCache[settings.chat_translate[3].set + settings.chat_translate[4].set], ...{[originalMsg] : translatedMsg}};
  4110. if((!('untranslated' in arguments[0]) || arguments[0].translatedLang != settings.chat_translate[3].set + settings.chat_translate[4].set || arguments[0].showingOrig != settings.chat_translate[2].active) && arguments[0]?.message && translatedMsg != null){
  4111. setTimeout(() => {
  4112. arguments[0].untranslated = originalMsg;
  4113. arguments[0].translatedLang = settings.chat_translate[3].set + settings.chat_translate[4].set;
  4114. arguments[0].showingOrig = settings.chat_translate[2].active;
  4115. arguments[0].message = settings.chat_translate[2].active ? originalMsg + ' [ ' + translatedMsg + ' ]' : translatedMsg;
  4116. arguments[0].filter = false;
  4117. arguments[0].cache = null;
  4118. }, 0);
  4119. }
  4120. } else { // change translate off
  4121. if('untranslated' in arguments[0] && arguments[0]?.untranslated != arguments[0].message){
  4122. setTimeout(() => {
  4123. arguments[0].message = arguments[0]?.untranslated;
  4124. arguments[0].translatedLang = 'none';
  4125. arguments[0].filter = false;
  4126. arguments[0].cache = null;
  4127. }, 0);
  4128. }
  4129. }
  4130.  
  4131. // addChatMsg = msg => {
  4132. // if(!Array.isArray(this)) return void(console.error('fsfb: no array ):'));
  4133. // pushFn.call(this, msg);
  4134. // }
  4135. })();
  4136. }
  4137. return applied;
  4138. }
  4139. Array.prototype.splice = function(){
  4140. if(customCells && this.length && typeof this[0].id == "number" && typeof this[0].color == "string"){
  4141. let cell = this[arguments[0]];
  4142. if(cell == r1Portal.portal){
  4143. r1Portal.portal = null;
  4144. } else if(cell == r2Portal.portal){
  4145. r2Portal.portal = null;
  4146. }
  4147. }
  4148. return spliceFn.apply(this, arguments);
  4149. }
  4150.  
  4151.  
  4152. const brSetting = settings.theme[6];
  4153. const _fillStyleSetter = Object.getOwnPropertyDescriptor(CanvasRenderingContext2D.prototype, 'fillStyle').set;
  4154.  
  4155. Object.defineProperty(CanvasRenderingContext2D.prototype, 'fillStyle', {
  4156. set: function(newFillStyle) {
  4157. if(brSetting.active
  4158. && newFillStyle === '#CC3030'){
  4159. newFillStyle = userPreferences.rainbowBrHazard ? hslToHex(Math.floor(Date.now() / userPreferences.rainbowBrHazardSpeed) % 360, 100, 50) : brSetting.color;
  4160. } else if(userPreferences.whiteBorder4BlackCells && newFillStyle === "#000101"){
  4161. this.strokeStyle = "#FFFFFF";
  4162. this.lineWidth = 12;
  4163. this.stroke();
  4164. }
  4165. _fillStyleSetter.call(this, newFillStyle);
  4166. }
  4167. });
  4168.  
  4169.  
  4170. const fillFn = CanvasRenderingContext2D.prototype.fill;
  4171. CanvasRenderingContext2D.prototype.fill = function() {
  4172. if(!fillCells) return fillFn.apply(this, arguments);
  4173. const { globalAlpha } = this;
  4174. let doStroke = true;
  4175. if(globalAlpha === .04){
  4176. switch(this.fillStyle){
  4177. case "#ff0000": // rec
  4178. this.strokeStyle = "#cc0001";
  4179. break;
  4180. case "#76ff54": // grw
  4181. this.strokeStyle = "#66b319";
  4182. break;
  4183. case "#ffd000": // spd
  4184. this.strokeStyle = "#ccb300";
  4185. break;
  4186. case "#00a2e8": // min pack
  4187. this.strokeStyle = "#0081b9";
  4188. break;
  4189. case "#622373": // portal
  4190. this.strokeStyle = "#4e1c5c";
  4191. break;
  4192. default:
  4193. doStroke = false;
  4194. };
  4195. if(doStroke){
  4196. this.globalAlpha = uisdoa?.o ?? .2;
  4197. this.lineWidth = 8;
  4198. this.stroke();
  4199. this.globalAlpha = uisdoa?.oo ?? .1;
  4200. this.shadowOffsetY = 1; // for f#&%ing curser lock
  4201. }
  4202. };
  4203. if(!doStroke && globalAlpha === 0.04 && settings.checkboxes[2].active){
  4204. this.strokeStyle = agmaSettings.sDark ? "#FFFFFF" : "#000000";
  4205. this.globalAlpha = 1;
  4206. this.lineWidth = 30;
  4207. this.stroke();
  4208. this.globalAlpha = 0.04;
  4209. } else if (globalAlpha === .4 && settings.theme_boxes[0].active) {
  4210. this.globalAlpha = 0.15
  4211. }
  4212. return fillFn.apply(this, arguments)
  4213. }
  4214. const strokeFn = CanvasRenderingContext2D.prototype.stroke;
  4215. CanvasRenderingContext2D.prototype.stroke = function() {
  4216. if (strokeCells && this.canvas.id === "canvas") {
  4217. const { strokeStyle } = this;
  4218. if (strokeStyle === "#dddddd" || strokeStyle === "#333333" || strokeStyle === "#4e1c5b" /* adjusted portal cell stroke color*/) {
  4219. if(settings.checkboxes[2].active) this.strokeStyle = agmaSettings.sDark ? "#FFFFFF" : "#000000";
  4220. if(this.shadowOffsetY == 1){
  4221. this.shadowOffsetY = 0;
  4222. return;
  4223. };
  4224. };
  4225. if (agmaSettings.sBubbleCells && settings.theme_boxes[0].active && this.lineWidth != 4) {
  4226. this.lineWidth = 15 + Math.min(Math.max(avgFps - 25, 0), 10);
  4227. }
  4228. }
  4229. return strokeFn.apply(this, arguments)
  4230. }
  4231.  
  4232. let drawImgFn = CanvasRenderingContext2D.prototype.drawImage;
  4233. CanvasRenderingContext2D.prototype.drawImage = function () {
  4234. if(this.globalAlpha === 0.01 && /ects\/[1-5](?:_lo)?\.p/.test(arguments[0]?.src)){
  4235. this.globalAlpha = .35;
  4236. }
  4237. drawImgFn.apply(this, arguments);
  4238. if(settings.checkboxes[7].active && this.canvas.id === "canvas"){
  4239. if((r1Portal.portal || r2Portal.portal) && !noPortalSvIdList.includes(currentServerId) && /ects\/1(?:_lo)?\./.test(arguments[0].src)){ // using destroyed doesnt work hence splice
  4240. let c = p => {
  4241. if((p.portal.nSize * p.portal.nSize / 100) != p.lastMass){
  4242. p.lastMassChange = Date.now();
  4243. }
  4244. p.lastMass = (p.portal.nSize * p.portal.nSize / 100);
  4245.  
  4246. let value = Date.now() - p.lastMassChange > 200 ? ~~(((p.portal.nSize * p.portal.nSize / 100) - getServerValue("r" + p.room + "StartMass")) / getServerValue("ejPortalMass")).toString() : p.lastValue;
  4247. p.lastValue = value;
  4248. if(value > 9 || value < 0){
  4249. value = "?";
  4250. }
  4251. this.fillStyle = value == "7" ? "#FFCC12" : "#FFFFFF";
  4252. this.globalAlpha = 1;
  4253. this.font = "72px Ubuntu, serif";
  4254. this.fillText(value, p.portal.x - this.measureText(value).width / 2, p.portal.y + 20);
  4255. }
  4256. r1Portal.portal && c(r1Portal);
  4257. r2Portal.portal && c(r2Portal);
  4258. // }
  4259. }
  4260. }
  4261. }
  4262.  
  4263.  
  4264. function hue2rgb(p, q, t){
  4265. if (t < 0) t += 1;
  4266. if (t > 1) t -= 1;
  4267. if (t < 1 / 6) return p + (q - p) * 6 * t;
  4268. if (t < 1 / 2) return q;
  4269. if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;
  4270. return p;
  4271. };
  4272.  
  4273. function hslToHex(h, s, l) {
  4274. h /= 360;
  4275. s /= 100;
  4276. l /= 100;
  4277. let r, g, b;
  4278. if (s === 0) {
  4279. r = g = b = l;
  4280. } else {
  4281. const q = l < 0.5 ? l * (1 + s) : l + s - l * s;
  4282. const p = 2 * l - q;
  4283. r = hue2rgb(p, q, h + 1 / 3);
  4284. g = hue2rgb(p, q, h);
  4285. b = hue2rgb(p, q, h - 1 / 3);
  4286. }
  4287. const toHex = x => {
  4288. const hex = Math.round(x * 255).toString(16);
  4289. return hex.length === 1 ? '0' + hex : hex;
  4290. };
  4291. return `#${toHex(r)}${toHex(g)}${toHex(b)}`;
  4292. }
  4293.  
  4294.  
  4295.  
  4296. const _lineTo = CanvasRenderingContext2D.prototype.lineTo;
  4297. CanvasRenderingContext2D.prototype.lineTo = function () {
  4298. if(settings.theme[5].active){
  4299. if(!agmaSettings.sGrid){ // use to avoid changing color of background "grid lines" settings
  4300. this.strokeStyle = userPreferences.rainbowMapBorder ? hslToHex(Math.floor(Date.now() / userPreferences.rainbowBorderSpeed) % 360, 100, 50) : settings.theme[5].color;
  4301. } else {
  4302. if(agmaSettings.sDark){
  4303. if(!/#(..)\1{2}/gm.test(this.strokeStyle)) this.strokeStyle = userPreferences.rainbowMapBorder ? hslToHex(Math.floor(Date.now() / userPreferences.rainbowBorderSpeed) % 360, 100, 50) : settings.theme[5].color;
  4304. } else {
  4305. let [, r, g, b] = this.strokeStyle.match(/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i).map(hex => parseInt(hex, 16));
  4306. if(r > g && r > b){
  4307. this.strokeStyle = userPreferences.rainbowMapBorder ? hslToHex(Math.floor(Date.now() / userPreferences.rainbowBorderSpeed) % 360, 100, 50) : settings.theme[5].color;
  4308. }
  4309. }
  4310. }
  4311. }
  4312. return _lineTo.apply(this, arguments);
  4313. }
  4314.  
  4315.  
  4316. const encodeCustomNameColor = (rgb) => {
  4317. const r = parseInt(rgb.slice(1, 3), 16);
  4318. const g = parseInt(rgb.slice(3, 5), 16);
  4319. const b = parseInt(rgb.slice(5, 7), 16);
  4320.  
  4321. const step = 0xFF / (invisUnicodeIds.length - 1);
  4322. let color_id_r = ~~(r / step);
  4323. let color_id_g = ~~(g / step);
  4324. let color_id_b = ~~(b / step);
  4325.  
  4326. const char1 = color_id_r % (invisUnicodeIds.length);
  4327. const char2 = color_id_g % (invisUnicodeIds.length);
  4328. const char3 = color_id_b % (invisUnicodeIds.length);
  4329.  
  4330. // console.log("ec", char1, char2, char3, color_id_r, color_id_g, color_id_b, rgb);
  4331.  
  4332. const tag = String.fromCharCode(invisUnicodeIds[char1], invisUnicodeIds[char2], invisUnicodeIds[char3]);
  4333.  
  4334. return tag;
  4335. }
  4336.  
  4337. const decodeCustomNameColor = (clanPart, pos) => {
  4338. // adjusted decode function designed to be called with cell.clanPart
  4339. // designed for 3 characters / color
  4340. if(!clanPart || ![5, 8].includes(clanPart.length)) return null;
  4341. // clanPart starts with a space you idiot
  4342. // ???? wtf - fishy
  4343. const idx_1 = invisUnicodeIds.indexOf(clanPart.charCodeAt(1 + pos * 3));
  4344. const idx_2 = invisUnicodeIds.indexOf(clanPart.charCodeAt(2 + pos * 3));
  4345. const idx_3 = invisUnicodeIds.indexOf(clanPart.charCodeAt(3 + pos * 3));
  4346.  
  4347. if(idx_1 == -1 || idx_2 == -1 || idx_3 == -1) return null;
  4348.  
  4349.  
  4350. return {r: idx_1, g: idx_2, b: idx_3};
  4351. }
  4352.  
  4353. const getColorById = (color_id) => {
  4354. const step = 0xFF / (invisUnicodeIds.length);
  4355. const r = color_id.r * step;
  4356. const g = color_id.g * step;
  4357. const b = color_id.b * step;
  4358. const rgb = "#" + (~~r).toString(16).padStart(2, '0') + (~~g).toString(16).padStart(2, '0') + (~~b).toString(16).padStart(2, '0');
  4359. return rgb;
  4360. }
  4361.  
  4362. let currentMass = 0, leaderboardPos;
  4363. const _fillText = CanvasRenderingContext2D.prototype.fillText;
  4364. CanvasRenderingContext2D.prototype.fillText = function() {
  4365. if ((this.fillStyle == "#ffffff" || this.fillStyle == "#626262") && isNaN(arguments?.[0]) && /^Mass: \d+$/gm.test(arguments[0])){
  4366. currentMass = +arguments[0].match(/(?<=^Mass: )\d+$/gm)[0];
  4367. if(hiddenUI) arguments[0] = " ";
  4368. } else if(this.canvas.id == "leaderboard" && this.fillStyle == "#ffaaaa" && /^\d+(?=\.\s)/gm.test(arguments[0])) [leaderboardPos] = arguments[0].match(/^\d+(?=\.\s)/gm);
  4369.  
  4370. _fillText.apply(this, arguments);
  4371. }
  4372.  
  4373. const debounce = (func, timeout = 300) => {
  4374. let timer;
  4375. return (...args) => {
  4376. clearTimeout(timer);
  4377. timer = setTimeout(() => { func.apply(this, args); }, timeout);
  4378. };
  4379. }
  4380.  
  4381. const isLogged = () => currentUser != 'Please Login First';
  4382. let intervalCount = 0, currentUser, lastLoggedOut = Date.now();
  4383.  
  4384. // const mainInterval = setInterval(() => {
  4385. const mainInterval = () => {
  4386. intervalCount++;
  4387. if(userPreferences.hoverShowSkinID && $('#publicSkinsPage').children().length > 0 && $('#publicSkinsPage').find('[id^="skinContainer"]>img')[0]?.title == ''){ // check if skins have loaded
  4388. $('[id^="skinContainer"]').each(function(){
  4389. $(this).find('img').attr('title', $(this).attr('id').replace('skinContainer', '')); // make hover show skin ID
  4390. })
  4391. $('.publicskins-nav-btn').on('click', () => {
  4392. $('[id^="skinContainer"]').each(function(){
  4393. $(this).find('img').attr('title', $(this).attr('id').replace('skinContainer', ''));
  4394. })
  4395. })
  4396. }
  4397. if(userPreferences.sortWearablesByOwned && $('#phpWearables>li').length && !$('#fsfb-wearsloaded').length){
  4398. $($('[id^="wearableUseBtn"]').get().reverse()).each(function(){
  4399. $($(this).parents().get(2)).insertBefore($("#phpWearables li:eq(0)"));
  4400. })
  4401. $('#phpWearables').append('<div id="fsfb-wearsloaded"></div>')
  4402.  
  4403. }
  4404. if(userPreferences.publicSkinSearch && $('#publicSkinsPage').children().length > 0 && !document.getElementById("fsfb-skinsearch")){
  4405. $('.publicskins-nav-bar').eq(0).after(`<input id="fsfb-skinsearch" placeholder="Enter skin name/id here" type="search">`);
  4406. // const handlePress = debounce(() => {
  4407. const handlePress = () => {
  4408. if(!$('#fsfb-skinsearch').val()) return void($('.btn.publicskins-nav-btn.btn-default').not('.btn-primary')[0].click());
  4409. const searchQuery = $('#fsfb-skinsearch').val();
  4410. const skinsSearchedArr = skinsArr.filter(skin => skin.type == 4 && (skin.name.toLowerCase().includes(searchQuery.toLowerCase()) || skin.id == +searchQuery));
  4411. let totalRows = Math.ceil(skinsSearchedArr.length / 4);
  4412. if(totalRows == 0){
  4413. $('#publicSkinsPage tbody').html('').append('<h1>No Skins Found</h1>');
  4414. } else {
  4415. $('#publicSkinsPage tbody').html('');
  4416. for(let i = 0; i < totalRows; i++) $('#publicSkinsPage tbody').append('<tr></tr>');
  4417. let currRow = 0, currColumn = 0;
  4418. for(let i of skinsSearchedArr){
  4419. if(++currColumn > 4) currRow++, currColumn = 1;
  4420. $('#publicSkinsPage tr').eq(currRow).append(`<td id="skinContainer${i.id}" class="skin-container"><img src="skins/${i.id}_lo.png" alt="" ${userPreferences.hoverShowSkinID ? 'title="' + i.id + '"': ''}><h4>${softSanitize(i.name)}</h4><button id="skinUseBtn${i.id}" class="btn btn-primary skinuse-btn" onclick="toggleSkin(${i.id});">Use</button></td>`)
  4421. }
  4422. }
  4423. }
  4424. // }, 300);
  4425. let pressTimer;
  4426. $('#fsfb-skinsearch').on('input', () => {
  4427. clearTimeout(pressTimer);
  4428. pressTimer = setTimeout(() => handlePress(), Math.round(300 / ($('#fsfb-skinsearch').val().length || 300)));
  4429. });
  4430. }
  4431. currentUser = $('#userCoins2')[0].innerText;
  4432. let user_abil = currentUser == 'Please Login First' ? null : misc_settings.abil?.[currentUser];
  4433. if(user_abil != undefined && userPreferences.showRemainingAbilityTime){
  4434. for(let i in user_abil){
  4435. let text = $(`.purchase-btn.confirmation[item="${i}"]`).parents().eq(0).find('div h5'),
  4436. active = $('#' + $(`.purchase-btn.confirmation[item="${i}"]`).parents().eq(0)[0].id + ' img').eq(1).css('display') != "none";
  4437. // has been 24h+ and the player hasn't logged out since it's expired
  4438. if(Date.now() - user_abil[i] > 8.64e7 && active){
  4439. text.eq(1).text('EXPIRED IF UNLOG');
  4440. text.eq(0).find('div h5').hide();
  4441. }
  4442. // has been >24h
  4443. else if(Date.now() - user_abil[i] < 8.64e7 && active){
  4444. text.eq(0).hide();
  4445. text.eq(1).text(msToTime(8.64e7 - (Date.now() - user_abil[i]))).show();
  4446. }
  4447. else { // has been 24h+ & player has logged out
  4448. text.eq(0).find('div h5').show();
  4449. text.eq(1).find('div h5').hide();
  4450. }
  4451. }
  4452. } else {
  4453. $('.white_shopdesc').show();
  4454. $('.white_shopdesc.fsfb-fake').hide();
  4455. }
  4456. if(accounts[currentUser] == null && currentUser !== 'Please Login First'){
  4457. xpInfo();
  4458. coinsInfo();
  4459. accounts = {...accounts, ...{[currentUser] : {coins: currentCoins, xp: currentXP, lvl: round(currentPercent, 3) + currentLevel}}};
  4460. }
  4461. if(accounts[currentUser] != null && accounts[currentUser].coins == 0) accounts[currentUser].coins = currentCoins;
  4462. if(accounts[currentUser] != null && accounts[currentUser].xp == 0) accounts[currentUser].xp = currentXP;
  4463. if(accounts[currentUser] != null && accounts[currentUser].lvl == 0) accounts[currentUser].lvl = round(currentPercent, 3) + currentLevel;
  4464.  
  4465. if(userPreferences.coinXPstats && intervalCount % 12 == 0){
  4466. xpInfo();
  4467. lastMinXP.push(new StatLog(round(currentXP, 3), round(currentPercent, 3) + currentLevel, currentUser, lastMinXP));
  4468. const prevObjXP = lastMinXP[lastMinXP.length - 1];
  4469. if(prevObjXP && prevObjXP.id % (6e4 / updateTimeXP) == 0) lastHrXP.push(new StatLog(round(currentXP, 3), round(currentPercent, 3) + currentLevel, currentUser, lastHrXP));
  4470. if(lastMinXP.length > 6e4 / updateTimeXP) lastMinXP.shift();
  4471. if(lastHrXP.length > 60) lastHrXP.shift();
  4472. if(!coinsHTMLactive && $('#stats-container').css('display') == 'block') updateUI();
  4473. // unsafeWindow.logStatsScriptXP && console.log(lastMinXP, lastHrXP);
  4474. }
  4475. if(userPreferences.coinXPstats && intervalCount % 6 == 0){
  4476. coinsInfo();
  4477. lastMinCoins.push(new StatLog(currentCoins, 0, currentUser, lastMinCoins));
  4478. const lastObjCoins = lastMinCoins[lastMinCoins.length - 1];
  4479. if(lastObjCoins && lastObjCoins.id % (6e4 / updateTimeCoins) == 0) lastHrCoins.push(new StatLog(currentCoins, 0, currentUser, lastHrCoins));
  4480. if(lastMinCoins.length > 6e4 / updateTimeCoins) lastMinCoins.shift();
  4481. if(lastHrCoins.length > 60) lastHrCoins.shift();
  4482. if(coinsHTMLactive && $('#stats-container').css('display') == 'block') updateUI();
  4483. // unsafeWindow.logStatsScriptCoins && console.log(lastMinCoins, lastHrCoins);
  4484. }
  4485. if(userPreferences.coinXPstats && $('#stats-container').css('display') == 'block')$('#stats-sesh-length').text(msToTime(Date.now() - (coinsHTMLactive ? scriptStartCoins : scriptStartXP)))
  4486. if(intervalCount % 3 == 0 && misc_settings?.statsPos != null){
  4487. statsboxPos = {top: $("#stats-container")[0].style.top, left: $("#stats-container")[0].style.left};
  4488. misc_settings.statsPos = statsboxPos;
  4489. setStorage("fsfb-misc", misc_settings);
  4490. }
  4491. if(intervalCount % 2 == 0){ // "You have an activated bot pack available: 100 XXL Bots 1 Hours! Restart your bots before they expire!"
  4492. if(chatmsgs != null && chatmsgs?.length > 2){ // "You have an activated bot pack available: 100 Bots 24 Hours! Restart your bots before they expire!"
  4493. for(let i of chatmsgs){
  4494. if(i.name == '' && i.cache != null && i.cache.color2 == '#ff8100'){
  4495. if(i.message.match(/(?<=(Welcome back to Agma, )).+/g)?.[0] == currentUser){
  4496. const msgBots = $('.memberType').text() == 'GOLD MEMBER' ? chatmsgs?.[chatmsgs.indexOf(i) - 2] : chatmsgs?.[chatmsgs.indexOf(i) - 1],
  4497. msgGM = $('.memberType').text() == 'GOLD MEMBER' ? chatmsgs?.[chatmsgs.indexOf(i) - 1] : null;
  4498. if(msgBots?.message.includes('Restart your bots before they expire!')){
  4499. if(misc_settings.bots[currentUser] != null) misc_settings.bots[currentUser].chatAmt = msgBots.message.match(/\d+.+\d Hours/g)[0];
  4500. minsChatAmt[currentUser] = {...minsChatAmt[currentUser], ... {amt: msgBots.message.match(/\d+.+\d Hours/g)[0], started: true}};
  4501. setStorage("fsfb-misc", misc_settings);
  4502. } else if(msgBots?.message.match(/(?<=(You have a new bot pack available: )).+(?=(! Start your bots in the minion panel.))/g)?.length){
  4503. if(misc_settings.bots[currentUser] != null) misc_settings.bots[currentUser].chatAmt = msgBots.message.match(/\d+.+\d Hours/g)[0];
  4504. minsChatAmt[currentUser] = {...minsChatAmt[currentUser], ... {amt: msgBots.message.match(/\d+.+\d Hours/g)[0], started: false}};
  4505. setStorage("fsfb-misc", misc_settings);
  4506. }
  4507. if(msgGM != null && msgGM.message.match(/(?<=You have )\d+(?= Days left of Gold Member!)/gm)?.length){
  4508. accGoldMem[currentUser] = {...accGoldMem[currentUser], ... {days: msgGM.message.match(/(?<=You have )\d+(?= Days left of Gold Member!)/gm)[0], has: true}};
  4509. } else {
  4510. accGoldMem[currentUser] = {...accGoldMem[currentUser], ... {has: false}};
  4511. }
  4512. } else if(i.message.match(/(?<=(You have a new bot pack available: )).+(?=(! Start your bots in the minion panel.))/g)?.length){
  4513. if(misc_settings.bots[currentUser] != null) misc_settings.bots[currentUser].chatAmt = i.message.match(/\d+.+\d Hours/g)[0];
  4514. minsChatAmt[currentUser] = {...minsChatAmt[currentUser], ... {amt: i.message.match(/\d+.+\d Hours/g)[0], started: false}};
  4515. setStorage("fsfb-misc", misc_settings);
  4516. }
  4517. }
  4518. }
  4519. }
  4520. }
  4521. if(currentServerId === 0){
  4522. try {
  4523. for(let { isCurrent, id } of JSON.parse(localStorage.gameservers)){
  4524. if(isCurrent) currentServerId = id;
  4525. }
  4526. if(currentServerId !== 0) svSwitch = true;
  4527. } catch {};
  4528. }
  4529. uisdoa && (unsafeWindow.__currentServerId = currentServerId);
  4530. if(currentUser == 'Please Login First' || $('#level').text() == 0) lastLoggedOut = Date.now();
  4531. changeTitle(settings.checkboxes[4].active ? currentUser == 'Please Login First' ? "Agma.io" : "Agma.io | " + currentUser : "Agma.io - A free multiplayer MMO game");
  4532.  
  4533. // if($('#friendAcceptAll').length > 0 && userPreferences.friendDeclineAll && $('#friendRejectAll').length < 1 && currentUser != 'Please Login First') addFriendDecline();
  4534.  
  4535. // if($('#friendDialogMessage').text() != 'Login to see your friendlist' && $('#friendDialogMessage').text() == 'Loading...' && $('#friendsRequestsAmt').text() == '' && userPreferences.friendDeclineAll && currentUser != 'Please Login First'){
  4536. // $('#btnFriends').click().click();
  4537. // }
  4538.  
  4539. fpsArr.push(+document.getElementById("fps").innerText);
  4540. if(fpsArr.length == 6) fpsArr.shift();
  4541. avgFps = mean(fpsArr);
  4542. setTimeout(mainInterval, 1e3);
  4543. }
  4544. setTimeout(mainInterval, 1e3);
  4545. // }, 1e3);
  4546.  
  4547.  
  4548. const antiAFK = () => {
  4549. setTimeout(antiAFK, 3e4);
  4550. if(!$('#fsfb-antiAFK').is(':checked')) return; // move mouse every 30sec
  4551. let [moveX, moveY] = linesplitting ? [pointMove.x, pointMove.y] : [mosX, mosY];
  4552. [++moveX, --moveX].forEach(x => $('#canvas').trigger($.Event('mousemove', {clientX: x, clientY: moveY})));
  4553. }
  4554.  
  4555. setTimeout(antiAFK, 3e4);
  4556.  
  4557. uisdoa ?? $('#fsfb-recospeed').parent().hide();
  4558.  
  4559. const updateScriptSettingsUI = () => {
  4560. for(let i of settings.checkboxes) $('#' + i.id).prop("checked", i.active).trigger("change");
  4561. for(let i of settings.hotkeys) $('#' + i.id).text(getName(i.key));
  4562. for(let i of settings.quickSettings){
  4563. $('#' + i.id1).val(i.set);
  4564. $('#' + i.id).text(getName(i.key));
  4565. }
  4566. // slowfeed
  4567. $('#' + settings.slowFeed[0].id).text(getName(settings.slowFeed[0].key));
  4568. $('#' + settings.slowFeed[1].id).val(settings.slowFeed[1].val);
  4569.  
  4570. $('#' + settings.frozenvirus[0].id).text(getName(settings.frozenvirus[0].key));
  4571. $('#' + settings.frozenvirus[1].id).val(settings.frozenvirus[1].val);
  4572.  
  4573. for(let i of settings.fastsplit_hotkeys){
  4574. i.val == null ? $('#' + i.id).text(getName(i.key)) : $('#' + i.id).val(i.val);
  4575. }
  4576. for(let i of settings.uiScaling) $('#' + i.id).val(i.level).trigger("input");
  4577. for(let i of settings.export_import) $('#' + i.id).prop("checked", i.active).trigger("change");
  4578. for(let i of settings.theme){
  4579. $('#' + i.id).prop("checked", i.active).trigger("change");
  4580. $('#' + i.id1).val(i.color).trigger("input");
  4581. }
  4582. for(let i of settings.theme_boxes) $('#' + i.id).prop("checked", i.active).trigger("change");
  4583. for(let i of settings.name_color){
  4584. if('color' in i){
  4585. $('#' + i.id).prop("checked", i.active).trigger("change");
  4586. $('#' + i.id1).val(i.color).trigger("input");
  4587. } else $('#' + i.id).prop("checked", i.active).trigger("change");
  4588. }
  4589. for(let i of settings.anti_lag) $('#' + i.id).prop("checked", i.active).trigger("change");
  4590. for(let i of settings.chat_translate){
  4591. 'set' in i ? $('#' + i.id).val(i.set) : $('#' + i.id).prop('checked', i.active).trigger('change');
  4592. }
  4593. }
  4594. setTimeout(() => updateScriptSettingsUI(), 1e3);
  4595.  
  4596. $('body').append('<div id="fsfb-css-styles"><style id="hideUI-css" type="text/css"></style><style id="css-invsingleline" type="text/css"></style><style id="stats-input-css" type="text/css">#stats-table input{ display: none; }</style></div>');
  4597.  
  4598. const _replaceCSS = (a,b) => {
  4599. document.getElementById(a).innerHTML = b;
  4600. }
  4601. !function(){
  4602. $('body').append(`
  4603. <div class="fade fsfb-bug-modal modal" aria-hidden=true role="dialog" tabindex="-1">
  4604. <div class="modal-dialog modal-lg">
  4605. <div class="modal-content">
  4606. <div class="modal-interior">
  4607. <h2 class="fsfb-modal-title">Script Documentation</h2><button class="close fsfb-btn" data-dismiss="modal" type=button>×</button>
  4608. <section class=fsfb-modal-body>
  4609. <div><span>Chat Copy/Cut/Paste</span> - allows you to use the commands in chat (e.g. Ctrl + V becomes avaiable inside chat)</div>
  4610. <div><span>Anti-AFK</span> - prevents you from automatically disconnecting after 10 minutes</div>
  4611. <div><span>Anti-Invis</span> - shows you players even when they have the invisibility ability active</div>
  4612. <div><span>Linesplit Toggle</span> - enabled means that if you press the linesplit hotkey, it will turn linesplitting on until the key is pressed again (in contrast to stopping the linesplit when key is released)</div>
  4613. <div><span>Change Page Title</span> - changes the tab's title to just "Agma.io" with the current username</div>
  4614. <div><span>Hide Shouts</span> - prevent megaphone shouts from showing up at all</div>
  4615. <div><span>Hold To Spam</span> - while the powerup's hotkey is held, it will continuously use the powerup</div>
  4616. <div><span>Show Portal Mass</span> - displays the predicted amount of times the portals in rooms 1 & 2 have been fed by players (not 100% accurate & doesn't work at all servers)</div>
  4617. <div><span>Power Spawns Overlay</span> - show the locations of where powerups/minion packs spawn with lower opacity (thanks to Light for helping with getting all of the power locations)</div>
  4618. <div><span>Quick Buy</span> - click plus sign (+) next to your powers (only if you set it to true in the code), then click on the powerup you want to buy</div>
  4619. <div><span>Food/Virus/Mothercell Color</span> - changes the color that's filling these to a custom one</div>
  4620. <div><span>Virus/Mothercell Stroke</span> - changes the color of the stroke (border/outline) to a custom one</div>
  4621. <div><span>Spiked Cells</span> - render all cells with the spikes from the infecton gamemode</div>
  4622. <div><span>Show Mass</span> - show the mass of all players' cells</div>
  4623. <div><span>Only My Skin</span> - hide all skins besides the one you're using</div>
  4624. <div><span>Only Party Skin</span> - hide all skins besides the ones people in your party are using</div>
  4625. <div><span>Only My Nick</span> - hide all nicks besides the one you're using</div>
  4626. <div><span>Only Party Nick</span> - hide all nicks besides the ones people in your party are using</div>
  4627. <div><span>Shoot 7 Ejected</span> - press ejected mass hotkey 7 times (useful to prime room 1 or 2 portal when it's been reset</div>
  4628. <div><span>Linesplit Lock</span> - finds which direction your mouse is the closest to & puts mouse way off the map (towards that direction) so you can perform perfect linesplits without zooming out or precisely placing your mouse (feature and design inspired by <a href=https://greasyfork.org/en/scripts/404559-agma-io-linesplit-overlay target=_blank>Wynell's script</a>)</div>
  4629. <div><span>Macrosplit Bots</span> - hold this key to macrosplit your bots without switching controls off of yourself</div>
  4630. <div><span>Hide UI</span> - press this key to toggle showing the game UI (intended for recording/screenshots)</div>
  4631. <div><span>Toggle Slow Feed</span> - (toggle) this presses eject mass hotkey at the defined interval (intended for feeding the gold block while AFK)</div>
  4632. <div><span>Slow Feed Speed</span> - the speed at which eject mass is pressed when slow-feeding</div>
  4633. <div><span>Quick Settings</span> - when the hotkey assigned is pressed, it will toggle the setting that is selected</div>
  4634. <div><span>Toggle Cursor Lock</span> - when pressed, this will keep cursor lock active until you press it again (also works when the tab is unfocused)</div>
  4635. <div><span>Fast Onesplit</span> - performs a fast onesplit (Onesplit -> Freeze -> Unfreeze); speed is dependent fps (low fps indicates slow CPU, slow CPU can mess timings up)</div>
  4636. <div><span>Fast Doublesplit</span> - performs a fast Doublesplit (Doublesplit -> Freeze -> Unfreeze); speed is dependent fps (low fps indicates slow CPU, slow CPU can mess timings up)</div>
  4637. <div><span>Chat Size</span> - make the size of chat bigger/smaller</div>
  4638. <div><span>Inventory Size</span> - make the size of powerups inventory bigger/smaller</div>
  4639. <div><span>Statsbox Size</span> - make the size of XP/coins stats bigger/smaller</div>
  4640. <div><span>Export</span> - select the boxes of the settings you wish to export and press the button, a .txt file will be downloaded with your settings inside</div>
  4641. <div><span>Import</span> - select the boxes of the settings you wish to import and insert the exported settings into the input (note: settings will only be changed if they were selected in both export & import</div>
  4642. <table>
  4643. <tr>
  4644. <th>Chat Command</th>
  4645. <th>Description</th>
  4646. </tr>
  4647. <tr>
  4648. <td class="fsfb-cmd-title">${userPreferences.chatPrefix}help</td>
  4649. <td>list all available chat commands</td>
  4650. </tr>
  4651. <tr>
  4652. <td class="fsfb-cmd-title">${userPreferences.chatPrefix}bots</td>
  4653. <td>show which bot pack you have active and how much time is remaining</td>
  4654. </tr>
  4655. <tr>
  4656. <td class="fsfb-cmd-title">${userPreferences.chatPrefix}pws</td>
  4657. <td>show the amount of powerups in your inventory (recommended to use ${userPreferences.chatPrefix}pws1, ${userPreferences.chatPrefix}pws2, and ${userPreferences.chatPrefix}pws3)</td>
  4658. </tr>
  4659. <tr>
  4660. <td class="fsfb-cmd-title">${userPreferences.chatPrefix}totalpws</td>
  4661. <td>show the total amount of powerups you have in your inventory</td>
  4662. </tr>
  4663. <tr>
  4664. <td class="fsfb-cmd-title">${userPreferences.chatPrefix}xp</td>
  4665. <td>show then amount of xp you've completed for this level</td>
  4666. </tr>
  4667. <tr>
  4668. <td class="fsfb-cmd-title">${userPreferences.chatPrefix}lvl</td>
  4669. <td>show your level and how much of the level you've completed</td>
  4670. </tr>
  4671. <tr>
  4672. <td class="fsfb-cmd-title">${userPreferences.chatPrefix}coins</td>
  4673. <td>show the amount of coins you have</td>
  4674. </tr>
  4675. <tr>
  4676. <td class="fsfb-cmd-title">${userPreferences.chatPrefix}hours</td>
  4677. <td>show the hours you have on your account</td>
  4678. </tr>
  4679. <tr>
  4680. <td class="fsfb-cmd-title">${userPreferences.chatPrefix}rank</td>
  4681. <td>show your ranking</td>
  4682. </tr>
  4683. <tr>
  4684. <td class="fsfb-cmd-title">${userPreferences.chatPrefix}ping</td>
  4685. <td>show your current ping</td>
  4686. </tr>
  4687. <tr>
  4688. <td class="fsfb-cmd-title">${userPreferences.chatPrefix}fps</td>
  4689. <td>show your current FPS</td>
  4690. </tr>
  4691. <tr>
  4692. <td class="fsfb-cmd-title">${userPreferences.chatPrefix}topmass</td>
  4693. <td>show your highest mass</td>
  4694. </tr>
  4695. <tr>
  4696. <td class="fsfb-cmd-title">${userPreferences.chatPrefix}cells</td>
  4697. <td>show your cell count</td>
  4698. </tr>
  4699. <tr>
  4700. <td class="fsfb-cmd-title">${userPreferences.chatPrefix}pws1</td>
  4701. <td>show the first part of your powerup inventory</td>
  4702. </tr>
  4703. <tr>
  4704. <td class="fsfb-cmd-title">${userPreferences.chatPrefix}pws2</td>
  4705. <td>show the second part of your powerup inventory</td>
  4706. </tr>
  4707. <tr>
  4708. <td class="fsfb-cmd-title">${userPreferences.chatPrefix}pws3</td>
  4709. <td>show the third part of your powerup inventory</td>
  4710. </tr>
  4711. <tr>
  4712. <td class="fsfb-cmd-title">${userPreferences.chatPrefix}friends</td>
  4713. <td>show how many friends you have and how many are online</td>
  4714. </tr>
  4715. <tr>
  4716. <td class="fsfb-cmd-title">${userPreferences.chatPrefix}requests</td>
  4717. <td>show how many friend requests you have</td>
  4718. </tr>
  4719. <tr>
  4720. <td class="fsfb-cmd-title">${userPreferences.chatPrefix}gold</td>
  4721. <td>show how many days of gold member you have left remaining</td>
  4722. </tr>
  4723. <tr>
  4724. <td class="fsfb-cmd-title">${userPreferences.chatPrefix}alive</td>
  4725. <td>show the amount of time you've been alive</td>
  4726. </tr>
  4727. <tr>
  4728. <td class="fsfb-cmd-title">${userPreferences.chatPrefix}mass</td>
  4729. <td>show your current mass</td>
  4730. </tr>
  4731. <tr>
  4732. <td class="fsfb-cmd-title">${userPreferences.chatPrefix}user</td>
  4733. <td>show your current username</td>
  4734. </tr>
  4735. <tr>
  4736. <td class="fsfb-cmd-title">${userPreferences.chatPrefix}customs</td>
  4737. <td>show the amount of custom skins you own</td>
  4738. </tr>
  4739. <tr>
  4740. <td class="fsfb-cmd-title">${userPreferences.chatPrefix}wearables</td>
  4741. <td>show how many wearables you own</td>
  4742. </tr>
  4743. <tr>
  4744. <td class="fsfb-cmd-title">${userPreferences.chatPrefix}cloak</td>
  4745. <td>show the remaining time of your cloak ability</td>
  4746. </tr>
  4747. <tr>
  4748. <td class="fsfb-cmd-title">${userPreferences.chatPrefix}add [user]</td>
  4749. <td>type this command to quickly add a friend using chat</td>
  4750. </tr>
  4751. <tr>
  4752. <td class="fsfb-cmd-title">${userPreferences.chatPrefix}partymembers</td>
  4753. <td>show how many people are in your party</td>
  4754. </tr>
  4755. <tr>
  4756. <td class="fsfb-cmd-title">${userPreferences.chatPrefix}players</td>
  4757. <td>show how many players are online in your server and are online in all agma servers</td>
  4758. </tr>
  4759. <tr>
  4760. <td class="fsfb-cmd-title">${userPreferences.chatPrefix}server</td>
  4761. <td>show which server you're currently in</td>
  4762. </tr>
  4763. <tr>
  4764. <td class="fsfb-cmd-title">${userPreferences.chatPrefix}abils</td>
  4765. <td>show your currently active abilities</td>
  4766. </tr>
  4767. <tr>
  4768. <td class="fsfb-cmd-title">${userPreferences.chatPrefix}xpproj</td>
  4769. <td>show the predicted amount of XP you will gain in an hour</td>
  4770. </tr>
  4771. <tr>
  4772. <td class="fsfb-cmd-title">${userPreferences.chatPrefix}coinsproj</td>
  4773. <td>show the predicted amount of coins you will gain in an hour</td>
  4774. </tr>
  4775. <tr>
  4776. <td class="fsfb-cmd-title">${userPreferences.chatPrefix}xprem</td>
  4777. <td>show the amount of XP remaining for your level</td></td>
  4778. </tr>
  4779. <tr>
  4780. <td class="fsfb-cmd-title">${userPreferences.chatPrefix}xphour</td>
  4781. <td>show the amount of xp you've gained in the last hour</td>
  4782. </tr>
  4783. <tr>
  4784. <td class="fsfb-cmd-title">${userPreferences.chatPrefix}coinshour</td>
  4785. <td>show the amount of coins you've gained in the last hour</td>
  4786. </tr>
  4787. <tr>
  4788. <td class="fsfb-cmd-title">${userPreferences.chatPrefix}xpmin</td>
  4789. <td>show the amount of XP you've gained in the last minute</td>
  4790. </tr>
  4791. <tr>
  4792. <td class="fsfb-cmd-title">${userPreferences.chatPrefix}coinsmin</td>
  4793. <td>show the amount of coins you've gained in the last minute</td>
  4794. </tr>
  4795. <tr>
  4796. <td class="fsfb-cmd-title">${userPreferences.chatPrefix}xp12s</td>
  4797. <td>show the amount of coins you've gained in the last 12 seconds</td>
  4798. </tr>
  4799. <tr>
  4800. <td class="fsfb-cmd-title">${userPreferences.chatPrefix}xpsesh</td>
  4801. <td>show the amount of XP you've gained in this session</td>
  4802. </tr>
  4803. <tr>
  4804. <td class="fsfb-cmd-title">${userPreferences.chatPrefix}lifetimexp</td>
  4805. <td>show the total amount of XP you've earned in your account's lifetime</td>
  4806. </tr>
  4807. <tr>
  4808. <td class="fsfb-cmd-title">${userPreferences.chatPrefix}seshcoins</td>
  4809. <td>show the amount of coins you've gained in this session</td>
  4810. </tr>
  4811. <tr>
  4812. <td class="fsfb-cmd-title">${userPreferences.chatPrefix}seshcoins</td>
  4813. <td>show the amount of coins you've gained in this session</td>
  4814. </tr>
  4815. <tr>
  4816. <td class="fsfb-cmd-title">${userPreferences.chatPrefix}waifu [user]</td>
  4817. <td>rate the waifu of the selected username (leave user blank to rate yourself)</td>
  4818. </tr>
  4819. <tr>
  4820. <td class="fsfb-cmd-title">${userPreferences.chatPrefix}pro [user]</td>
  4821. <td>show how pro someone is (leave user blank to rate yourself)</td>
  4822. </tr>
  4823. <tr>
  4824. <td class="fsfb-cmd-title">${userPreferences.chatPrefix}dog [user]</td>
  4825. <td>show how dog someone is (leave user blank to rate yourself)</td>
  4826. </tr>
  4827. <tr>
  4828. <td class="fsfb-cmd-title">${userPreferences.chatPrefix}king [user]</td>
  4829. <td>show how king someone is (leave user blank to rate yourself)</td>
  4830. </tr>
  4831. <tr>
  4832. <td class="fsfb-cmd-title">${userPreferences.chatPrefix}dice [sides]</td>
  4833. <td>roll a die with the desired number of sides</td>
  4834. </tr>
  4835. <tr>
  4836. <td class="fsfb-cmd-title">${userPreferences.chatPrefix}rng [min] [max]</td>
  4837. <td>generate a random number in a range</td>
  4838. </tr>
  4839. <tr>
  4840. <td class="fsfb-cmd-title">${userPreferences.chatPrefix}coinflip</td>
  4841. <td>flip a coin and see if it lands on heads or tails</td>
  4842. </tr>
  4843. <tr>
  4844. <td class="fsfb-cmd-title">${userPreferences.chatPrefix}script</td>
  4845. <td>show the current script you're using & which version</td>
  4846. </tr>
  4847. <tr>
  4848. <td class="fsfb-cmd-title">${userPreferences.chatPrefix}time</td>
  4849. <td>show your current locale date & time</td>
  4850. </tr>
  4851. <tr>
  4852. <td class="fsfb-cmd-title">${userPreferences.chatPrefix}skins</td>
  4853. <td>show your bought skins and their worth (limited as well)</td>
  4854. </tr>
  4855. <tr>
  4856. <td class="fsfb-cmd-title">${userPreferences.chatPrefix}ratefriends [user1] [user2]</td>
  4857. <td>show how what percent friends two usernames are</td>
  4858. </tr>
  4859. <tr>
  4860. <td class="fsfb-cmd-title">${userPreferences.chatPrefix}rateenemies [user1] [user2]</td>
  4861. <td>show how what percent enemies two usernames are</td>
  4862. </tr>
  4863. <tr>
  4864. <td class="fsfb-cmd-title">${userPreferences.chatPrefix}leaderboard</td>
  4865. <td>show your leaderboard position</td>
  4866. </tr>
  4867. <tr>
  4868. <td class="fsfb-cmd-title">${userPreferences.chatPrefix}altcaps [text]</td>
  4869. <td>anything written after this command will have alternating lowercase/capital letters</td>
  4870. </tr>
  4871. <tr>
  4872. <td class="fsfb-cmd-title">${userPreferences.chatPrefix}sparkles [text]</td>
  4873. <td>anything written after this command will be surrounded with star emojis</td>
  4874. </tr>
  4875. <tr>
  4876. <td class="fsfb-cmd-title">${userPreferences.chatPrefix}cfix</td>
  4877. <td>resets canvas, can sometimes fix bugs with rendering</td>
  4878. </tr>
  4879. <tr>
  4880. <td class="fsfb-cmd-title">${userPreferences.chatPrefix}fact</td>
  4881. <td>sends a random fact in chat</td>
  4882. </tr>
  4883. <tr>
  4884. <td class="fsfb-cmd-title">${userPreferences.chatPrefix}fastsplit</td>
  4885. <td>show your fastsplit delays</td>
  4886. </tr>
  4887. <tr>
  4888. <td class="fsfb-cmd-title">${userPreferences.chatPrefix}progress</td>
  4889. <td>show your progress for the daily challenge</td>
  4890. </tr>
  4891. <tr>
  4892. <td class="fsfb-cmd-title">${userPreferences.chatPrefix}sorapoints</td>
  4893. <td>show how many SoraPoints you have</td>
  4894. </tr>
  4895. <tr>
  4896. <td class="fsfb-cmd-title">${userPreferences.chatPrefix}keys</td>
  4897. <td>show how many myster box keys you have</td>
  4898. </tr>
  4899. <tr>
  4900. <td class="fsfb-cmd-title">${userPreferences.chatPrefix}stars</td>
  4901. <td>show how many challenge stars you have</td>
  4902. </tr>
  4903. <table>
  4904. <div><span>Hide Ads</span> - both video and image ads will be removed from the screen</div>
  4905. <div><span>Skin Search</span> - search through skins by their names/ids</div>
  4906. <div><span>Improved Shop</span> - added larger amounts that can be purchased at a time, can also buy a specified amount at one time</div>
  4907. <div><span>Sort Wearables</span> - wearables are automatically sorted by owned (the ones you own will be before all others)</div>
  4908. <div><span>Extra Bot Packs</span> - added hidden bot packs that can be purchased with coins (originally discovered by firebone)</div>
  4909. <div><span>Context Menu Copy Info</span> - right click on a player, then click on their cell icon to copy their skin ID to clipboard or click on their name to copy their nickname to clipboard</div>
  4910. <div><span>Copy Chat</span> - right click on screen, then click "Copy Chat Messages" to copy the currently visible chat messages to your clipboard</div>
  4911. <div><span>Abilities Remaining Time</span> - shows the remaining time left of abilities (only works if the abilities were purchased in the same browser)</div>
  4912. <div><span>Unlock Free Skins</span> - gives you access to the facebook & youtube free skins</div>
  4913. <div><span>Hover For Skin ID</span> - hovering skins in the skin menu will shop their ID</div>
  4914. <div><span>In Depth XP/Coins Stats</span> - click on coins/xp progress bar in top left to view respective statistics</div>
  4915. <div><span>XP Bar Decimals</span> - show the percentage up to 2 decimal places</div>
  4916. <div><span>White Border For Black Cells</span> - show a white border around black cells (from minion nuker) so they're easier to see with dark backgrounds</div>
  4917. <div><span>Inventory Single Row</span> - put powerups inventory on a single row instead of on 2 seperate rows (inspired by Principito)</div>
  4918. <div><span>Public Name Color</span> - enables other fsfb users to see your colored name and you to see the colored name of other fsfb users</div>
  4919. <div><span>Name Color</span> - change the color of your name</div>
  4920. <div><span>Name Stroke</span> - change the outline color of your name, when this setting is disabled and the Name Color enabled, a color will be generated that fits to the name color</div>
  4921. <div><span>Hide Small Minions</span> - hides small minions, but lets them appear once they grow bigger to reduce lag</div>
  4922. <div><span>No Minion Skins </span> - makes minions appear without skins to reduce lag</div>
  4923. <div><span>Hide Ejected Mass</span> - hides all ejected (W) mass to reduce lag</div>
  4924. <div><span>Hide Static Ejected</span> - only hides non-moving ejected mass to reduce lag</div>
  4925. <div><span>No Eat Anims</span> - removes the absorbtion animation when eating a cell to reduce lag</div>
  4926. <div><span>Translate Chat</span> - translates chat messages sent by players to the selected language (english by default), the translation appears in square brackets</div>
  4927. <div><span>Translate Server</span> - translates chat messages sent by the server to the selected language (english by default), the translation appears in square brackets</div>
  4928. <div><span>Show Original</span> - shows the untranslated message</div>
  4929.  
  4930. <div><span>Custom Backgrounds</span> - a few <a href=https://imgur.com/a/sTANNBE target=_blank>backgrounds</a></div>
  4931. </section>
  4932. </div>
  4933. </div>
  4934. </div>
  4935. </div>`);
  4936. }();
  4937.  
  4938. !function(){
  4939. const styles = document.createElement('style');
  4940. styles.innerHTML = `
  4941. p.fsfb-lag::after{
  4942. content: '*';
  4943. position: absolute;
  4944. margin-left: 1px;
  4945. }
  4946. input.fsfb-lag+p::after{
  4947. content: '*';
  4948. position: absolute;
  4949. margin-left: 1px;
  4950. }
  4951. #fsfb-settings-left .hotkey-paragraph{
  4952. margin: 0;
  4953. }
  4954. ${userPreferences.stylizeActiveSettings ? `
  4955. #fsfb-settings-main input:checked+p {
  4956. color: #df901c;
  4957. }
  4958. .fsfb-active-setting{
  4959. color: #df901c;
  4960. }` : ''}
  4961. #fsfb-freeze_yourself {
  4962. background-image: url(../img/store/freeze_yourself.png);
  4963. }
  4964. #fsfb-ripple-virus {
  4965. background-image: url(../img/store/ripple-virus.png);
  4966. }
  4967. #fsfb-minion_nuker {
  4968. background-image: url(../img/store/minion_nuker.png);
  4969. }
  4970. #fsfb-megaphone_shout {
  4971. background-image: url(../img/store/megaphone_shout.png);
  4972. }
  4973. .fsfb-update-swal .cancel{
  4974. background-color: #29b962 !important;
  4975. }
  4976. .fsfb-update-swal button:hover{
  4977. opacity: 75%;
  4978. }
  4979. a.fsfb-curser-anchor{
  4980. color: #8CEFFF;
  4981. }
  4982. a.fsfb-curser-anchor:hover{
  4983. opacity: 70%;
  4984. }
  4985. select.fsfb-changelang{
  4986. background: #a8a8a833;
  4987. border-radius: 3px;
  4988. border: none;
  4989. height: 20px;
  4990. color: #ffffffad;
  4991. margin: 2px 0 0 0;
  4992. }
  4993. select.fsfb-changelang:focus-visible{
  4994. outline: none;
  4995. }
  4996. select.fsfb-changelang option{
  4997. background: #222;
  4998. }
  4999. #fsfb-wearsloaded{
  5000. display: none;
  5001. width: 0;
  5002. height: 0;
  5003. }
  5004. #fsfb-skinsearch{
  5005. border: 1px solid #2e6da4;
  5006. background-color: #222328;
  5007. font-size: 17px;
  5008. border-radius: 4px;
  5009. width: 100%;
  5010. padding: 4px 4px 4px 8px;
  5011. margin: 4px 0;
  5012. color: white;
  5013. }
  5014. #stats-table td{
  5015. font-size: 17px;
  5016. }
  5017. #stats-table label{
  5018. padding-right: 10px;
  5019. margin: 0 6px 0 2px;
  5020. }
  5021. #stats-table input{
  5022. transform: scale(1.8);
  5023. margin: 5px 8px 5px 5px;
  5024. }
  5025. #friendRejectAll{
  5026. color: #ff4000 !important;
  5027. }
  5028. div.fsfb-slider{
  5029. display: flex;
  5030. align-items: center;
  5031. }
  5032. input[type="range"].fsfb-slider{
  5033. width: 58px;
  5034. display: inline;
  5035. position: absolute;
  5036. right: 5px;
  5037. }
  5038. #fsfb-minion_nuker img{
  5039. margin-top: 2px;
  5040. }
  5041. .fsfb-shown{
  5042. display: block !important;
  5043. }
  5044. .fsfb-hidden{
  5045. display: none !important;
  5046. }
  5047. #fsfb-quickbuy{
  5048. background-image: url('data:image/svg+xml;charset=UTF-8,<svg xmlns="http://www.w3.org/2000/svg" fill="white" viewBox="0 0 601 601"><path d="M1 301c0-31 23-54 49-54l198 1V50c0-26 23-49 53-49s53 23 53 49v198l197-1c26 0 49 23 49 54 0 30-23 53-49 53l-197-1v198c0 26-23 50-53 50s-53-24-53-50V354H50c-26 0-50-23-50-53"></path></svg>');
  5049. background-size: 80% 80%;
  5050. }
  5051. .fsfb-bug-modal>div>div{
  5052. -webkit-box-shadow: 0 5px 15px rgb(0 0 0 / 50%);
  5053. background: linear-gradient(to bottom,#3b414e 0,#302f33 100%);
  5054. border: 3px solid #232630;
  5055. }
  5056. .close.fsfb-btn{
  5057. position: absolute;
  5058. right: 10px;
  5059. top: 3px;
  5060. font-size: 60px;
  5061. }
  5062. .fsfb-modal-body>div{
  5063. color: ffffffb0;
  5064. margin: 10px 20px;
  5065. }
  5066. .fsfb-modal-body>table{
  5067. width: 90%;
  5068. margin: 10px 20px;
  5069. }
  5070. .fsfb-cmd-title{
  5071. color: white;
  5072. white-space: nowrap;
  5073. padding-right: 12px !important;
  5074. }
  5075. .fsfb-modal-body>table th{
  5076. color: white;
  5077. }
  5078. .fsfb-modal-body>table td{
  5079. padding: 4px 0;
  5080. }
  5081. .fsfb-modal-body>div>span{
  5082. color: white;
  5083. }
  5084. .fsfb-modal-body{
  5085. margin: 10px 10px;
  5086. font-size: 20px;
  5087. max-height: 600px;
  5088. overflow-y: auto;
  5089. }
  5090. .fsfb-modal-title{
  5091. text-align: center;
  5092. color: white;
  5093. }
  5094. .fsfb-hotkey{
  5095. background-color: #df901c;
  5096. color: #fff;
  5097. cursor: pointer;
  5098. text-align: center;
  5099. min-width: 40px;
  5100. max-width: 60px;
  5101. height: 18px;
  5102. line-height: 18px;
  5103. vertical-align: middle;
  5104. border-radius: 9px;
  5105. right: 5px;
  5106. position: absolute;
  5107. display: inline-block;
  5108. padding: 0 5px;
  5109. overflow: hidden;
  5110. opacity: 1;
  5111. }
  5112. .fsfb-modal-body::-webkit-scrollbar-thumb {
  5113. background-color: #57595b;
  5114. border: 1px solid black;
  5115. border-radius: 12px;
  5116. }
  5117. .fsfb-modal-body::-webkit-scrollbar {
  5118. border: 1px solid black;
  5119. background-color: #2523239e;
  5120. width: 15px;
  5121. border-radius: 12px;
  5122. }
  5123. .fsfb-modal-body::-webkit-scrollbar-track {
  5124. -webkit-box-shadow: inset 0px 0px 2px 2px rgba(0, 0, 0, 0.75);
  5125. box-shadow: inset 0px 0px 2px 2px rgba(0, 0, 0, 0.75);
  5126. border-radius: 12px;
  5127. }
  5128. .fsfb-hotkey:hover {
  5129. background-color: #f1a02d;
  5130. }
  5131. .fsfb-hotkey.selected{
  5132. background-color: #ff4;
  5133. color: #444;
  5134. }
  5135. #fsfb-settings-main p{
  5136. margin: 0;
  5137. display: inline-block;
  5138. margin-left: 4px;
  5139. }
  5140. #fsfb-settings-main{
  5141. display: -ms-grid;
  5142. display: grid;
  5143. -ms-grid-columns: 50% 50%;
  5144. grid-template-columns: 50% 50%;
  5145. }
  5146. #settingPage4::-webkit-scrollbar-thumb {
  5147. background-color: #ff9800c2;
  5148. border-radius: 12px;
  5149. border: 1px #000000c2 solid;
  5150. }
  5151. #settingPage4::-webkit-scrollbar {
  5152. border: 1px solid #00000085;
  5153. background-color: #2523239e;
  5154. width: 9px;
  5155. border-radius: 12px;
  5156. }
  5157. #settingPage4{
  5158. display: none;
  5159. max-height: 660px;
  5160. overflow-x: hidden;
  5161. }
  5162. .padbot10{
  5163. padding-bottom: 10px;
  5164. }
  5165. #fsfb-slowfeedtime, #fsfb-dubsecdelay, #fsfb-dubfirstdelay, #fsfb-secdelay, #fsfb-fvsdelay, #fsfb-firstdelay, #fsfb-threesecdelay, #fsfb-threefirstdelay{
  5166. border: none;
  5167. width: 40px;
  5168. }
  5169. select.fsfb-quickchange{
  5170. background: none;
  5171. border: none;
  5172. height: 20px;
  5173. }
  5174. select.fsfb-quickchange:focus-visible{
  5175. outline: none;
  5176. }
  5177. select.fsfb-quickchange option{
  5178. background: #222;
  5179. }
  5180. .fsfb-sect-ch label{
  5181. display: flex;
  5182. align-items: center;
  5183. }
  5184. .fsfb-sect-ch label input{
  5185. margin: 0 2px 0 0;
  5186. }
  5187. .fsfb-colors div{
  5188. height: 18px;
  5189. aspect-ratio: 1;
  5190. }
  5191. .fsfb-colors input[type="color"]{
  5192. width: 100%;
  5193. height: 100%;
  5194. opacity: 0;
  5195. border: none;
  5196. background-color: white;
  5197. margin: 0;
  5198. cursor: pointer;
  5199. }
  5200. .fsfb-colors p{
  5201. min-width: 120px;
  5202. margin-left: 5px;
  5203. }
  5204. .fsfb-colors div{
  5205. border-radius: 4px;
  5206. border: 1px solid #ffffff29;
  5207. }
  5208. #fsfb-ximport-cont{
  5209. display: flex;
  5210. justify-content: space-around;
  5211. margin-top: 7px;
  5212. }
  5213. .fsfb-eximport{
  5214. background-color: #df901c;
  5215. color: white;
  5216. padding: 5px 17px;
  5217. border-radius: 25px;
  5218. cursor: pointer;
  5219. }
  5220. .hideMegaphone{
  5221. display: none !important;
  5222. }
  5223. .fsfb-fake{
  5224. padding: 0 0 0 43px;
  5225. color: #cbff4e !important;
  5226. }
  5227. #fsfb-extra-info{
  5228. margin: 10% 0 0 90%;
  5229. cursor: pointer;
  5230. }
  5231. #linesplit-markers div {
  5232. background-color: transparent;
  5233. height: 15px;
  5234. aspect-ratio: 1;
  5235. position: fixed;
  5236. z-index: 999;
  5237. border: 2px solid rgb(255 255 255 / 80%);
  5238. border-radius: 50%;
  5239. display: none;
  5240. }
  5241. #linesplit-top {
  5242. top: -7.5px;
  5243. transform: translateX(-50%);
  5244. left: 50%;
  5245. }
  5246. #stats-container{
  5247. background: rgba(0,0,0,.5);
  5248. top: 200px;
  5249. position: absolute;
  5250. border: 1px white solid;
  5251. border-radius: 12px;
  5252. color:white;
  5253. left:30px;
  5254. }
  5255. #stats-main{
  5256. padding: 10px;
  5257. }
  5258. #stats-extra-info{
  5259. color: #00bbff;
  5260. font-size: 15px;
  5261. margin-bottom: 2px;
  5262. display: block;
  5263. }
  5264. #stats-info div{
  5265. display:flex;
  5266. }
  5267. #stats-info div p{
  5268. margin: 0;
  5269. }
  5270. .stats-completed{
  5271. margin: 9px 5px 0;
  5272. font-size: 12px;
  5273. bottom: 0;
  5274. color: rgb(255, 255, 255, .8);
  5275. }
  5276. #stats-title{
  5277. display: flex;
  5278. align-items: center;
  5279. justify-content: space-between;
  5280. }
  5281. #stats-title>div{
  5282. font-size: 15px;
  5283. margin-left: 8px;
  5284. cursor: pointer;
  5285. }
  5286. #stats-title>div>div{
  5287. padding: 0 5px;
  5288. }
  5289. #linesplit-right {
  5290. right: -7.5px;
  5291. transform: translateY(-50%);
  5292. top: 50%;
  5293. }
  5294. #linesplit-bottom {
  5295. bottom: -7.5px;
  5296. transform: translateX(-50%);
  5297. left: 50%;
  5298. }
  5299. #linesplit-left {
  5300. left: -7.5px;
  5301. transform: translateY(-50%);
  5302. top: 50%;
  5303. }
  5304. .fsfb-removeAds{
  5305. transform: translateX(9999%) !important;
  5306. }`;
  5307. document.querySelector('body').append(styles);
  5308. }();
  5309.  
  5310. if(userPreferences.level1kFix){
  5311. $('.innerBoxDashboard2>div>div').css('max-width', '210px');
  5312. $('#levelTopLeft').css({'min-width': '30%', 'max-width': '90px', width: 'unset'});
  5313. $('#fpsBox').css('left', '220px');
  5314. }
  5315. if(!userPreferences.tripleFastSplitSetting){
  5316. $('#fsfb-fsThree, #fsfb-threefirstdelay, #fsfb-threesecdelay').prevUntil('input').hide();
  5317. }
  5318.  
  5319. const scripts = document.createElement('script');
  5320. scripts.innerHTML = `const onlyNumberKey = (e, key) => (key = e.which || e.keyCode, 48 <= key && key <= 57);`;
  5321.  
  5322. let script_id = 446564; // main script
  5323. let version_timestamp = 1707000000000;
  5324. // @changelog fsfb 40k install update! Custom name setting, hide mod messages setting in TM menu, bugfixes, and more
  5325. if (+getStorage("lastUpdateCheck", "0") + 864e5 <= Date.now() && typeof GM_xmlhttpRequest == 'function' && userPreferences.notifyNewUpdates) {
  5326. try {
  5327. GM_xmlhttpRequest({
  5328. method: "GET",
  5329. url: `https://greasyfork.org/en/scripts/${script_id}/code?${Date.now()}`,
  5330. headers: {
  5331. 'Cache-Control': 'no-cache'
  5332. },
  5333. onload: function(xhrResponse) {
  5334. setStorage("lastUpdateCheck", String(Date.now()));
  5335. const rt = xhrResponse.responseText.replace(/&nbsp;?/gm, " ").replace(/&#x000A;/g, "\n").replace(/<li>/gm, "\n").replace(/<[^>]*>/gm, "");
  5336. if (+(rt?.match(/version_timestamp\s*=\s*([0-9]+)/)?.[1] ?? 0) > version_timestamp) {
  5337. let changelog = rt.match(/(?<=@changelog\s+)(?:\S).+$/gm)?.[0] ?? 'unable to find',
  5338. version = rt.match(/(?<=@version\s+)(?:\S).+$/gm)?.[0] ?? 'unable to find';
  5339. swal({
  5340. title: `<span style="color: #8CEFFF;">fsfb update!</span>`,
  5341. text: `<span style="color: #BBF6FF;">It appears there's a new update available for fsfb script (version: ${version})</br>Changelog: ${changelog}</span>`,
  5342. type: "info",
  5343. confirmButtonColor: "#2cb7f7",
  5344. confirmButtonText: 'Install fsfb Update',
  5345. html: true,
  5346. focusCancel: true,
  5347. // cancelButtonColor: "#29b962",
  5348. // cancelButtonText: 'Install Auto-Updating fsfb',
  5349. // showCancelButton: true,
  5350. customClass: 'fsfb-update-swal'
  5351. }, function(val) {
  5352. if(val){ // install new update
  5353. unsafeWindow.open(`https://greasyfork.org/scripts/${script_id}/`);
  5354. }
  5355. });
  5356. }
  5357. }
  5358. });
  5359. } catch (err) {
  5360. console.error("FSFB: An error occurred while checking for updates:\n" + err);
  5361. }
  5362. }
  5363.  
  5364. document.querySelector('body').append(scripts);
  5365. unsafeWindow.fsfbScriptsLoaded = true;
  5366. // $('#gameSettingsTab a')[0].click(); // att
  5367. // $('#settingTab4')[0].click();
  5368. };
  5369.  
  5370.  
  5371. if(unsafeWindow.fsfbScriptsLoaded || unsafeWindow.fsfbEvListenerAdded) alert('It appears fsfb scripts is already loaded. It\'s recommended to only use one instance of fsfb at a time.');
  5372. (document.readyState === "complete" ? setTimeout(afterLoaded, 1) : (document.addEventListener("DOMContentLoaded", afterLoaded), unsafeWindow.fsfbEvListenerAdded = true));