Skip to content

Commit

Permalink
修复 哩哔轻小说 #602 (#677)
Browse files Browse the repository at this point in the history
* fix 哩哔轻小说 #602

* 优化 chapterHiddenFix 函数中的变量声明方式
  • Loading branch information
ldm0206 authored Nov 2, 2024
1 parent b908e74 commit 0f317f8
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ EPUB 文件请使用相应阅读器阅读。
| [棉花糖小说网](https://www.mht99.com/) ||| |
| [笔趣阁](https://www.xbiquge.tw/) ||| |
| [红叶书斋](https://www.007zw.com/) ||| |
| [哩哔轻小说](https://www.linovelib.com/) ||| |
| [哩哔轻小说](https://www.linovelib.com/) ||| 因需要基于邻近章节修复隐藏链接的章节,生成目录时间变慢,大约2分钟。 |
| [落秋中文](https://www.luoqiuzw.com/) ||| |
| [一笔阁](https://www.yibige.cc/) ||| |
| [腐书网](https://www.fushuwang.org/) ||| |
Expand Down
5 changes: 3 additions & 2 deletions src/header.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@
"*://www.007zw.com/shuzhai/*/",
"*://www.linovelib.com/novel/*/catalog",
"*://www.linovelib.com/novel/*.html",
"*://w.linovelib.com/novel/*.html",
"*://www.bilinovel.com/novel/*.html",
"*://www.bilinovel.com/novel/*/catalog",
"*://www.luoqiuzw.com/book/*/",
"*://www.yibige.cc/*/",
"*://www.fushuwang.org/*/*/*/*.html",
Expand Down Expand Up @@ -265,7 +266,7 @@
"*://www.alphapolis.co.jp/novel/*/*/episode/*",
"*://novelup.plus/story/*/*",
"*://www.linovelib.com/novel/*/*.html",
"*://w.linovelib.com/novel/*/*.html",
"*://www.bilinovel.com/novel/*/*.html",
"*://www.qbtr.cc/*/*/*.html",
"*://www.ciyuanji.com/chapter/*"
],
Expand Down
20 changes: 15 additions & 5 deletions src/lib/rule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,15 +231,25 @@ export async function chapterHiddenFix(
invalidTest: (c: Chapter) => boolean,
getPrevHref: (doc: Document) => string | undefined,
concurrencyLimit: number,
sleepTime: number = 500,
getHtmlDomFunc: typeof getHtmlDOM | typeof ggetHtmlDOM = getHtmlDOM
) {
const { chapters } = book;
const invalidChapterList = chapters.filter(invalidTest);
const limit = pLimit(concurrencyLimit);
const tasks = invalidChapterList.map((ic) => {
return limit(() => fix(ic, chapters));
});
await Promise.all(tasks);

if (concurrencyLimit === 1) {
for (const ic of invalidChapterList) {
fix(ic, chapters);
await new Promise(resolve => setTimeout(resolve, Math.random() * 100 + sleepTime));
}
} else {
const limit = pLimit(concurrencyLimit);
const tasks = invalidChapterList.map((ic) => {
return limit(() => fix(ic, chapters));
});
await Promise.all(tasks);
}


async function fix(invalidChapter: Chapter, chapterList: Chapter[]) {
const no = invalidChapter.chapterNumber;
Expand Down
2 changes: 1 addition & 1 deletion src/router/download.ts
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ export async function getRule(): Promise<BaseRuleClass> {
ruleClass = linovelib();
break;
}
case "w.linovelib.com": {
case "www.bilinovel.com": {
const { wlinovelib } = await import("../rules/twoPage/linovelib");
ruleClass = wlinovelib();
break;
Expand Down
16 changes: 16 additions & 0 deletions src/router/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,22 @@ export function getUI(): () => UIObject {
}
};
}
case "www.bilinovel.com": {
return () => {
if (document.location.pathname.endsWith("/catalog")) {
return {
type: "jump",
jumpFunction: () =>
(document.location.pathname = document.location.pathname.replace(
/\/catalog$/,
".html"
)),
};
} else {
return defaultObject;
}
};
}
case "masiro.me": {
return () => {
if (document.querySelector(".error-box")) {
Expand Down
27 changes: 20 additions & 7 deletions src/rules/twoPage/linovelib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ import { Book } from "../../main/Book";
import { Chapter } from "../../main/Chapter";
import { table } from "../lib/linovelib";

const chapterFixSleepTime = 2000;
const concurrencyLimit = 1;
const sleepTime = 600;
const maxSleepTime = 3000;

export const linovelib = () => {
const ToCurl = document.location.href;
const bookUrl = ToCurl.replace(/\/catalog$/, ".html");
Expand Down Expand Up @@ -35,8 +40,8 @@ export const linovelib = () => {
return additionalMetadate;
},
getAList: () => document.querySelectorAll(".chapter-list li.col-4 > a"),
getSections: () => document.querySelectorAll(".chapter-list div.volume"),
getSName: (sElem) => (sElem as HTMLElement).innerText.trim(),
getSections: () => document.querySelectorAll("#volume-list > div.volume"),
getSName: (sElem) => (sElem.querySelector(".volume-info >h2") as HTMLElement )?.innerText.trim(),
postHook: (chapter) => {
if (chapter.chapterUrl.startsWith("javascript")) {
chapter.status = Status.aborted;
Expand All @@ -56,7 +61,8 @@ export const linovelib = () => {
book,
invalidTest,
getPrevHref,
classThis.concurrencyLimit
concurrencyLimit,
chapterFixSleepTime,
);
return book;
};
Expand Down Expand Up @@ -95,6 +101,9 @@ export const linovelib = () => {
}
return content;
},
concurrencyLimit: concurrencyLimit,
sleepTime: sleepTime,
maxSleepTime: maxSleepTime,
});
};

Expand All @@ -111,9 +120,9 @@ export const wlinovelib = () => {
url_index: string;
// "/novel/3225.html",
url_articleinfo: string;
// "https://w.linovelib.com/files/article/image/3/3225/3225s.jpg",
// "https://www.bilinovel.com/files/article/image/3/3225/3225s.jpg",
url_image: string;
// "https://w.linovelib.com/",
// "https://www.bilinovel.com/",
url_home: string;
// "3225",
articleid: string;
Expand Down Expand Up @@ -156,7 +165,7 @@ export const wlinovelib = () => {
ToCUrl: tocUrl,
getBookname: () =>
document
.querySelector<HTMLHeadingElement>("h2.book-title")
.querySelector<HTMLHeadingElement>("h1.book-title")
?.innerText.trim() ?? "",
getAuthor: () =>
document
Expand Down Expand Up @@ -202,7 +211,8 @@ export const wlinovelib = () => {
book,
invalidTest,
getPrevHref,
classThis.concurrencyLimit
concurrencyLimit,
chapterFixSleepTime,
);
return book;
};
Expand Down Expand Up @@ -238,5 +248,8 @@ export const wlinovelib = () => {
return contentRaw;
},
contentPatch: (dom) => dom,
concurrencyLimit: concurrencyLimit,
sleepTime: sleepTime,
maxSleepTime: maxSleepTime,
});
};

0 comments on commit 0f317f8

Please sign in to comment.