Thanks. Yes I see it in Alchemist but it doesn’t seem to be in the DOM.
This is a bit beyond my experience so I’ve had AI assist. With that caveat the following seems to work…
//Checks if a layer mask or quick mask is currently active
async function isMaskActive() {
const targetChannels = await getTargetChannels();
// If targetChannels is a single channel with _index: 4, mask is active
return (
Array.isArray(targetChannels) &&
targetChannels.length === 1 &&
targetChannels[0]._index === 4
);
}
async function getTargetChannels() {
const app = require("photoshop").app;
const doc = app.activeDocument;
const layer = doc.activeLayers && doc.activeLayers.length > 0 ? doc.activeLayers[0] : null;
if (!layer) {
console.log("No active layer.");
return null;
}
const result = await batchPlay(
[{
_obj: "get",
_target: [
{ _ref: "layer", _id: layer.id }
],
_options: { dialogOptions: "dontDisplay" }
}],
{}
);
// The targetChannels property should be in result[0]
return result[0].targetChannels || null;
}