diff options
Diffstat (limited to 'src/lib/Reader')
| -rw-r--r-- | src/lib/Reader/Chapters/MangaDex.svelte | 14 | ||||
| -rw-r--r-- | src/lib/Reader/Chapters/Rawkuma.svelte | 6 | ||||
| -rw-r--r-- | src/lib/Reader/resource.ts | 50 |
3 files changed, 35 insertions, 35 deletions
diff --git a/src/lib/Reader/Chapters/MangaDex.svelte b/src/lib/Reader/Chapters/MangaDex.svelte index f1a90338..2bbf076f 100644 --- a/src/lib/Reader/Chapters/MangaDex.svelte +++ b/src/lib/Reader/Chapters/MangaDex.svelte @@ -1,15 +1,15 @@ <script lang="ts"> interface MangaDexChapter { - id: string; - attributes: { - volume?: string; - chapter: string; - title?: string; - }; + id: string; + attributes: { + volume?: string; + chapter: string; + title?: string; + }; } interface MangaDexData { - data: MangaDexChapter[]; + data: MangaDexChapter[]; } export let data: MangaDexData; diff --git a/src/lib/Reader/Chapters/Rawkuma.svelte b/src/lib/Reader/Chapters/Rawkuma.svelte index 02e0ed18..ee2ab116 100644 --- a/src/lib/Reader/Chapters/Rawkuma.svelte +++ b/src/lib/Reader/Chapters/Rawkuma.svelte @@ -1,11 +1,11 @@ <script lang="ts"> -import { getChaptersFromText } from '$lib/Data/Manga/raw'; -import { onMount } from 'svelte'; +import { getChaptersFromText } from "$lib/Data/Manga/raw"; +import { onMount } from "svelte"; export let data: string; onMount(() => { - console.log(); + console.log(); }); </script> diff --git a/src/lib/Reader/resource.ts b/src/lib/Reader/resource.ts index 2ee606b0..d00767c5 100644 --- a/src/lib/Reader/resource.ts +++ b/src/lib/Reader/resource.ts @@ -1,40 +1,40 @@ export enum Resource { - MangaDex = 'MangaDex', - Rawkuma = 'Rawkuma' + MangaDex = "MangaDex", + Rawkuma = "Rawkuma", } export const identify = (url: string): Resource | undefined => { - if (url.match(/mangadex\.org\/title\/([a-f0-9-]+)\/?/)?.[1]) { - return Resource.MangaDex; - } else if (url.match(/rawkuma\.com\/manga\/([a-z0-9-]+)\/?/)?.[1]) { - return Resource.Rawkuma; - } + if (url.match(/mangadex\.org\/title\/([a-f0-9-]+)\/?/)?.[1]) { + return Resource.MangaDex; + } else if (url.match(/rawkuma\.com\/manga\/([a-z0-9-]+)\/?/)?.[1]) { + return Resource.Rawkuma; + } - return undefined; + return undefined; }; export const fetchResource = async (url: string) => { - const resource = identify(url); + const resource = identify(url); - if (resource === Resource.MangaDex) { - return await fetch( - `https://api.mangadex.org/manga/${ - url.match(/mangadex\.org\/title\/([a-f0-9-]+)\/?/)?.[1] - }/feed?order[chapter]=desc&translatedLanguage[]=en` - ); - } else if (resource === Resource.Rawkuma) { - return await fetch(url); - } + if (resource === Resource.MangaDex) { + return await fetch( + `https://api.mangadex.org/manga/${ + url.match(/mangadex\.org\/title\/([a-f0-9-]+)\/?/)?.[1] + }/feed?order[chapter]=desc&translatedLanguage[]=en`, + ); + } else if (resource === Resource.Rawkuma) { + return await fetch(url); + } - return fetch(url); + return fetch(url); }; export const decodeResource = async (response: Response, url: string) => { - const resource = identify(url); + const resource = identify(url); - if (resource === Resource.MangaDex) { - return await response.json(); - } else { - return await response.text(); - } + if (resource === Resource.MangaDex) { + return await response.json(); + } else { + return await response.text(); + } }; |