Question
Can someone help with this script?
I am trying to get a script that selects the background of a layer and fills it with green. This is repeated for all layers. There might well be more than one error, but so far, it is erroring out "doc.selection.load(layer transparency = false);"

#target photoshop
app.activeDocument.suspendHistory("Fill Background Green All Layers", "main()");
function main() {
var doc = app.activeDocument;
var originalLayer = doc.activeLayer;
for (var i = 0; i < doc.layers.length; i++) {
var layer = doc.layers[i];
if (layer.kind == LayerKind.NORMAL && layer.visible) {
doc.activeLayer = layer;
// Select transparent areas (background)
doc.selection.selectAll();
doc.selection.load(layer transparency = false);
doc.selection.invert();
// Set green color
var fillColor = new SolidColor();
fillColor.rgb.red = 0;
fillColor.rgb.green = 255;
fillColor.rgb.blue = 0;
// Fill the selection
doc.selection.fill(fillColor, ColorBlendMode.NORMAL, 100, false);
doc.selection.deselect();
}
}
doc.activeLayer = originalLayer;
}
