import { upload } from "../scrapbox-file-uploader/mod.ts"; import { scrape } from "../YAMAPの登山計画データをCompassSourceに変換するscript/mod.ts"; import { write, CompassSource } from "../コンパスに自動入力するscript/mod.ts"; (async () => { if ( `${location.protocol}//${location.hostname}${location.pathname}` === "https://www.mt-compass.com/reportedit.php" ) { const file = await upload({ accept: ".json" }); if (!file) return; const json = JSON.parse(await file.text()) as CompassSource; write(json); return; } const json = scrape(); if (!json) return; const url = URL.createObjectURL( new Blob([JSON.stringify(json)], { type: "application/json" }) ); const a = document.createElement("a"); a.href = url; a.download = `${json.area}.json`; a.style.display = "none"; document.body.append(a); a.click(); a.remove(); })();