import { useStatusBar } from "../scrapbox-userscript-std/dom.ts"; import { upload } from "../scrapbox-file-uploader/mod.ts"; const main = async () => { const textList = [] as string[]; const { render, dispose } = useStatusBar(); try { const fileList = await upload({ accept: "text/plain", multiple: true }); if (!fileList) return; const compare = new Intl.Collator().compare; const files = Array.from(fileList) .sort((a, b) => compare(a.name, b.name)); let counter = 0; for (const file of files) { textList.push(await file.text()); render( { type: "spinner" }, { type: "text", text: `${files.length} files, ${counter} proceed`, }, ); } render( { type: "check-circle" }, { type: "text", text: `Finish process.` }, ); console.log(textList); const blob = new Blob([JSON.stringify(textList)], { type: "application/json" }); window.open(URL.createObjectURL(blob)); } finally { setTimeout(() => { dispose(); }, 1000); } }; await main();