-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
113 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
// ==MiruExtension== | ||
// @name 聚小说 | ||
// @version v0.0.1 | ||
// @author OshekharO | ||
// @lang zh-cn | ||
// @license MIT | ||
// @package juxiaoshuo | ||
// @type fikushon | ||
// @icon https://www.juxiaoshuo.net/images/nocover.png | ||
// @webSite https://www.juxiaoshuo.net | ||
// ==/MiruExtension== | ||
|
||
export default class extends Extension { | ||
async latest() { | ||
const res = await this.request("/"); | ||
const bsxList = await this.querySelectorAll(res, "div.item"); | ||
const novel = []; | ||
for (const element of bsxList) { | ||
const html = await element.content; | ||
const url = await this.getAttributeText(html, "a", "href"); | ||
const title = await this.querySelector(html, "span").text; | ||
const cover = await this.querySelector(html, "img").getAttributeText("data-src"); | ||
novel.push({ | ||
title: title.trim(), | ||
url, | ||
cover: "https://www.juxiaoshuo.net" + cover, | ||
}); | ||
} | ||
return novel; | ||
} | ||
|
||
async search(kw) { | ||
const res = await this.request(`/page/search?query=${kw}&source=12`); | ||
const bsxList = await this.querySelectorAll(res, "div.so_list.bookcase"); | ||
const novel = []; | ||
|
||
for (const element of bsxList) { | ||
const html = await element.content; | ||
const url = await this.getAttributeText(html, "a", "href"); | ||
const title = await this.querySelector(html, "h4.bookname > a").text; | ||
const cover = await this.querySelector(html, "img").getAttributeText("data-src"); | ||
novel.push({ | ||
title: title.trim(), | ||
url, | ||
cover: "https://www.juxiaoshuo.net" + cover, | ||
}); | ||
} | ||
return novel; | ||
} | ||
|
||
async detail(url) { | ||
const res = await this.request(`${url}`, { | ||
headers: { | ||
"miru-referer": "https://www.juxiaoshuo.net/", | ||
}, | ||
}); | ||
|
||
const title = await this.querySelector(res, "span.title").text; | ||
const cover = await this.querySelector( | ||
res, | ||
"img" | ||
).getAttributeText("data-src"); | ||
const desc = await this.querySelector( | ||
res, | ||
"div.intro > dl > dd" | ||
).text; | ||
|
||
const episodes = []; | ||
const listMainMatch = res.match(/<div class="listmain">([\s\S]+?)<\/div>/); | ||
|
||
if (listMainMatch) { | ||
const epiList = listMainMatch[1].matchAll(/<a[^>]*href="([^"]+)"[^>]*>([^<]+)<\/a>/g); | ||
|
||
for (const match of epiList) { | ||
const url = match[1]; | ||
const name = match[2]; | ||
|
||
episodes.push({ | ||
name, | ||
url, | ||
}); | ||
} | ||
} | ||
|
||
return { | ||
title, | ||
cover: "https://www.juxiaoshuo.net" + cover, | ||
desc, | ||
episodes: [ | ||
{ | ||
title: "Chapters", | ||
urls: episodes, | ||
}, | ||
], | ||
}; | ||
} | ||
|
||
async watch(url) { | ||
const res = await this.request(`${url}`); | ||
const contentList = await this.querySelectorAll(res, "div.Readarea.ReadAjax_content"); | ||
const title = await this.querySelector(res, "h1.wap_none").text; | ||
const content = []; | ||
|
||
for (const c of contentList) { | ||
content.push(await this.querySelector(c.content, "div").text); | ||
} | ||
|
||
return { | ||
title, | ||
content, | ||
}; | ||
} | ||
} |