-
Notifications
You must be signed in to change notification settings - Fork 105
/
flamecomics.com.js
116 lines (99 loc) · 3.87 KB
/
flamecomics.com.js
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
// ==MiruExtension==
// @name FlameComics
// @version v0.0.1
// @author bethro
// @lang en
// @license MIT
// @icon https://flamecomics.com/wp-content/uploads/2021/03/cropped-fds-1-192x192.png
// @package flamecomics.com
// @type manga
// @webSite https://flamecomics.com/
// ==/MiruExtension==
export default class extends Extension {
async req(url) {
return this.request(url, {
headers: {
"Miru-Url": await this.getSetting("flamecomics"),
},
});
}
async load() {
this.registerSetting({
title: "Flame Comics Base URL",
key: "flamecomics",
type: "input",
desc: "This is the URL where the comics are fetched from",
defaultValue: "https://flamecomics.com",
});
}
async latest(page) {
let res = await this.req(`/series/?page=${page}&order=update`);
let items = await this.querySelectorAll(res, "div.listupd > div.bs > div.bsx");
let respItems = await Promise.all(items.map(async (item) => ({
url: await this.getAttributeText(item.content, "a", "href"),
cover: await this.getAttributeText(item.content, "img", "src"),
title: await this.getAttributeText(item.content, "a", "title")
})))
return respItems
}
async search(kw, page) {
let res = await this.req(`/page/${page}/?s=${kw}`);
let items = await this.querySelectorAll(res, "div.listupd > div.bs > div.bsx");
let respItems = await Promise.all(items.map(async (item) => ({
url: await this.getAttributeText(item.content, "a", "href"),
cover: await this.getAttributeText(item.content, "img", "src"),
title: await this.getAttributeText(item.content, "a", "title")
})))
return respItems;
}
async detail(url) {
// Implement the detail method to get details of a specific comic
let res = await this.request('',{
headers: {
"Miru-Url": url,
}
})
let title = await this.querySelector(res, "title").text
const cover = await this.querySelector(res, "img.wp-post-image").getAttributeText("src");
const desclist = await this.querySelectorAll(res, "div.entry-content.entry-content-single > p");
const desc = await Promise.all(desclist.map(async (element) => {
const decHtml = await element.content;
return await this.querySelector(decHtml, "p").text;
})).then((texts) => texts.join(""));
const epiList = await this.querySelectorAll(res, "#chapterlist > ul > li");
const episodes = await Promise.all(epiList.map(async (element) => {
const html = await element.content;
const name = (await this.querySelector(html, "span.chapternum").text).trim().replace(/[\n\t]/g, '');;
const url = await this.getAttributeText(html, "a", "href");
return {
name,
url: url,
};
}));
return {
title,
cover,
desc,
episodes: [
{
title: "Chapters",
urls: episodes,
},
],
};
}
async watch(url) {
const res = await this.request("", {
headers: {
"Miru-Url": url,
},
});
const images = await Promise.all((await this.querySelectorAll(res, "div#readerarea > p > img")).map(async (element) => {
const html = await element.content;
return this.getAttributeText(html, "img", "src");
}));
return {
urls: images,
};
}
}