I had expected there to be lots of people asking this so that suggests that it's either very easy and I am being dumb or it's very hard and that's why no one is trying it.
How do I run a script so that the entire script counts as a single undo?
Either create a snapshop and revert back to it or use suspendHistory()
if(documents.length) app.activeDocument.suspendHistory('History Name', 'functionName()');
can you use the same for InDesign? If so, where do you add into the script?