Skip to content

Commit

Permalink
Merge branch 'miru-project:main' into patch-5
Browse files Browse the repository at this point in the history
  • Loading branch information
OshekharO authored Sep 19, 2023
2 parents 6bba76f + aa9ac29 commit 3f49dab
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Miru extensions repository | [Miru App Download](https://github.com/miru-project
| 轻小说文库 | moe.wol.wenku8 | v0.0.1 | NPGamma | zh-cn | false | [Source Code](https://github.com/miru-project/repo/blob/main/repo/moe.wol.wenku8.js) |
| Mtlnation | mtlnation.com | v0.0.1 | OshekharO | en | false | [Source Code](https://github.com/miru-project/repo/blob/main/repo/mtlnation.com.js) |
| TYS.mx | mx.yts | v0.0.5 | MiaoMint | all | false | [Source Code](https://github.com/miru-project/repo/blob/main/repo/mx.yts.js) |
| ReadLN | readlightnovels | v0.0.1 | OshekharO | en | false | [Source Code](https://github.com/miru-project/repo/blob/main/repo/readlightnovels.js) |
| 免费小说网 | ren.0u0.miru.mfxs | v0.0.1 | MiaoMint | zh-cn | true | [Source Code](https://github.com/miru-project/repo/blob/main/repo/ren.0u0.miru.mfxs.js) |
| 樱花动漫 | sakura | v0.0.1 | Monster | zh-cn | false | [Source Code](https://github.com/miru-project/repo/blob/main/repo/sakura.js) |
| SimplyHentai | simplyhentai.com | v0.0.1 | OshekharO | all | true | [Source Code](https://github.com/miru-project/repo/blob/main/repo/simplyhentai.com.js) |
Expand Down
12 changes: 12 additions & 0 deletions index.json
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,18 @@
"version": "v0.0.5",
"webSite": "https://yts.mx/"
},
{
"author": "OshekharO",
"icon": "https://readlightnovels.net/wp-content/uploads/2020/01/rln-logo-ret.png",
"lang": "en",
"license": "MIT",
"name": "ReadLN",
"package": "readlightnovels",
"type": "fikushon",
"url": "readlightnovels.js",
"version": "v0.0.1",
"webSite": "https://api.consumet.org/light-novels/readlightnovels"
},
{
"author": "MiaoMint",
"lang": "zh-cn",
Expand Down
98 changes: 98 additions & 0 deletions repo/readlightnovels.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
// ==MiruExtension==
// @name ReadLN
// @version v0.0.1
// @author OshekharO
// @lang en
// @license MIT
// @icon https://readlightnovels.net/wp-content/uploads/2020/01/rln-logo-ret.png
// @package readlightnovels
// @type fikushon
// @webSite https://api.consumet.org/light-novels/readlightnovels
// ==/MiruExtension==

export default class extends Extension {
async req(url) {
return this.request(url, {
headers: {
"Miru-Url": await this.getSetting("readlightnovels"),
},
});
}

async load() {
this.registerSetting({
title: "ReadLN API",
key: "readlightnovels",
type: "input",
description: "ReadLN Api Url",
defaultValue: "https://api.consumet.org/light-novels/readlightnovels",
});
}

async latest() {
const res = await this.request("", {
headers: {
"Miru-Url": "https://readlightnovels.net/latest",
},
});
const bsxList = await this.querySelectorAll(res, "div.home-truyendecu");
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, "h3").text;
const cover = await this.querySelector(html, "img").getAttributeText("src");

if (!url.includes("%")) {
novel.push({
title,
url,
cover,
});
}
}
return novel;
}

async detail(url) {
const res = await this.req(`/info?id=${url}`);
return {
title: res.title,
cover: res.image,
desc: res.description,
episodes: [
{
title: "Directory",
urls: res.chapters.map((item) => ({
name: item.title,
url: item.id,
})),
},
],
};
}

async search(kw) {
const res = await this.req(`/${kw}`);
return res.results
.filter((item) => !item.id.includes("%"))
.map((item) => ({
title: item.title,
url: item.id,
cover: item.image,
}));
}

async watch(url) {
const res = await this.req(`/read?chapterId=${url}`);
let chapterContentDiv = res.text;
chapterContentDiv = chapterContentDiv.replace(/<\/?p>|<br\s*\/?>/gi, "\n");
chapterContentDiv = chapterContentDiv.replace(/\n{2,}/g, "\n");
const content = chapterContentDiv.split("\n");

return {
title: res.novelTitle,
content: content,
};
}
}

0 comments on commit 3f49dab

Please sign in to comment.