Skip to content

Instantly share code, notes, and snippets.

@oov

oov/addkome.jsx Secret

Last active April 15, 2021 16:03
Show Gist options
  • Save oov/98644643cbc37ad5d3cecbd245b22b37 to your computer and use it in GitHub Desktop.
Save oov/98644643cbc37ad5d3cecbd245b22b37 to your computer and use it in GitHub Desktop.
Photopea 用スクリプト「選択中のレイヤーと同じ階層にある全てのレイヤー名の先頭に「*」を追加する」
// https://www.photopea.com/ 用スクリプト(紹介動画: https://twitter.com/oovch/status/1200969778292125696 )
// 選択中のレイヤーと同じ階層にある全てのレイヤー名の先頭に「*」を追加する
// ファイルメニューのスクリプトを開いて、↓を貼り付けて「Run」を押す
function findSelectedParent(doc) {
function find(l) {
const t = l.typename;
if (t == "Document" || t == "LayerSet") {
for (let i=0; i<l.layers.length; ++i) {
const l2 = l.layers[i];
if (l2.selected) {
return l;
}
const r = find(l2);
if (r) {
return r;
}
}
}
}
const r = find(doc);
return r;
}
const ls = findSelectedParent(app.activeDocument);
for (let i=0;i<ls.layers.length;++i){
ls.layers[i].name = "*" + ls.layers[i].name;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment