generated at
長いタイトルを刻むページを簡単に作れるUserScript
(deprecated)複数のリンクを含んだ文字列を長いタイトルを刻むページにするUserScript

PopupMenuで実装する
複数行では実行しない

たくさん作るとこうなる


2023-04-30
18:33:06 for-custom-new-page#63e00aab1280f00000e11d1fがバグって動かないので、こちらを使うことにする
バグの原因がわからない
2023-02-06
05:18:39 for-custom-new-page#63e00aab1280f00000e11d1fでhookとして実装しなおした
このページのUserScriptはdeprecatedとする
2023-02-04
05:30:34 わざわざ作る必要あった?
エッジケースすぎる
やるなら、汎用的で小さな機能の組み合わせで実現すべきだった
custom-new-pageで実装しよう

$ deno check --remote -r=https://scrapbox.io https://scrapbox.io/api/code/takker/長いリンクを刻むページを簡単に作れるUserScript/main.ts
main.ts
import { useStatusBar, patch } from "../scrapbox-userscript-std/mod.ts"; import { delay as sleep } from "../deno_std%2Fasync/mod.ts"; import { Scrapbox } from "../scrapbox-jp%2Ftypes/userscript.ts"; declare const scrapbox: Scrapbox; const enable = (text: string) => !text.includes("\n") && /\[[^\]]+\]/.test(text); scrapbox.PopupMenu.addButton({ title: (text) => enable(text) ? "[][]" : "", onClick: (text) => { if (!enable(text)) return; const title = text.replaceAll("[", "").replaceAll("]", ""); (async () => { const { render, dispose } = useStatusBar(); try { const project = scrapbox.Project.name; render( { type: "spinner" }, { type: "text", text: `create /${project}/${title}` }, ); await patch( project, title, ([{ text: title }], { persistent }) => { // 中身があるときは何もしない if (persistent) return; return [title, text]; }, ); render( { type: "check-circle" }, { type: "text", text: `create /${project}/${title}` }, ); } catch(e) { console.error(e); if (!(e instanceof Error)) throw e; render( { type: "exclamation-triangle" }, { type: "text", text: `${e.name} ${e.message}` }, ); } finally { await sleep(2000); dispose(); } })(); return `[${title}]`; }, });

#2023-06-14 19:01:19
#2023-02-06 05:19:22
#2023-02-04 05:31:51
#2023-02-03 06:20:23