var totalItens = app.activeDocument.pageItems.length;
var items = app.activeDocument.pageItems;
for (i = 0; i < totalItens; i++){
if(items.typename == 'PathItem'){
if (items.fillColor.cyan == 0 && items.fillColor.magenta == 0 && items.fillColor.yellow == 0 && items.fillColor.black == 100){
if (items.fillOverprint == false){
items.fillOverprint = true;
};
};
if (items.strokeColor.cyan == 0 && items.strokeColor.magenta == 0 && items.strokeColor.yellow == 0 && items.strokeColor.black == 100){
if (items.strokeOverprint == false){
items.strokeOverprint = true;
};
};
};
if(items.typename == 'TextFrame'){
for ( var j = 0; j < items.textRanges.length; j++ ) {
if (items.textRanges.fillColor.cyan == 0 && items.textRanges.fillColor.magenta == 0 && items.textRanges.fillColor.yellow == 0 && items.textRanges.fillColor.black == 100){
if (items.textRanges.characterAttributes.overprintFill == false){
items.textRanges.characterAttributes.overprintFill = true;
};
};
if (items.textRanges.strokeColor.cyan == 0 && items.textRanges.strokeColor.magenta == 0 && items.textRanges.strokeColor.yellow == 0 && items.textRanges.strokeColor.black == 100){
if (items.textRanges.characterAttributes.overprintStroke == false){
items.textRanges.characterAttributes.overprintStroke = true;
};
};
};
};
};
And, answering the second question: Yes OfCourse, you can unlock the layers, perform some operations and then lock it back. But is better you say what you trying to do, what the purpose of this?
I hope helped, bests, Vinícius.