-
Notifications
You must be signed in to change notification settings - Fork 186
Expand file tree
/
Copy pathmxs.js
More file actions
523 lines (463 loc) · 18.8 KB
/
Copy pathmxs.js
File metadata and controls
523 lines (463 loc) · 18.8 KB
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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
class MXS extends ComicSource {
// 漫画源基本信息
name = "漫小肆";
key = "mxs";
version = "1.0.0";
minAppVersion = "1.5.0";
url = "https://cdn.jsdelivr.net/gh/venera-app/venera-configs@main/mxs.js";
// 漫画源设置项
settings = {
// 域名选择功能
domains: {
title: "选择域名",
type: "select",
options: [
{ value: "https://www.mxshm.top", text: "mxshm.top" },
{ value: "https://www.jjmhw1.top", text: "jjmhw1.top" },
{ value: "https://www.jjmh.top", text: "jjmh.top" },
{ value: "https://www.jjmh.cc", text: "jjmh.cc" },
{ value: "https://www.wzd1.cc", text: "wzd1.cc" },
{ value: "https://www.wzdhm1.cc", text: "wzdhm1.cc" },
{ value: "https://www.ikanwzd.cc", text: "ikanwzd.cc" }
],
default: "https://www.mxshm.top"
},
// 域名检测功能
domainCheck: {
title: "检测当前域名",
type: "callback",
buttonText: "检测",
callback: () => {
const currentDomain = this.loadSetting("domains");
const startTime = Date.now();
let isCompleted = false;
// 显示加载对话框
const loadingId = UI.showLoading(() => {
UI.showMessage("检测已取消");
isCompleted = true;
});
// 10秒超时检测
setTimeout(() => {
if (!isCompleted) {
UI.cancelLoading(loadingId);
UI.showMessage("❌ 连接超时,可能需要 🚀");
isCompleted = true;
}
}, 10000);
// 测试网络连接
Network.get(currentDomain).then(res => {
if (isCompleted) return;
const delay = Date.now() - startTime;
UI.cancelLoading(loadingId);
UI.showMessage(`✅ 连接正常,延迟: ${delay}ms`);
isCompleted = true;
}).catch(() => {
if (isCompleted) return;
UI.cancelLoading(loadingId);
UI.showMessage("❌ 连接失败,可能需要 🚀");
isCompleted = true;
});
}
}
};
// 获取基础URL
get baseUrl() {
return this.loadSetting("domains");
}
// 解析普通漫画列表
parseComicList(items) {
const comics = [];
for (let item of items) {
// 提取漫画ID
const linkElem = item.querySelector("a[href^='/book/']");
const id = linkElem.attributes.href.split("/").pop();
// 提取标题和作者
const title = item.querySelector(".title a")?.text?.trim();
const author = item.querySelector("span a")?.text?.trim();
// 提取描述信息
const description = item.querySelector(".chapter")?.text?.replace(/^更新/, "")?.replace(/\s+/g, " ")?.trim() || item.querySelector(".zl")?.text?.trim();
// 验证必要字段并创建漫画对象
if (id && title) {
comics.push(new Comic({
id: id,
title: title,
subTitle: author,
cover: `${this.baseUrl}/static/upload/book/${id}/cover.jpg`,
description: description
}));
}
}
return comics;
}
// 解析热门漫画列表
parseHotComicList(items) {
const comics = [];
for (let item of items) {
// 提取漫画ID
const linkElem = item.querySelector(".cover a[href^='/book/']");
const id = linkElem.attributes.href.split("/").pop();
// 提取标题、作者和点击量
const title = item.querySelector(".info .title a")?.text?.trim();
const author = item.querySelector(".info .desc")?.text?.trim();
const clickCount = item.querySelector(".info .subtitle span a")?.text?.trim();
// 提取标签信息
const tags = [];
const tagElems = item.querySelectorAll(".info .tag a");
for (let tagElem of tagElems) {
if (tagElem.text) tags.push(tagElem.text.trim());
}
// 验证必要字段并创建漫画对象
if (id && title) {
comics.push(new Comic({
id: id,
title: title,
subTitle: author,
cover: `${this.baseUrl}/static/upload/book/${id}/cover.jpg`,
tags: tags,
description: `热度: 🔥${clickCount}`
}));
}
}
return comics;
}
// 解析评论列表
parseCommentList(items) {
const comments = [];
for (let item of items) {
// 提取评论信息
const userName = item.querySelector(".title")?.text?.trim();
const content = item.querySelector(".content")?.text?.trim();
const time = item.querySelector(".bottom")?.text?.match(/\d{4}-\d{2}-\d{2}/)?.[0]?.trim();
const avatar = item.querySelector(".cover img")?.attributes?.src;
// 验证必要字段并创建评论对象
if (userName && content) {
comments.push(new Comment({
userName: userName,
avatar: `${this.baseUrl}${avatar}`,
content: content,
time: time
}));
}
}
return comments;
}
// 执行网络请求并返回HTML文档对象
async fetchDocument(url) {
const res = await Network.get(url, {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
});
if (res.status !== 200) {
throw `请求失败: ${res.status}`;
}
return new HtmlDocument(res.body);
}
// === 探索页面配置 ===
explore = [
{
title: "漫小肆",
type: "multiPartPage",
load: async (page) => {
const doc = await this.fetchDocument(this.baseUrl);
// 最近更新部分
const updateSection = {
title: "最近更新",
comics: this.parseComicList(doc.querySelectorAll(".index-manga .mh-item")),
viewMore: {
page: "category",
attributes: { category: "最近更新" }
}
};
// 热门漫画部分
const hotSection = {
title: "热门漫画",
comics: this.parseHotComicList(doc.querySelectorAll(".index-original .index-original-list li")),
viewMore: {
page: "category",
attributes: { category: "排行榜" }
}
};
// 完结优选部分
const endSection = {
title: "完结优选",
comics: this.parseComicList(doc.querySelectorAll(".box-body .mh-item")),
viewMore: {
page: "category",
attributes: { category: "全部漫画" }
}
};
doc.dispose();
return [updateSection, hotSection, endSection];
}
}
];
// === 分类页面配置 ===
category = {
title: "漫小肆",
parts: [
{
name: "推荐",
type: "fixed",
categories: ["最近更新", "排行榜", "全部漫画"],
itemType: "category"
},
{
name: "题材",
type: "fixed",
categories: [
"都市", "校园", "青春", "性感", "长腿", "多人", "御姐", "巨乳",
"新婚", "媳妇", "暧昧", "清纯", "调教", "少妇", "风骚", "同居",
"淫乱", "好友", "女神", "诱惑", "偷情", "出轨", "正妹", "家教"
],
itemType: "category"
}
],
enableRankingPage: false
};
// === 分类漫画加载配置 ===
categoryComics = {
// 加载分类漫画
load: async (category, param, options, page) => {
// 根据分类构建不同的请求URL
let url;
if (category === "最近更新") {
url = `${this.baseUrl}/update?page=${page}`;
} else if (category === "排行榜") {
url = `${this.baseUrl}/rank`;
} else {
const tag = (category !== "全部漫画") ? category : "全部";
const area = options[0] || "-1";
const end = options[1] || "-1";
url = `${this.baseUrl}/booklist?tag=${encodeURIComponent(tag)}&area=${area}&end=${end}&page=${page}`;
}
const doc = await this.fetchDocument(url);
let comics = [];
// 排行榜特殊处理
if (category === "排行榜") {
const selectedRank = options[0] || "new";
const rankMapping = {
"new": "新书榜",
"popular": "人气榜",
"end": "完结榜",
"recommend": "推荐榜"
};
// 查找对应的排行榜列表
const rankLists = doc.querySelectorAll(".mh-list.col3.top-cat li");
let targetList = null;
for (let list of rankLists) {
const titleElem = list.querySelector(".title");
if (titleElem) {
const title = titleElem.text.trim();
if (title === rankMapping[selectedRank]) {
targetList = list;
break;
}
}
}
if (!targetList) {
doc.dispose();
throw "未找到对应的排行榜";
}
comics = this.parseComicList(targetList.querySelectorAll(".mh-item.horizontal, .mh-itme-top"));
} else {
// 普通分类处理
comics = this.parseComicList(doc.querySelectorAll(".mh-list.col7 .mh-item"));
}
// 解析最大页数(排行榜不分页)
let maxPage = 1;
if (category !== "排行榜") {
const pageLinks = doc.querySelectorAll(".pagination a[href*='page=']");
for (let link of pageLinks) {
const match = link.attributes.href.match(/page=(\d+)/);
if (match) {
const pageNum = parseInt(match[1]);
if (!isNaN(pageNum) && pageNum > maxPage) {
maxPage = pageNum;
}
}
}
}
doc.dispose();
return { comics, maxPage };
},
// 动态加载分类选项
optionLoader: async (category, param) => {
if (category === "最近更新") {
return [];
} else if (category === "排行榜") {
return [{
options: [
"new-新书榜",
"popular-人气榜",
"end-完结榜",
"recommend-推荐榜"
]
}];
} else {
return [
{
label: "地区",
options: [
"-全部",
"1-韩国",
"2-日本",
"3-台湾"
]
},
{
label: "状态",
options: [
"-全部",
"0-连载",
"1-完结"
]
}
];
}
}
};
// === 搜索功能配置 ===
search = {
// 搜索漫画
load: async (keyword, options, page) => {
const url = `${this.baseUrl}/search?keyword=${encodeURIComponent(keyword)}`;
const doc = await this.fetchDocument(url);
const comics = this.parseComicList(doc.querySelectorAll(".mh-item"));
doc.dispose();
return {
comics: comics,
maxPage: 1
};
},
enableTagsSuggestions: false
};
// === 漫画详情和阅读功能配置 ===
comic = {
// 加载漫画详情
loadInfo: async (id) => {
const url = `${this.baseUrl}/book/${id}`;
const doc = await this.fetchDocument(url);
// 提取标题信息
const title = doc.querySelector(".info h1")?.text?.trim();
// 提取副标题信息(别名和作者)
let author = "";
let subTitle = "";
const subTitleElems = doc.querySelectorAll(".info .subtitle");
for (let elem of subTitleElems) {
const text = elem.text;
if (text.includes("别名:")) subTitle = text.replace("别名:", "").trim();
if (text.includes("作者:")) author = text.replace("作者:", "").trim();
}
const authors = author ? author.split("&").map(a => a.trim()).filter(a => a) : [];
// 提取其他信息(状态、地区、更新时间、点击量和描述信息)
let status = "";
let area = "";
let updateTime = "";
let clickCount = "";
const tipElems = doc.querySelectorAll(".info .tip span");
for (let elem of tipElems) {
const text = elem.text;
if (text.includes("状态:")) status = elem.querySelector("span")?.text?.trim();
if (text.includes("地区:")) area = elem.querySelector("a")?.text?.trim();
if (text.includes("更新时间:")) updateTime = elem.text.replace("更新时间:", "").trim();
if (text.includes("点击:")) clickCount = elem.text.replace("点击:", "").trim();
}
const description = doc.querySelector(".info .content")?.text?.trim();
// 提取标签信息
const tagList = [];
const tagElems = doc.querySelectorAll(".info .tip a[href*='tag=']");
for (let elem of tagElems) {
const tagName = elem.text?.trim();
if (tagName) tagList.push(tagName);
}
// 提取章节列表
const chapters = {};
const chapterElems = doc.querySelectorAll("#detail-list-select li a");
for (let elem of chapterElems) {
const chapterUrl = elem.attributes?.href;
const chapterTitle = elem.text?.trim();
if (chapterUrl && chapterTitle) {
const chapterId = chapterUrl.split("/").pop();
if (chapterId) chapters[chapterId] = chapterTitle;
}
}
// 提取评论和推荐漫画
const comments = this.parseCommentList(doc.querySelectorAll(".view-comment-main .postlist li.dashed"));
const recommend = this.parseComicList(doc.querySelectorAll(".index-manga .mh-item"));
doc.dispose();
// 创建并返回漫画详情对象
return new ComicDetails({
title: title,
subTitle: subTitle,
cover: `${this.baseUrl}/static/upload/book/${id}/cover.jpg`,
description: description,
tags: {
"作者": authors,
"题材": tagList,
"地区": [area],
"状态": [status],
"热度": [`🔥${clickCount}`]
},
chapters: chapters,
recommend: recommend,
commentCount: comments.length,
updateTime: updateTime,
url: url,
comments: comments
});
},
// 加载章节图片
loadEp: async (comicId, epId) => {
const url = `${this.baseUrl}/chapter/${epId}`;
const doc = await this.fetchDocument(url);
// 提取懒加载图片
const images = [];
const imageElems = doc.querySelectorAll("img.lazy");
for (let img of imageElems) {
const src = img.attributes?.["data-original"];
const image = src.replace(/https?:\/\/[^\/]+/, this.baseUrl);
if (image) images.push(image);
}
if (images.length === 0) {
doc.dispose();
throw "本章中未找到图片";
}
doc.dispose();
return {
images: images
};
},
// 加载评论列表
loadComments: async (comicId, subId, page, replyTo) => {
const url = `${this.baseUrl}/book/${comicId}`;
const doc = await this.fetchDocument(url);
const comments = this.parseCommentList(doc.querySelectorAll(".view-comment-main .postlist li.dashed"));
doc.dispose();
return {
comments: comments,
maxPage: 1
};
},
// 处理标签点击事件
onClickTag: (namespace, tag) => {
// 作者标签跳转到搜索页面
if (namespace === "作者") {
return {
page: "search",
attributes: {
keyword: tag
}
};
}
// 题材标签跳转到分类页面
else if (namespace === "题材") {
return {
page: "category",
attributes: {
category: tag
}
};
}
},
enableTagsTranslate: false
};
}