Commit e6493d3a authored by rockyl's avatar rockyl

增加埋点脚本

parent e9c228b4
/**
* Created by rockyl on 2019-11-25.
*/
var mergeFlagReg = /__m$/;
var oldDocument = app.activeDocument;
var mergeLayers = [];
var document = oldDocument.duplicate(oldDocument.name + '-合并', 0);
app.activeDocument = document;
merge(document);
function merge(document){
traverse(document, function(layer){
return layer.name.match(mergeFlagReg);
}, function(layer){
var newName = layer.name.replace(mergeFlagReg, '');
layer.name = newName;
mergeLayers.push(newName);
document.activeLayer = layer;
layer.merge();
});
if(mergeLayers.length > 0){
alert('合并的图层有: ' + mergeLayers.join(','));
}else{
alert('没有图层被合并');
}
}
function traverse(layer, filter, callback) {
if(layer.layers){
for (var i = 0; i < layer.layers.length; i++) {
var childLayer = layer.layers[i];
if (filter(childLayer)) {
callback(childLayer);
}else{
traverse(childLayer, filter, callback);
}
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment