Hi,
try following snippet to select all rectangles with magenta stroke.
#target illustrator
function main() {
app.selection = null;
var doc = app.activeDocument;
var _path;
for (var i = 0; i < doc.pathItems.length; i++) {
_path = doc.pathItems[i];
if (_path.stroked && _path.strokeColor.magenta > 25) {
_path.selected = true;
}
}
}
main();
Best regards