From 2d31353f10adfd2b3fae081aa7aa492fe4b11349 Mon Sep 17 00:00:00 2001 From: Saksham Shekher <95137948+OshekharO@users.noreply.github.com> Date: Tue, 19 Sep 2023 03:49:37 -0700 Subject: [PATCH 1/2] Create readlightnovels.js (#42) --- repo/readlightnovels.js | 98 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 repo/readlightnovels.js diff --git a/repo/readlightnovels.js b/repo/readlightnovels.js new file mode 100644 index 0000000..cf94e55 --- /dev/null +++ b/repo/readlightnovels.js @@ -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>|/gi, "\n"); + chapterContentDiv = chapterContentDiv.replace(/\n{2,}/g, "\n"); + const content = chapterContentDiv.split("\n"); + + return { + title: res.novelTitle, + content: content, + }; + } +} From aa9ac29a673c7889e82f69aad6afd2e0b157e0e6 Mon Sep 17 00:00:00 2001 From: Automated Publisher Date: Tue, 19 Sep 2023 10:49:56 +0000 Subject: [PATCH 2/2] Automated publish: Tue Sep 19 10:49:56 UTC 2023 2d31353f10adfd2b3fae081aa7aa492fe4b11349 --- README.md | 1 + index.json | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/README.md b/README.md index 64c3c12..87aff77 100644 --- a/README.md +++ b/README.md @@ -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) | diff --git a/index.json b/index.json index cdda72d..99752d8 100644 --- a/index.json +++ b/index.json @@ -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",