| 36 | }; |
| 37 | |
| 38 | export const getTempCode = async (tempUUID: string): Promise<string | undefined> => { |
| 39 | try { |
| 40 | const folder = await navigator.storage.getDirectory().then((root) => root.getDirectoryHandle("temp_install_codes")); |
| 41 | const handle = await folder.getFileHandle(`${tempUUID}.user.js`); |
| 42 | return await handle.getFile().then((f) => f.text()); |
| 43 | } catch (err: any) { |
| 44 | if (err?.name === "NotFoundError") { |
| 45 | return undefined; |
| 46 | } |
| 47 | console.error("[scriptInstall] getTempCode failed:", err); |
| 48 | throw err; |
| 49 | } |
| 50 | }; |
| 51 | |
| 52 | export const removeCachedCodes = async (uuids: string[]) => { |
| 53 | if (!uuids.length) return; |