diff options
| author | Fuwn <[email protected]> | 2024-01-08 13:28:46 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2024-01-08 13:28:46 -0800 |
| commit | 3102f457a583b56e21a4953af5c576e9a86c8025 (patch) | |
| tree | ec32840486b8eb4cf5b3504dc5e8759df7d1401e /src/lib/Tools/DumpProfile.svelte | |
| parent | fix(hovercover): page scroll height (diff) | |
| download | due.moe-3102f457a583b56e21a4953af5c576e9a86c8025.tar.xz due.moe-3102f457a583b56e21a4953af5c576e9a86c8025.zip | |
feat(dump): decode hoh's
Diffstat (limited to 'src/lib/Tools/DumpProfile.svelte')
| -rw-r--r-- | src/lib/Tools/DumpProfile.svelte | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/src/lib/Tools/DumpProfile.svelte b/src/lib/Tools/DumpProfile.svelte index f01814e6..1f0eba7e 100644 --- a/src/lib/Tools/DumpProfile.svelte +++ b/src/lib/Tools/DumpProfile.svelte @@ -2,8 +2,27 @@ import { dumpUser } from '$lib/AniList/user'; import RateLimited from '$lib/Error/RateLimited.svelte'; import InputTemplate from './InputTemplate.svelte'; + import LZString from 'lz-string'; let submission = ''; + + // Credit: @hoh + const decodeJSON = (about: string): JSON | null => { + const match = (about || '').match(/^\[\]\(json([A-Za-z0-9+/=]+)\)/); + + if (match) + try { + return JSON.parse(atob(match[1])); + } catch { + try { + return JSON.parse(LZString.decompressFromBase64(match[1])); + } catch { + return null; + } + } + + return null; + }; </script> <!-- svelte-ignore missing-declaration --> @@ -11,8 +30,22 @@ {#await dumpUser(submission)} Loading user ... 50% {:then dump} - <pre style="margin: 0;">{JSON.stringify(dump, null, 2)}</pre> + {@const decoded = decodeJSON(dump.about)} + + <pre>{JSON.stringify(dump, null, 2)}</pre> + + {#if decoded && (dump.about || '').includes('[](json')} + <p /> + + <pre>{JSON.stringify(decoded, null, 2).replaceAll(/\\n/g, '\n')}</pre> + {/if} {:catch} <RateLimited type="User" list={false} /> {/await} </InputTemplate> + +<style> + pre { + margin: 0; + } +</style> |