If you're only working with pathItems and compoundPathItems, this script will work. If you've got groups within your selection, things get much more difficult because unless you can predict the grouping order and the number of subgroups, you need a recursive loop to ensure that all pathItems' colors are changed.
Hopefully this is good enough for ya. let me know.
function test()
{
var docRef = app.activeDocument;
var sel = docRef.selection;
var blackColor = new CMYKColor();
blackColor.cyan=0;
blackColor.magenta=0;
blackColor.yellow=0;
blackColor.black=100;
blackColor.name = "Script Defined Black";
for(var a=0;a<sel.length;a++)
{
var thisSel = sel;
if(thisSel.typename == "PathItem")
{
thisSel.fillColor = blackColor;
}
else if(thisSel.typename == "CompoundPathItem")
{
for(var b=0;b<thisSel.pathItems.length;b++)
{
var thisInnerSel = thisSel.pathItems;
thisInnerSel.fillColor = blackColor;
}
}
}
}
test();