Skip to content

Commit

Permalink
feat(add): juxiaoshuo
Browse files Browse the repository at this point in the history
  • Loading branch information
OshekharO authored Oct 7, 2023
2 parents 2ce7050 + d140df9 commit 1d3ad27
Showing 1 changed file with 113 additions and 0 deletions.
113 changes: 113 additions & 0 deletions repo/juxiaoshuo.js
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,
};
}
}

0 comments on commit 1d3ad27

Please sign in to comment.