-
-
Save oov/98644643cbc37ad5d3cecbd245b22b37 to your computer and use it in GitHub Desktop.
Photopea 用スクリプト「選択中のレイヤーと同じ階層にある全てのレイヤー名の先頭に「*」を追加する」
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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