行IDからページの行を検索する
from Settings
これどこの行を指してるの・・・( ◞‸◟)Mijikko.icon
”これ”:特定の行でだけ使える文字装飾記法で指定されているID
どこなんだろう……?takker.icon
はー、仕方ない。script組むか。
その場ですぐ組めるのつよすぎMijikko.icon
code:js
const targets = [
"60925f6aff23a500238c845c",
"607e9b43246f5900006eca5e",
"5ff2e3cf1280f0000034b08f",
"6016932ad4387500007799a9",
"6016925dd4387500007f6f77",
"60ef82d8fa8faf00007108d2",
];
const titleLcs =
scrapbox.Project.pages.flatMap(({exists, titleLc}) => exists ? titleLc : []);
const count = titleLcs.length;
const chunk = 50;
const end = Math.floor(count / chunk) + 1;
const results = [];
for (let i = 0; i < end; i++) {
const temp = await Promise.all(
titleLcs.slice(i * chunk, (i + 1) * chunk)
.map((titleLc, j) => check(titleLc, j + i * chunk))
);
results.push(
...temp.filter((founds) => founds.length > 0)
);
}
if (results.length === 0) {
console.log("Not found");
} else {
console.log("Found:");
for (const titleLc, founds of results) {
for (const id of founds) {
console.log(\t https://scrapbox.io/${scrapbox.Project.name}/${titleLc}#${id});
}
}
}
async function check(titleLc, index) {
const res = await fetch(`/api/pages/${
scrapbox.Project.name
}/${encodeURIComponent(titleLc)}`);
const { lines } = await res.json();
const ids = lines.map(({ id }) => id);
const founds = targets.filter(id => ids.includes(id));
console.log(`${index}/${count} check "${titleLc}"...${
founds.length > 0 ? found ${founds}! : "not found."
}`);
return titleLc, founds;
}
17:45:58 テストする
17:54:02 実行中
時間かかるなあ
17:55:31 半分走査した
17:58:10 5000おわた
18:01:19 終了
結果
Settings#6016932ad4387500007799a9
移植した
特定の行でだけ使える文字装飾記法#61fe3ee37838e300007de69e
/villagepump/UserScriptを他人のprojectから読み込むな#5ff2e3cf1280f0000034b08f
/villagepump/日本沈没#60925f6aff23a500238c845c
/villagepump/2021/07/15#60ef82d8fa8faf00007108d2
/villagepump/シャイニング#607e9b43246f5900006eca5e
/villagepump/次回予告#6016925dd4387500007f6f77
黒背景の記法を作れば減らせそうMijikko.icon
その記法自体に需要があるのかは微妙すぎると思うけど
とりあえず移植した
特定の行でだけ使える文字装飾記法#61fe3ec77838e300007de69b
/icons/+1.icontakker.icon