While I was doing my modification, I had a strange bug and I did not know how to fix it. When loading a save, all territories disappeared from the map, and only after the capture of any territory did they reappear on the map. By scientific poke, I was able to find a solution, but also an interesting effect appeared that I liked and I decided to post it here.
Now, when capturing a territory, it will not flicker red on the map, it will have the color of its grouping during the capture, and with each wave it will become more and more colored in the color of your grouping.