What is the quickest method to undo all changes back to the source of the history?
Version: 2022
If you're talking about reverting to the previous save then just use
function revert_it()
{
var idRvrt = charIDToTypeID( "Rvrt" );
executeAction( idRvrt, undefined, DialogModes.NO );
}
You can also get the number of history states from the current document
var history = app.activeDocument.historyStates.length;