blob: cbdd39166f7ec96f22cc6921b415f009b2612c8e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
<script>
import Notice from '$lib/Error/Notice.svelte';
import InputTemplate from '$lib/Tools/InputTemplate.svelte';
let submission = '';
$: mangaDexID = submission.match(/mangadex\.org\/title\/([a-f0-9-]+)\/?/)?.[1];
</script>
<InputTemplate field="MangaDex URL" bind:submission submitText="Read" preserveCase>
{#if mangaDexID}
{#await fetch(`https://api.mangadex.org/manga/${mangaDexID}/feed?order[chapter]=desc&translatedLanguage[]=en`)}
<!-- -->
{:then response}
{#if response.ok}
{#await response.json() then data}
{#if data.data}
<ul>
{#each data.data as chapter}
<li>
{#if chapter.attributes.volume}
Vol. {chapter.attributes.volume}
{/if}
Ch. {chapter.attributes.chapter}
<span class="opaque">|</span>
<a
href={`https://mangadex.org/chapter/${chapter.id}`}
target="_blank"
rel="noopener noreferrer"
>
{chapter.attributes.title}
</a>
</li>
{/each}
</ul>
{:else}
<p class="opaque">(⌣_⌣”)</p>
{/if}
{:catch error}
<Notice>{error}</Notice>
{/await}
{:else}
<Notice>Failed to fetch data from MangaDex</Notice>
{/if}
{:catch error}
{error}
{/await}
{:else}
<Notice>Invalid URL</Notice>
{/if}
</InputTemplate>
|