-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
216 lines (181 loc) · 4.4 KB
/
index.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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
let headers = {
appversion: '2.1.0'
}
async function setMangaListFilterOptions() {
try {
let result = [{
label: '分区',
name: 'filter_class_id',
options: [{
label: '同人',
value: 1
},
{
label: '原创',
value: 2
}
]
}]
window.Rulia.endWithResult(result);
} catch (error) {
window.Rulia.endWithResult([])
}
}
async function getMangaListByCategory(page, pageSize, filterOptions) {
const url = 'https://feigeblog.com/api/channel/searchUserChannel';
try {
const payload = {
filter_block: 2,
refresh_time: Date.now().toString(),
page: page.toString(),
filter_class_id: filterOptions.filter_class_id
}
const rawResponse = await window.Rulia.httpRequest({
url: url,
method: 'POST',
payload: JSON.stringify(payload),
contentType: 'application/json',
headers: headers
})
const response = JSON.parse(rawResponse);
var result = {
list: []
}
for (var manga of response.data.data) {
var comic = {
title: manga.name,
url: manga.id,
coverUrl: manga.cover
}
result.list.push(comic);
}
window.Rulia.endWithResult(result);
} catch (error) {
window.Rulia.endWithException(error.message);
}
}
async function getMangaListBySearching(page, pageSize, keyword) {
const url = 'https://feigeblog.com/api/channel/searchUserChannel';
try {
const payload = {
filter_block: 2,
keyword_type: 1,
keyword: keyword.toString(),
page: page.toString(),
refresh_time: Date.now().toString(),
}
const rawResponse = await window.Rulia.httpRequest({
url: url,
method: 'POST',
payload: JSON.stringify(payload),
contentType: 'application/json',
headers: headers
})
const response = JSON.parse(rawResponse);
var result = {
list: []
}
for (var manga of response.data.data) {
var comic = {
title: manga.name,
url: manga.id,
coverUrl: manga.cover
}
result.list.push(comic);
}
window.Rulia.endWithResult(result);
} catch (error) {
window.Rulia.endWithException(error.message);
}
}
async function getMangaList(page, pageSize, keyword, rawFilterOptions) {
if (keyword) {
return await getMangaListBySearching(page, pageSize, keyword);
} else {
return await getMangaListByCategory(page, pageSize, JSON.parse(rawFilterOptions));
}
}
async function getMangaData(dataPageUrl) {
const url = 'https://feigeblog.com/api/ajax/getAlbumDetailById';
const listUrl = 'https://feigeblog.com/api/ajax/getWorksListByAlbumId';
try {
const payload = {
id: dataPageUrl
}
const listPayload = {
id: dataPageUrl,
page: 1,
refreshTime: Date.now().toString(),
order_sort: 'asc'
}
const rawResponse = await window.Rulia.httpRequest({
url: url,
method: 'POST',
payload: JSON.stringify(payload),
contentType: 'application/json',
headers: headers
})
const listRawResponse = await window.Rulia.httpRequest({
url: listUrl,
method: 'POST',
payload: JSON.stringify(listPayload),
contentType: 'application/json',
headers: headers
})
const response = JSON.parse(rawResponse);
const listResponse = JSON.parse(listRawResponse);
let result = {
title: response.data.name,
description: response.data.desc,
coverUrl: response.data.cover,
chapterList: []
}
for (var manga of listResponse.data.data) {
let mangaTitle = manga.content;
let match = manga.content.match(/^(.*?)\n/);
if (match && match[1]) {
mangaTitle = match[1]
}
var comic = {
title: '[' + mangaTitle + '][' + manga.update_time + ']',
url: manga.id
}
result.chapterList.push(comic);
}
window.Rulia.endWithResult(result);
} catch (error) {
window.Rulia.endWithException(error.message);
}
}
async function getChapterImageList(chapterUrl) {
const url = 'https://feigeblog.com/api/ajax/worksDetail';
try {
const payload = {
id: chapterUrl
}
const rawResponse = await window.Rulia.httpRequest({
url: url,
method: 'POST',
payload: JSON.stringify(payload),
contentType: 'application/json',
headers: headers
})
const response = JSON.parse(rawResponse);
let result = [];
let list = response.data.image.split(',');
for (var i = 0; i < list.length; i++) {
result.push({
url: list[i],
index: i,
width: 1,
height: 1
});
}
window.Rulia.endWithResult(result);
} catch (error) {
window.Rulia.endWithException(error.message);
}
}
async function getImageUrl(path) {
window.Rulia.endWithResult(path);
}