feat(skills): add lawnb-pdf-download skill for saving LAWnB 주석서 pages as PDF

Scripts to probe a book's TOC, print each page-level item to PDF via the
print popup, verify, merge per 대항목 and clean up temp files. Invoked only
by /lawnb-pdf-download (disable-model-invocation).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-28 22:16:22 +09:00
co-authored by Claude Sonnet 5.5
parent 18fa95368b
commit b066471945
7 changed files with 371 additions and 0 deletions
@@ -0,0 +1,31 @@
// Dump the TOC subtree under one node of a LAWnB 주석서 book.
// Render with render.py (CFG = {bookUrl, rootRegex}) and run:
// ego-browser nodejs < rendered.js (sandbox must be disabled)
//
// Output: one line per TOC node. "pages" = number of page-level anchors
// (href id has exactly two parts) under that child. Roman-numeral sub-headings
// (three-part ids) are NOT pages; they are sections of the page above them.
const CFG = __CFG__;
const task = await taskSpace("lawnb probe " + Date.now());
const page = task.page("p1");
await page.goto(CFG.bookUrl, { timeout: 30000 });
await page.waitForTimeout(3500);
const lines = await page.evaluate((cfg) => {
const ownText = (li) => { const a = li.querySelector(':scope > a'); return a ? a.innerText.trim() : [...li.childNodes].filter(n => n.nodeType === 3).map(n => n.textContent.trim()).join(''); };
const root = [...document.querySelectorAll('li')].find(li => new RegExp(cfg.rootRegex).test(ownText(li)));
if (!root) return ['ROOT NOT FOUND for ' + cfg.rootRegex];
const isPage = (x) => /showTargetContent\('[^'|]+\|\d+\|R1'\)/.test(x.getAttribute('href') || '');
const out = [];
const walk = (li, d, maxDepth) => {
const a = li.querySelector(':scope > a');
const t = ownText(li);
const pages = [...li.querySelectorAll('a')].filter(isPage).length;
out.push(' '.repeat(d) + (t || '(no text)') + (a ? '' : ' [group: no link]') + ' pages=' + pages);
const ol = li.querySelector(':scope > ol, :scope > ul');
if (ol && d < maxDepth) [...ol.children].forEach(c => walk(c, d + 1, maxDepth));
};
walk(root, 0, cfg.depth || 1);
return out;
}, CFG);
console.log(lines.join('\n'));
await task.finish({ keep: [] });