Function to Restore Original Channel Visibility
Does anyone have a function to restore the original channel visibility?
The idea is to have something similar to the standard DOM feature:
// Set the active channels
var savedChannelState = activeDocument.activeChannels;
// Do stuff that changes the original active/selected channels
// Reset the saved active channels
activeDocument.activeChannels = savedChannelState;
However, rather than returning the original active/selected channels, it would restore the original visibility of the various channels (whether component, spot, alpha etc).
Another possible approach would be to not change the existing channel visibility when making the channel active in the for loop... but how?

In this example, all channels except one are visible before some "other" script code is run. If the "other" script code in a for loop changes the visibility, I'd like to reset it to what it was before the "other" code was run.
I was expecting to find an existing function for this as it would appear to be a common enough task, however, I haven't had any luck and have had no joy in trying to hack something together myself.
Can somebody please help?
