Satisfactory Collectable Tracker

Plugin for the satisfactory map

  1. // ==UserScript==
  2. // @name Satisfactory Collectable Tracker
  3. // @namespace luxferre.dev
  4. // @version 1.0.0
  5. // @description Plugin for the satisfactory map
  6. // @author Lux-Ferre
  7. // @license MIT
  8. // @match *://satisfactory-calculator.com/en/interactive-map*
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. class CollectableTracker{
  13. constructor(){
  14. this.found_harddrives = []
  15. this.found_spheres = []
  16. this.found_sloops = []
  17. this.load()
  18. setTimeout(() => {
  19. ct.init()
  20. }, 3000)
  21. }
  22. init(){
  23. for (const [key, marker] of Object.entries(SCIM.map.availableLayers.hardDrives._layers)) {
  24. if (this.found_harddrives.includes(marker.options.pathName)){
  25. SCIM.map.leafletMap.removeLayer(marker)
  26. } else {
  27. marker.on("click", e=>{
  28. this.mark_found_hd(e)
  29. this.refresh_hd_markers()
  30. })
  31. }
  32. }
  33. for (const [key, marker] of Object.entries(SCIM.map.availableLayers.mercerSpheres._layers)) {
  34. if (this.found_spheres.includes(marker.options.pathName)){
  35. SCIM.map.leafletMap.removeLayer(marker)
  36. } else {
  37. marker.on("click", e=>{
  38. this.mark_found_spheres(e)
  39. this.refresh_sphere_markers()
  40. })
  41. }
  42. }
  43. for (const [key, marker] of Object.entries(SCIM.map.availableLayers.somersloops._layers)) {
  44. if (this.found_spheres.includes(marker.options.pathName)){
  45. SCIM.map.leafletMap.removeLayer(marker)
  46. } else {
  47. marker.on("click", e=>{
  48. this.mark_found_sloops(e)
  49. this.refresh_sloop_markers()
  50. })
  51. }
  52. }
  53. this.refresh_sloop_markers()
  54. }
  55. save(){
  56. const hd_str = JSON.stringify(this.found_harddrives)
  57. localStorage.setItem("plugin_hd_found", hd_str)
  58. const sphere_str = JSON.stringify(this.found_spheres)
  59. localStorage.setItem("plugin_sphere_found", sphere_str)
  60. const sloop_str = JSON.stringify(this.found_sloops)
  61. localStorage.setItem("plugin_sloop_found", sloop_str)
  62. }
  63. load(){
  64. const hd_str = localStorage.getItem("plugin_hd_found")
  65. if (hd_str){this.found_harddrives = JSON.parse(hd_str)}
  66. const sphere_str = localStorage.getItem("plugin_sphere_found")
  67. if (sphere_str){this.found_spheres = JSON.parse(sphere_str)}
  68. const sloop_str = localStorage.getItem("plugin_sloop_found")
  69. if (sloop_str){this.found_sloops = JSON.parse(sloop_str)}
  70. }
  71. mark_found_hd(e){
  72. this.found_harddrives.push(e.target.options.pathName)
  73. this.save()
  74. }
  75. refresh_hd_markers(){
  76. for (const [key, marker] of Object.entries(SCIM.map.availableLayers.hardDrives._layers)) {
  77. if (this.found_harddrives.includes(marker.options.pathName)){
  78. SCIM.map.leafletMap.removeLayer(marker)
  79. }
  80. }
  81. }
  82. mark_found_spheres(e){
  83. this.found_spheres.push(e.target.options.pathName)
  84. this.save()
  85. }
  86. refresh_sphere_markers(){
  87. for (const [key, marker] of Object.entries(SCIM.map.availableLayers.mercerSpheres._layers)) {
  88. if (this.found_spheres.includes(marker.options.pathName)){
  89. SCIM.map.leafletMap.removeLayer(marker)
  90. }
  91. }
  92. }
  93. mark_found_sloops(e){
  94. this.found_sloops.push(e.target.options.pathName)
  95. this.save()
  96. }
  97. refresh_sloop_markers(){
  98. for (const [key, marker] of Object.entries(SCIM.map.availableLayers.somersloops._layers)) {
  99. if (this.found_sloops.includes(marker.options.pathName)){
  100. SCIM.map.leafletMap.removeLayer(marker)
  101. }
  102. }
  103. }
  104. }
  105.  
  106. window.ct = new CollectableTracker()