fsfb script

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

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

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