What you can do is club your actions that you want to undo into a single script action so that you can undo all the changes done by that method with a single undo. So we will be using the undo modes as mentioned by @BarlaeDC . In the sample below I call a method as a single script action. This method adds a frame and adds contents two times to this frame. So in effect it does three operations on the document so should add three actions to the undo stack. However with us clubbing it into one, you can call undo just once and all the actions will be reversed. You also name your operations into a single stack operation as "testaction"
function testMethod(arg1, arg2){
var doc = app.documents[0]
var tf = doc.textFrames.add()
tf.geometricBounds = [0, 0, 100, 200]
tf.contents += arg1
tf.contents += arg2
}
app.doScript("testMethod(arguments[0], arguments[1])", ScriptLanguage.JAVASCRIPT, ["arg1", "arg2"], UndoModes.ENTIRE_SCRIPT, "testaction")
//Now if you use just a single undo, all the operations by the method are undone
//app.documents[0].undo()
-Manan