hasLayerMask

function hasLayerMask(layer) {    var ref = new ActionReference();    ref.putProperty(charIDToTypeID(“Prpr”), stringIDToTypeID(“hasUserMask”));    ref.putIdentifier(charIDToTypeID(“Lyr “), layer.id);    return executeActionGet(ref).getBoolean(stringIDToTypeID(“hasUserMask”));}
// Helper function to check if the mask is currently selected by testing if RGB channels are hiddenfunction isMaskSelected() {    try {        var rgbVisible = areRGBChannelsVisible();        return !rgbVisible; // If RGB channels are not visible, assume the mask is selected    } catch (e) {        return false; // If an error occurs, assume the mask is not selected    }}
// Set the tool to Brush Tool



1
Using Format