It would be a good thing if such a script could be implemented. But until the problem is solved you can just restrict yourself.
For example, in my Romani campaigns when I want to recreate the first punic war, I invade the Karthadastim heartlands only with decent armies and after the landing I wait for 4 turns before making any move, thus giving the stupid AI time to bring back their forces which are taking a stroll in Mauretania or Phasania. I combine this with teleporting enemy fullstacks in Italy and avoiding capturing Lilibeo until the end of the war. You will be amazed at the number and the intensity of battles you will have to go through if you follow such simple house rules.
Bookmarks