This version requires you change the variable to suit your LayerSet name.
#target photoshop;
if(documents.length){
main();
}else{
alert("You need a document open to run this script!");
}
function main(){
//////////////////////////////////////////////////////////////////////
// Change "Default Actions" to the name of your LayerSet
var ASname = "Default Actions";
/////////////////////////////////////////////////////////////////////
if(!checkActionExists(ASname.toString())) {
alert("\"" +ASname+ "\"" + " does not exist!\nPlease check your spelling\nIt is case sensitive!")
return;
}
var ActionSets =getActionSets();
for(var a in ActionSets){
if(ActionSets.toString() == ASname.toString()){
var Actions = getActions(ActionSets.toString());
var RA = Actions[Math.floor(Math.random() * Actions.length)];
try{
app.doAction(RA.toString(), ASname.toString());
}catch(e){};
break;
}
}
};
function checkActionExists( setName, actionName ){
var res = false;
try{
var ref = new ActionReference();
if(actionName != undefined){
ref.putName( charIDToTypeID( 'Actn' ), actionName );
}
ref.putName( charIDToTypeID( "ASet" ), setName );
executeActionGet( ref );
res = true;
}catch(e){return false}
return res;
};
function getActionSets(){
var aSets=[];
var z = 1;
while(true){
var ref = new ActionReference();
ref.putIndex(charIDToTypeID('ASet'), z);
try{
var desc = executeActionGet(ref);
var actName = desc.getString(charIDToTypeID('Nm '));
aSets.push(actName);
z++;
}catch(e){return aSets;}
}
};
function getActions(aSet){
var names = [];
var z =1;
while(true){
var ref = new ActionReference();
ref.putIndex(charIDToTypeID('Actn'), z);
ref.putName(charIDToTypeID('ASet'), aSet);
try{
var adesc = executeActionGet(ref);
var actName = adesc.getString(charIDToTypeID('Nm '));
names.push(actName);
z++;
}catch(e){return names;}
}
};