Adobe Photoshop Scripting DOM does not cover all of Photoshop Feature so you can not script many of Photoshop feature using DOM code. Often scripts need to use Action Manager code to script Photoshop features that the actions can be recorder for. On Adobe's Web Site there is a Plug-in you can install in Photoshop "Scriptlistener" when installed it will record two log on your desktop one is a javascript log the other a vbs log. Every thing you do in Photoshop that can be recorded in an action will recorded in Action Manager code in these logs. Like Actions the code will have Steps with hard coder step settings. But you can change the setting into variables and create functions you can use in your scripts. So it is easy to select a Frame Animation frame by number with a function that uses Action Manager code, If you know the layers you want visible in a particular frame, Target the Frame by number then then use DOM code on Photoshop scripting layer objects and set the layers visibility. You do not actually merge layers you set the layers visibility the form the frame's composite image. The code between{} is action manager code I changed the hard coded frame number to a variable frameNumber and create the function selectFrame.
function selectFrame(frameNumber) {
var idslct = charIDToTypeID( "slct" );
var desc9 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref3 = new ActionReference();
var idanimationFrameClass = stringIDToTypeID( "animationFrameClass" );
ref3.putIndex( idanimationFrameClass, frameNumber );
desc9.putReference( idnull, ref3 );
executeAction( idslct, desc9, DialogModes.NO );
}
selectFrame(10)