generated from manga-raiku/raiku-plugin-template
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plugin.ts
91 lines (72 loc) · 2.13 KB
/
plugin.ts
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import { defineApi } from "raiku-pgs/plugin"
import type { API, Comic, Comments, ID } from "raiku-pgs/plugin"
import { Rankings, Servers, TAGS_IS_MANGA } from "src/constants"
import { index } from "src/fetch"
import { getComic } from "src/fetch/get-comic"
import { getComicChapter } from "src/fetch/get-comic-chapter"
import { getListChapters } from "src/fetch/get-list-chapters"
import { search } from "src/fetch/search"
import { searchQuickly } from "src/fetch/search-quickly"
class Plugin implements API<false> {
public readonly Rankings = Rankings
public readonly Servers = Servers
public readonly autoFetchComicIsManga = false
async setup() {
if (AppInfo.extension) {
await setReferrers({
"#hentaivn": CURL
})
}
}
async index() {
return index()
}
async getComic(zlug: string) {
return getComic(zlug)
}
async getModeReader(_: string, __: string) {
// if (comicData.genres.some(item => TAGS_IS_MANGA.includes(item.name.toLowerCase()))) {
return {
scrollingMode: false,
rightToLeft: true
}
// }
// return {}
}
async getComicChapter<Fast extends boolean>(zlug: ID, chap: ID, fast: Fast) {
return getComicChapter(zlug, chap, fast)
}
async getComicComments(
) {
return {
comments: [],
comments_count: 0,
comments_pages: 0
} as Comments
}
async getListChapters(mangaId: ID, mangaParam: string) {
return getListChapters(mangaId, mangaParam)
}
searchQuickly(keyword: string, page: number) {
return searchQuickly(keyword, page)
}
async search(keyword: string, page: number) {
return search(keyword, page)
}
async getRanking(type: string, page: number) {
const rank = Rankings.find((item) => item.value === type)
if (!rank) throw new Error("not_found")
return general(rank.match, page)
}
async getCategory(type: string, page: number) {
const match = type.match(/-(\d+)$/)
if (type && !match) throw new Error("not_found")
return general(
!type
? "danh-sach.html"
: `the-loai-${type.slice(0, match!.index)}-${match![1]}.html`,
page
)
}
}
defineApi(Plugin)