#target illustrator
function test(){
function isSquare(item){
if(item.pathPoints.length > 4){
return false;
}
for(var i=0; i<item.pathPoints.length; i++){
var thisPoint = item.pathPoints;
if(Math.floor(thisPoint.leftDirection[0]) != Math.floor(thisPoint.rightDirection[0]) ||
Math.floor(thisPoint.leftDirection[1]) != Math.floor(thisPoint.rightDirection[1]) ||
Math.floor(thisPoint.leftDirection[0]) != Math.floor(thisPoint.anchor[0]) ||
Math.floor(thisPoint.leftDirection[1]) != Math.floor(thisPoint.anchor[1])){
return false;
}
}
return true;
}
if(app.documents.length > 0){
var doc = app.activeDocument;
for(var i=0; i<doc.pathItems.length; i++){
var thisPath = doc.pathItems;
if(isSquare(thisPath)){
var v = thisPath.geometricBounds;
for(var j=0; j<doc.pathItems.length; j++){
var thisInnerPath = doc.pathItems;
if(thisInnerPath != thisPath){
var v1 = thisInnerPath.geometricBounds;
if(v1[0] >= v[0] && v1[2] <= v[2] && v1[1] <= v[1] && v1[3] >= v[3]){
thisInnerPath.fillColor = thisPath.fillColor;
}
}
}
}
}
}
}
test();