fsfb script

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

当前为 2024-03-13 提交的版本,查看 最新版本

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