@acanthis-dec/linovelib 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,7 +1,7 @@
1
- Copyright 2026 ConstasJ
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
-
5
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
-
1
+ Copyright 2026 ConstasJ
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
7
  THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/dist/index.mjs CHANGED
@@ -501,10 +501,13 @@ async function searchNovels(keyword, fetchClient) {
501
501
  let currentPageHtml = response.data;
502
502
  while (true) {
503
503
  const $2 = cheerio.load(currentPageHtml);
504
- if ($2("a.next").length > 0) currentPageHtml = (await fetchClient.text(`https://www.linovelib.com${$2("a.next").attr("href")}`, { headers: {
505
- host: "www.linovelib.com",
506
- referer: "https://www.linovelib.com/S6/"
507
- } })).data;
504
+ if ($2("a.next").length > 0) {
505
+ await new Promise((r) => setTimeout(r, Math.random() * 500 + 500));
506
+ currentPageHtml = (await fetchClient.text(`https://www.linovelib.com${$2("a.next").attr("href")}`, { headers: {
507
+ host: "www.linovelib.com",
508
+ referer: "https://www.linovelib.com/S6/"
509
+ } })).data;
510
+ }
508
511
  const $3 = cheerio.load(currentPageHtml);
509
512
  $3("div.search-html-box div.search-result-list").each((_, el) => {
510
513
  const $el = $3(el);
@@ -527,22 +530,18 @@ async function searchNovels(keyword, fetchClient) {
527
530
  //#region src/queue.ts
528
531
  /**
529
532
  * Simple backoff strategy for request rate limiting
530
- * - Normal desktop delay: 500-1000ms random
531
- * - Normal mobile delay: 2000-5000ms random
533
+ * - Normal delay: 500-1000ms random
532
534
  * - Failure delay: 8000ms (8 seconds)
533
535
  */
534
536
  var SimpleBackoff = class {
535
537
  NORMAL_DELAY_MIN = 500;
536
538
  NORMAL_DELAY_MAX = 1e3;
537
- NORMAL_MOBILE_DELAY_MIN = 2e3;
538
- NORMAL_MOBILE_DELAY_MAX = 5e3;
539
539
  FAILURE_DELAY = 15e3;
540
540
  /**
541
541
  * Get delay for normal (successful) operation
542
542
  * @returns Random delay in range [500, 1000]ms. If isMobile is true, returns random delay in range [2000, 5000]ms
543
543
  */
544
- getDelayForSuccess(isMobile = false) {
545
- if (isMobile) return this.NORMAL_MOBILE_DELAY_MIN + Math.random() * (this.NORMAL_MOBILE_DELAY_MAX - this.NORMAL_MOBILE_DELAY_MIN);
544
+ getDelayForSuccess() {
546
545
  return this.NORMAL_DELAY_MIN + Math.random() * (this.NORMAL_DELAY_MAX - this.NORMAL_DELAY_MIN);
547
546
  }
548
547
  };
@@ -563,12 +562,15 @@ var SearchQueue = class {
563
562
  this.logger?.debug(`[SearchQueue] 任务完成或超时,开始下一个任务。剩余:${this.queue.size} `);
564
563
  });
565
564
  }
565
+ async _sleep(ms) {
566
+ return new Promise((resolve) => setTimeout(resolve, ms));
567
+ }
566
568
  async searchNovels(keyword) {
567
569
  return await this.queue.add(async () => {
568
570
  if (Date.now() - this.lastSearchTime < this.COOLDOWN_MS) {
569
571
  const waitTime = this.COOLDOWN_MS - (Date.now() - this.lastSearchTime);
570
572
  this.logger?.debug(`[SearchQueue] 搜索请求过快,等待 ${waitTime}ms 后重试`);
571
- await new Promise((resolve) => setTimeout(resolve, waitTime));
573
+ await this._sleep(waitTime);
572
574
  }
573
575
  this.logger?.debug(`[SearchQueue] 开始搜索关键词 "${keyword}"`);
574
576
  const results = await searchNovels(keyword, this.client);
@@ -583,6 +585,7 @@ var NovelChapterQueue = class {
583
585
  client;
584
586
  backoff;
585
587
  logger;
588
+ lastFetchTime = 0;
586
589
  constructor(client, logger) {
587
590
  this.queue = new PQueue({ concurrency: 1 });
588
591
  this.client = client;
@@ -600,6 +603,12 @@ var NovelChapterQueue = class {
600
603
  }
601
604
  async fetchChapterPart(url) {
602
605
  return await this.queue.add(async () => {
606
+ const delay = this.backoff.getDelayForSuccess();
607
+ if (Date.now() - this.lastFetchTime < delay) {
608
+ const waitTime = delay - (Date.now() - this.lastFetchTime);
609
+ this.logger?.debug(`[NovelChapterQueue] 请求过快,等待 ${waitTime}ms`);
610
+ await this._sleep(waitTime);
611
+ }
603
612
  const match = url.match(/\/novel\/(\d+)\/(\d+)(?:_(\d+))?\.html/);
604
613
  if (!match) throw new Error(`Invalid chapter URL: ${url}`);
605
614
  const novelId = match[1];
@@ -623,24 +632,9 @@ var NovelChapterQueue = class {
623
632
  return defaultRetryPolicy(ctx) || ctx.error instanceof CloudflareBlockError;
624
633
  }
625
634
  };
626
- let content = (await this.client.text(url, { retry })).data ?? "";
627
- if (content.match(/沒有可閱讀的章節|没有可阅读的章节/i)) {
628
- content = (await this.client.text(url, {
629
- profile: "chrome149-android",
630
- retry: {
631
- ...retry,
632
- minRetryDelayMs: this.backoff.NORMAL_MOBILE_DELAY_MIN,
633
- maxRetryDelayMs: this.backoff.NORMAL_MOBILE_DELAY_MAX
634
- }
635
- })).data;
636
- const delay = this.backoff.getDelayForSuccess(true);
637
- this.logger?.debug(`[NovelChapterQueue] 小说${novelId}-章节${chapterId}_${partId} 获取成功。下一次请求将在 ${delay.toFixed(0)}ms 后进行`);
638
- await this._sleep(delay);
639
- return content;
640
- }
641
- const delay = this.backoff.getDelayForSuccess();
642
- this.logger?.debug(`[NovelChapterQueue] 小说${novelId}-章节${chapterId}_${partId} 获取成功。下一次请求将在 ${delay.toFixed(0)}ms 后进行`);
643
- await this._sleep(delay);
635
+ const content = (await this.client.text(url, { retry })).data ?? "";
636
+ this.lastFetchTime = Date.now();
637
+ this.logger?.debug(`[NovelChapterQueue] 小说${novelId}-章节${chapterId}_${partId} 获取成功。`);
644
638
  return content;
645
639
  });
646
640
  }
@@ -651,6 +645,7 @@ var NovelInfoQueue = class {
651
645
  backoff;
652
646
  chapterQueue;
653
647
  logger;
648
+ lastFetchTime = 0;
654
649
  constructor(client, chapterQueue, logger) {
655
650
  this.queue = new PQueue({ concurrency: 1 });
656
651
  this.client = client;
@@ -669,6 +664,12 @@ var NovelInfoQueue = class {
669
664
  }
670
665
  async fetchNovelInfo(id) {
671
666
  return await this.queue.add(async () => {
667
+ const delay = this.backoff.getDelayForSuccess();
668
+ if (Date.now() - this.lastFetchTime < delay) {
669
+ const waitTime = delay - (Date.now() - this.lastFetchTime);
670
+ this.logger?.debug(`[NovelInfoQueue] 请求过快,等待 ${waitTime}ms`);
671
+ await this._sleep(waitTime);
672
+ }
672
673
  this.logger?.debug(`[NovelInfoQueue] 开始获取小说${id}的信息`);
673
674
  const retry = {
674
675
  retries: 10,
@@ -689,14 +690,19 @@ var NovelInfoQueue = class {
689
690
  };
690
691
  const novel = await getNovelInfo(id, this.client, retry, this.chapterQueue);
691
692
  if (!novel) throw new Error(`无法获取小说信息: ${id}`);
692
- const delay = this.backoff.getDelayForSuccess();
693
- this.logger?.debug(`[NovelInfoQueue] 小说${id} 信息获取成功。下一次请求将在 ${delay.toFixed(0)}ms 后进行`);
694
- await this._sleep(delay);
693
+ this.logger?.debug(`[NovelInfoQueue] 小说${id} 信息获取成功。`);
694
+ this.lastFetchTime = Date.now();
695
695
  return novel;
696
696
  });
697
697
  }
698
698
  async fetchNovelUpdateInfo(id) {
699
699
  return await this.queue.add(async () => {
700
+ const delay = this.backoff.getDelayForSuccess();
701
+ if (Date.now() - this.lastFetchTime < delay) {
702
+ const waitTime = delay - (Date.now() - this.lastFetchTime);
703
+ this.logger?.debug(`[NovelInfoQueue] 请求过快,等待 ${waitTime}ms`);
704
+ await this._sleep(waitTime);
705
+ }
700
706
  this.logger?.debug(`[NovelInfoQueue] 开始获取小说${id}的更新信息(封面和章节数)`);
701
707
  const retry = {
702
708
  retries: 10,
@@ -717,8 +723,8 @@ var NovelInfoQueue = class {
717
723
  };
718
724
  const updateInfo = await getUpdateInfo(id, this.client, retry);
719
725
  if (!updateInfo) this.logger?.warn(`[NovelInfoQueue] 无法获取小说${id}的更新信息,可能是因为小说不存在或已被删除`);
720
- else this.logger?.debug(`[NovelInfoQueue] 小说${id} 更新信息获取成功。下一次请求将在 ${this.backoff.getDelayForSuccess().toFixed(0)}ms 后进行`);
721
- await this._sleep(this.backoff.getDelayForSuccess());
726
+ else this.logger?.debug(`[NovelInfoQueue] 小说${id} 更新信息获取成功。 封面: ${updateInfo.coverUrl}, 章节数: ${updateInfo.chapterCount}`);
727
+ this.lastFetchTime = Date.now();
722
728
  return updateInfo;
723
729
  });
724
730
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["z"],"sources":["../src/coefficients.ts","../src/utils.ts","../src/chapter.ts","../src/cover.ts","../src/novel.ts","../src/search.ts","../src/queue.ts","../src/session.ts","../src/client.ts"],"sourcesContent":["import type { BrowserFetchClient } from \"@acanthis-dec/browser-fetch\";\nimport type { DescrambleCoefficients } from \"@acanthis-dec/core\";\nimport { deobfuscate } from \"@acanthis-dec/deobfuscator\";\nimport { parse } from \"@babel/parser\";\nimport traverseModule from \"@babel/traverse\";\nimport * as t from \"@babel/types\";\nimport * as cheerio from \"cheerio\";\nimport { z } from \"zod\";\n\ntype TraverseFunction = typeof traverseModule;\n\nconst traverse =\n\t(traverseModule as unknown as { default?: TraverseFunction }).default ??\n\ttraverseModule;\n\nexport const descrambleCoefficientsSchema = z.object({\n\tmodulus: z.number().int(),\n\tincrement: z.number().int(),\n\tmultiplier: z.number().int(),\n\tseedOffset: z.number().int(),\n\tseedMultiplier: z.number().int(),\n});\n\nfunction getObfuscatedPart(fullCode: string): string {\n\treturn fullCode\n\t\t.split(/\\r?\\n/)\n\t\t.map((line) => line.trim())\n\t\t.filter((line) => line !== \"\")\n\t\t.slice(-2)\n\t\t.join(\"\\n\");\n}\n\nexport async function extractCoefficients(\n\tscript: string,\n): Promise<DescrambleCoefficients> {\n\tconst obfuscatedPart = getObfuscatedPart(script);\n\tconst deObfCode = await deobfuscate(obfuscatedPart);\n\tconst ast = parse(deObfCode, { sourceType: \"module\", plugins: [\"jsx\"] });\n\tconst coefficients: Partial<DescrambleCoefficients> = {};\n\ttraverse(ast, {\n\t\tBinaryExpression(path) {\n\t\t\tconst { node } = path;\n\t\t\tif (\n\t\t\t\tnode.operator === \"%\" &&\n\t\t\t\tt.isNumericLiteral(node.right) &&\n\t\t\t\tt.isBinaryExpression(node.left) &&\n\t\t\t\tnode.left.operator === \"+\" &&\n\t\t\t\tt.isNumericLiteral(node.left.right) &&\n\t\t\t\tt.isBinaryExpression(node.left.left) &&\n\t\t\t\tnode.left.left.operator === \"*\" &&\n\t\t\t\tt.isNumericLiteral(node.left.left.right)\n\t\t\t) {\n\t\t\t\tcoefficients.modulus = node.right.value;\n\t\t\t\tconst leftSide = node.left;\n\t\t\t\tif (t.isBinaryExpression(leftSide) && leftSide.operator === \"+\") {\n\t\t\t\t\tif (t.isNumericLiteral(leftSide.right)) {\n\t\t\t\t\t\tcoefficients.increment = leftSide.right.value;\n\t\t\t\t\t}\n\t\t\t\t\tif (\n\t\t\t\t\t\tt.isBinaryExpression(leftSide.left) &&\n\t\t\t\t\t\tleftSide.left.operator === \"*\"\n\t\t\t\t\t) {\n\t\t\t\t\t\tif (t.isNumericLiteral(leftSide.left.right)) {\n\t\t\t\t\t\t\tcoefficients.multiplier = leftSide.left.right.value;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (\n\t\t\t\tnode.operator === \"+\" &&\n\t\t\t\tt.isNumericLiteral(node.right) &&\n\t\t\t\tt.isBinaryExpression(node.left) &&\n\t\t\t\tnode.left.operator === \"*\" &&\n\t\t\t\tt.isNumericLiteral(node.left.right)\n\t\t\t) {\n\t\t\t\tconst potentialOffset = node.right.value;\n\t\t\t\tconst potentialMultiplier = node.left.right.value;\n\t\t\t\tconst numberTransformed = node.left.left;\n\t\t\t\tif (\n\t\t\t\t\tt.isCallExpression(numberTransformed) &&\n\t\t\t\t\tt.isIdentifier(numberTransformed.callee) &&\n\t\t\t\t\t(numberTransformed.callee.name === \"Number\" ||\n\t\t\t\t\t\tnumberTransformed.callee.name === \"parseInt\")\n\t\t\t\t) {\n\t\t\t\t\tcoefficients.seedOffset = potentialOffset;\n\t\t\t\t\tcoefficients.seedMultiplier = potentialMultiplier;\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t});\n\tif (\n\t\tcoefficients.modulus === undefined ||\n\t\tcoefficients.increment === undefined ||\n\t\tcoefficients.multiplier === undefined ||\n\t\tcoefficients.seedOffset === undefined ||\n\t\tcoefficients.seedMultiplier === undefined\n\t) {\n\t\tthrow new Error(\"Failed to extract all coefficients\");\n\t}\n\treturn coefficients as DescrambleCoefficients;\n}\n\nexport function extractChapterLogScriptUrl(html: string): string {\n\tconst $ = cheerio.load(html);\n\tconst chapterLogScriptUrl =\n\t\t$(\n\t\t\t$(\"script\")\n\t\t\t\t.toArray()\n\t\t\t\t.find((el) => {\n\t\t\t\t\tconst scriptContent = $(el).attr(\"src\") || \"\";\n\t\t\t\t\treturn /chapterlog\\.js/.test(scriptContent);\n\t\t\t\t}),\n\t\t).attr(\"src\") || \"\";\n\treturn chapterLogScriptUrl.startsWith(\"http\")\n\t\t? chapterLogScriptUrl\n\t\t: `https://www.linovelib.com${chapterLogScriptUrl}`;\n}\n\nexport interface CoefficientResult {\n\tcoefficients: DescrambleCoefficients;\n\tversion: string;\n}\n\nexport async function getCoefficientsFromPage(\n\thtml: string,\n\tfetchClient: BrowserFetchClient,\n\tcachedVersion?: string,\n): Promise<CoefficientResult | undefined> {\n\tconst scriptUrl = extractChapterLogScriptUrl(html);\n\tif (!scriptUrl) {\n\t\tthrow new Error(\"Chapter log script URL not found\");\n\t}\n\tconst version = scriptUrl.match(/chapterlog\\.js\\?(v.*)/)?.[1] || \"\";\n\tif (version === cachedVersion) {\n\t\treturn undefined; // No need to fetch and extract again\n\t}\n\tconst scriptContent = await fetchClient.text(scriptUrl);\n\tif (!scriptContent.mimeType.includes(\"javascript\")) {\n\t\tthrow new Error(\"Fetched content is not JavaScript\");\n\t}\n\tconst coefficients = await extractCoefficients(scriptContent.data);\n\treturn {\n\t\tcoefficients,\n\t\tversion: version,\n\t};\n}\n","export function extractNovelIdFromUrl(url: string): string | undefined {\n\tconst match = url.match(/\\/novel\\/(\\d+)\\.html/);\n\treturn match ? match[1] : undefined;\n}\n\nexport interface NovelAndChapterIds {\n\tnovelId: string | undefined;\n\tchapterId: string | undefined;\n}\n\nexport function extractChapterIdFromUrl(\n\turl: string,\n): NovelAndChapterIds | undefined {\n\tconst match = url.match(/\\/novel\\/(\\d+)\\/(\\d+)\\.html/);\n\tif (match) {\n\t\treturn {\n\t\t\tnovelId: match[1],\n\t\t\tchapterId: match[2],\n\t\t};\n\t}\n\treturn undefined;\n}\n\nexport function transformChapterName(name: string): string {\n\tconst chapNameTransDict: Record<string, string> = {\n\t\t\"\\u004e\": \"\\u5973\",\n\t};\n\treturn name.replace(/./g, (char) => chapNameTransDict[char] || char);\n}\n\nexport function transformContent(content: string): string {\n\tconst contentTransDict: Record<string, string> = {\n\t\t\"\\u201c\": \"\\u300c\",\n\t\t\"\\u201d\": \"\\u300d\",\n\t\t\"\\u2018\": \"\\u300e\",\n\t\t\"\\u2019\": \"\\u300f\",\n\t\t\"\\ue82c\": \"\\u7684\",\n\t\t\"\\ue852\": \"\\u4e00\",\n\t\t\"\\ue82d\": \"\\u662f\",\n\t\t\"\\ue819\": \"\\u4e86\",\n\t\t\"\\ue856\": \"\\u6211\",\n\t\t\"\\ue857\": \"\\u4e0d\",\n\t\t\"\\ue816\": \"\\u4eba\",\n\t\t\"\\ue83c\": \"\\u5728\",\n\t\t\"\\ue830\": \"\\u4ed6\",\n\t\t\"\\ue82e\": \"\\u6709\",\n\t\t\"\\ue836\": \"\\u8fd9\",\n\t\t\"\\ue859\": \"\\u4e2a\",\n\t\t\"\\ue80a\": \"\\u4e0a\",\n\t\t\"\\ue855\": \"\\u4eec\",\n\t\t\"\\ue842\": \"\\u6765\",\n\t\t\"\\ue858\": \"\\u5230\",\n\t\t\"\\ue80b\": \"\\u65f6\",\n\t\t\"\\ue81f\": \"\\u5927\",\n\t\t\"\\ue84a\": \"\\u5730\",\n\t\t\"\\ue853\": \"\\u4e3a\",\n\t\t\"\\ue81e\": \"\\u5b50\",\n\t\t\"\\ue822\": \"\\u4e2d\",\n\t\t\"\\ue813\": \"\\u4f60\",\n\t\t\"\\ue85b\": \"\\u8bf4\",\n\t\t\"\\ue807\": \"\\u751f\",\n\t\t\"\\ue818\": \"\\u56fd\",\n\t\t\"\\ue810\": \"\\u5e74\",\n\t\t\"\\ue812\": \"\\u7740\",\n\t\t\"\\ue851\": \"\\u5c31\",\n\t\t\"\\ue801\": \"\\u90a3\",\n\t\t\"\\ue80c\": \"\\u548c\",\n\t\t\"\\ue815\": \"\\u8981\",\n\t\t\"\\ue84c\": \"\\u5979\",\n\t\t\"\\ue840\": \"\\u51fa\",\n\t\t\"\\ue848\": \"\\u4e5f\",\n\t\t\"\\ue835\": \"\\u5f97\",\n\t\t\"\\ue800\": \"\\u91cc\",\n\t\t\"\\ue826\": \"\\u540e\",\n\t\t\"\\ue863\": \"\\u81ea\",\n\t\t\"\\ue861\": \"\\u4ee5\",\n\t\t\"\\ue854\": \"\\u4f1a\",\n\t\t\"\\ue827\": \"\\u5bb6\",\n\t\t\"\\ue83b\": \"\\u53ef\",\n\t\t\"\\ue85d\": \"\\u4e0b\",\n\t\t\"\\ue84d\": \"\\u800c\",\n\t\t\"\\ue862\": \"\\u8fc7\",\n\t\t\"\\ue81c\": \"\\u5929\",\n\t\t\"\\ue81d\": \"\\u53bb\",\n\t\t\"\\ue860\": \"\\u80fd\",\n\t\t\"\\ue843\": \"\\u5bf9\",\n\t\t\"\\ue82f\": \"\\u5c0f\",\n\t\t\"\\ue802\": \"\\u591a\",\n\t\t\"\\ue831\": \"\\u7136\",\n\t\t\"\\ue84b\": \"\\u4e8e\",\n\t\t\"\\ue837\": \"\\u5fc3\",\n\t\t\"\\ue829\": \"\\u5b66\",\n\t\t\"\\ue85e\": \"\\u4e48\",\n\t\t\"\\ue83a\": \"\\u4e4b\",\n\t\t\"\\ue832\": \"\\u90fd\",\n\t\t\"\\ue808\": \"\\u597d\",\n\t\t\"\\ue841\": \"\\u770b\",\n\t\t\"\\ue821\": \"\\u8d77\",\n\t\t\"\\ue845\": \"\\u53d1\",\n\t\t\"\\ue803\": \"\\u5f53\",\n\t\t\"\\ue828\": \"\\u6ca1\",\n\t\t\"\\ue81b\": \"\\u6210\",\n\t\t\"\\ue83e\": \"\\u53ea\",\n\t\t\"\\ue820\": \"\\u5982\",\n\t\t\"\\ue84e\": \"\\u4e8b\",\n\t\t\"\\ue85a\": \"\\u628a\",\n\t\t\"\\ue806\": \"\\u8fd8\",\n\t\t\"\\ue83f\": \"\\u7528\",\n\t\t\"\\ue833\": \"\\u7b2c\",\n\t\t\"\\ue811\": \"\\u6837\",\n\t\t\"\\ue804\": \"\\u9053\",\n\t\t\"\\ue814\": \"\\u60f3\",\n\t\t\"\\ue80f\": \"\\u4f5c\",\n\t\t\"\\ue84f\": \"\\u79cd\",\n\t\t\"\\ue80e\": \"\\u5f00\",\n\t\t\"\\ue823\": \"\\u7f8e\",\n\t\t\"\\ue849\": \"\\u4e73\",\n\t\t\"\\ue805\": \"\\u9634\",\n\t\t\"\\ue809\": \"\\u6db2\",\n\t\t\"\\ue81a\": \"\\u830e\",\n\t\t\"\\ue844\": \"\\u6b32\",\n\t\t\"\\ue847\": \"\\u547b\",\n\t\t\"\\ue850\": \"\\u8089\",\n\t\t\"\\ue824\": \"\\u4ea4\",\n\t\t\"\\ue85f\": \"\\u6027\",\n\t\t\"\\ue817\": \"\\u80f8\",\n\t\t\"\\ue85c\": \"\\u79c1\",\n\t\t\"\\ue838\": \"\\u7a74\",\n\t\t\"\\ue82a\": \"\\u6deb\",\n\t\t\"\\ue83d\": \"\\u81c0\",\n\t\t\"\\ue82b\": \"\\u8214\",\n\t\t\"\\ue80d\": \"\\u5c04\",\n\t\t\"\\ue839\": \"\\u8131\",\n\t\t\"\\ue834\": \"\\u88f8\",\n\t\t\"\\ue846\": \"\\u9a9a\",\n\t\t\"\\ue825\": \"\\u5507\",\n\t};\n\treturn content.replace(/./g, (char) => contentTransDict[char] || char);\n}\n","import type { BrowserFetchClient } from \"@acanthis-dec/browser-fetch\";\nimport {\n\tbuildDescrambleMapping,\n\ttype DescrambleCoefficients,\n} from \"@acanthis-dec/core\";\nimport * as cheerio from \"cheerio\";\nimport type { AnyNode, Element } from \"domhandler\";\nimport { getCoefficientsFromPage } from \"./coefficients\";\nimport type { NovelChapterQueue } from \"./queue\";\nimport { transformContent } from \"./utils\";\n\nfunction extractChapterId($: cheerio.CheerioAPI): string {\n\tconst scriptTags = $(\"script\");\n\tlet chapterId = \"\";\n\tscriptTags.each((_, el) => {\n\t\tconst scriptContent = $(el).html();\n\t\tif (scriptContent) {\n\t\t\tconst match = scriptContent.match(/chapterid\\s*:\\s*'(\\d+)'/);\n\t\t\tif (match?.[1]) {\n\t\t\t\tchapterId = match[1];\n\t\t\t\treturn false; // Break the loop\n\t\t\t}\n\t\t}\n\t});\n\treturn chapterId;\n}\n\nexport interface DecryptResult {\n\tcontent: string;\n\tversion: string;\n\tcoefficients: DescrambleCoefficients;\n}\n\nasync function decrypt(\n\thtml: string,\n\tfetchClient: BrowserFetchClient,\n\tcachedJsVersion?: string,\n\tcachedCoefficients?: DescrambleCoefficients,\n): Promise<DecryptResult> {\n\tconst $ = cheerio.load(html);\n\tconst coefficientResult = await getCoefficientsFromPage(\n\t\thtml,\n\t\tfetchClient,\n\t\tcachedJsVersion,\n\t);\n\tconst version = coefficientResult?.version || cachedJsVersion;\n\tconst coefficients = coefficientResult?.coefficients || cachedCoefficients;\n\tif (!version) {\n\t\tthrow new Error(\"Failed to determine chapterlog.js version\");\n\t}\n\tif (!coefficients) {\n\t\tthrow new Error(\"Failed to obtain descrambling coefficients\");\n\t}\n\tconst chapterId = extractChapterId($);\n\tconst container = $(\"#TextContent, #acontent\");\n\tif (!container.length) {\n\t\treturn {\n\t\t\tcontent: \"\",\n\t\t\tversion,\n\t\t\tcoefficients: coefficients,\n\t\t};\n\t}\n\n\tcontainer.find(\"p\").each((_, el) => {\n\t\tconst $el = $(el);\n\t\tconst innerHtml = $el.html();\n\t\tif (innerHtml) {\n\t\t\tconst cleanedHtml = innerHtml.replace(/^\\s+|(?<=>)\\s+/g, \"\");\n\t\t\t$el.html(cleanedHtml);\n\t\t}\n\t});\n\n\tcontainer.find(\"img.imagecontent\").each((_, el) => {\n\t\tconst imgSrc = $(el).attr(\"data-src\") || $(el).attr(\"src\");\n\t\tif (imgSrc) {\n\t\t\t$(el).attr(\"src\", imgSrc).removeAttr(\"data-src\");\n\t\t}\n\t});\n\n\tcontainer.find(\"div.dag\").remove();\n\tcontainer.find(\"script\").remove();\n\n\tconst allChildren = container\n\t\t.contents()\n\t\t.toArray()\n\t\t.filter((node) => !(node.type === \"tag\" && node.tagName === \"div\"));\n\tconst sortableEntries: { element: Element; originalPos: number }[] = [];\n\tallChildren.forEach((node, index) => {\n\t\tif (node.type === \"tag\" && node.tagName === \"p\") {\n\t\t\tconst text = $(node).text().trim();\n\t\t\tif (text.length > 0) {\n\t\t\t\tsortableEntries.push({ element: node, originalPos: index });\n\t\t\t}\n\t\t}\n\t});\n\n\tconst seed =\n\t\tparseInt(chapterId, 10) * coefficients?.seedMultiplier +\n\t\tcoefficients?.seedOffset;\n\n\tconst mapping = buildDescrambleMapping(\n\t\tsortableEntries.length,\n\t\tseed,\n\t\tcoefficients,\n\t\t20,\n\t);\n\n\tconst restoredChildren: (AnyNode | null)[] = [...allChildren];\n\n\tsortableEntries.forEach((entry, i) => {\n\t\tconst targetIndex = mapping[i] ?? i;\n\t\tconst actualSlot = sortableEntries[targetIndex]?.originalPos ?? 0;\n\t\trestoredChildren[actualSlot] = entry.element;\n\t});\n\n\tconst newContainer = $(\"<div></div>\");\n\trestoredChildren.forEach((node) => {\n\t\tif (node && node.type === \"tag\") {\n\t\t\tnewContainer.append(node);\n\t\t\tnewContainer.append(\"\\n\");\n\t\t}\n\t});\n\n\treturn {\n\t\tcontent: newContainer.html() || \"\",\n\t\tversion,\n\t\tcoefficients: coefficients,\n\t};\n}\n\nexport async function getChapter(\n\tid: string,\n\tnovelId: string,\n\tchapterQueue: NovelChapterQueue,\n\tfetchClient: BrowserFetchClient,\n\tcachedJsVersion?: string,\n\tcachedCoefficients?: DescrambleCoefficients,\n): Promise<DecryptResult | undefined> {\n\tconst firstPageHtml = await chapterQueue.fetchChapterPart(\n\t\t`https://www.linovelib.com/novel/${novelId}/${id}.html`,\n\t);\n\tlet $ = cheerio.load(firstPageHtml);\n\tconst chapterName = $(\"h1\").text().trim();\n\tlet nextPageId =\n\t\t$(\"div.mlfy_page a:last\")\n\t\t\t.attr(\"href\")\n\t\t\t?.match(/\\/novel\\/(\\d+)\\/([\\d_]+)\\.html/)?.[2] ||\n\t\tfirstPageHtml.match(/url_next:'\\/novel\\/(\\d+)\\/([\\d_]+)\\.html'/)?.[2] ||\n\t\t\"\";\n\tlet content = await decrypt(\n\t\tfirstPageHtml,\n\t\tfetchClient,\n\t\tcachedJsVersion,\n\t\tcachedCoefficients,\n\t);\n\tcachedCoefficients = content.coefficients;\n\tcachedJsVersion = content.version;\n\twhile (nextPageId?.includes(id)) {\n\t\tconst nextPageHtml = await chapterQueue.fetchChapterPart(\n\t\t\t`https://www.linovelib.com/novel/${novelId}/${nextPageId}.html`,\n\t\t);\n\t\tconst nextContent = await decrypt(\n\t\t\tnextPageHtml,\n\t\t\tfetchClient,\n\t\t\tcachedJsVersion,\n\t\t\tcachedCoefficients,\n\t\t);\n\t\tcontent = {\n\t\t\t...content,\n\t\t\tcontent: content.content + nextContent.content,\n\t\t};\n\t\t$ = cheerio.load(nextPageHtml);\n\t\tnextPageId =\n\t\t\t$(\"div.mlfy_page a:last\")\n\t\t\t\t.attr(\"href\")\n\t\t\t\t?.match(/\\/novel\\/(\\d+)\\/([\\d_]+)\\.html/)?.[2] ||\n\t\t\tnextPageHtml.match(/url_next:'\\/novel\\/(\\d+)\\/([\\d_]+)\\.html/)?.[2] ||\n\t\t\t\"\";\n\t}\n\t// content = `<h2>${chapterName}</h2>\\n${transformContent(content)}`;\n\tcontent = {\n\t\t...content,\n\t\tcontent: `<h2>${chapterName}</h2>\\n${transformContent(content.content)}`,\n\t};\n\treturn content;\n}\n","import type {\n\tBinaryResponse,\n\tBrowserFetchClient,\n} from \"@acanthis-dec/browser-fetch\";\n\nexport function novelIdToCoverUrl(novelId: string): string {\n\tconst prefix = novelId.length > 3 ? novelId[0] : \"0\";\n\treturn `https://www.linovelib.com/files/article/image/${prefix}/${novelId}/${novelId}s.jpg`;\n}\n\nexport async function getCover(\n\tnovelId: string,\n\tfetchClient: BrowserFetchClient,\n): Promise<BinaryResponse> {\n\tconst url = novelIdToCoverUrl(novelId);\n\tconst response = await fetchClient.binary(url);\n\treturn response;\n}\n","import type {\n\tBrowserFetchClient,\n\tRetryOptions,\n} from \"@acanthis-dec/browser-fetch\";\nimport type { Chapter, Novel, NovelStatus, Volume } from \"@acanthis-dec/core\";\nimport * as cheerio from \"cheerio\";\nimport type { Element } from \"domhandler\";\nimport { novelIdToCoverUrl } from \"./cover\";\nimport type { NovelChapterQueue } from \"./queue\";\n\nfunction extractVolumesArray(catalog: string): Element[] {\n\tconst $ = cheerio.load(catalog);\n\tconst results: Element[] = [];\n\t$(\"#volume-list div.volume\").each((_, elem) => {\n\t\t$(elem).remove(\"div.volume\");\n\t\tresults.push(elem);\n\t});\n\treturn results;\n}\n\nfunction processVolumeName(novelTitle: string, volumeName: string): string {\n\t// Remove novel title from volume name if present\n\tif (volumeName.startsWith(novelTitle)) {\n\t\treturn volumeName.slice(novelTitle.length).trim();\n\t}\n\tif (!Number.isNaN(Number(volumeName))) {\n\t\treturn `第 ${volumeName} 卷`;\n\t}\n\treturn volumeName.trim();\n}\n\nfunction parseVolumeOrChapterId(url: string): string {\n\tif (url.includes(\"javascript:cid(0)\")) {\n\t\treturn \"TOBEDETERMINED\";\n\t}\n\tconst match = url.match(/\\/novel\\/\\d+\\/(\\d+|vol_\\d+)\\.html/);\n\treturn match ? (match[1] ?? \"\") : \"\";\n}\n\nasync function parseChapterIdFromNextChapter(\n\tnextChapterEl: Element,\n\tchapterQueue: NovelChapterQueue,\n): Promise<string> {\n\tconst nextChapterPath = nextChapterEl.attribs.href ?? \"\";\n\tconst nextChapterContent = await chapterQueue.fetchChapterPart(\n\t\t`https://www.linovelib.com${nextChapterPath}`,\n\t);\n\tconst $temp = cheerio.load(nextChapterContent);\n\tconst chapterPath =\n\t\t$temp(\"div.mlfy_page a:first\").attr(\"href\") ??\n\t\tnextChapterContent.match(\n\t\t\t/url_previous:'(\\/novel\\/\\d+\\/[\\d_]+\\.html)'/,\n\t\t)?.[1] ??\n\t\t\"\";\n\treturn parseVolumeOrChapterId(chapterPath);\n}\n\nasync function getNovelVolumes(\n\ttitle: string,\n\turl: string,\n\tfetchClient: BrowserFetchClient,\n\tretry: RetryOptions,\n\tchapterQueue?: NovelChapterQueue,\n): Promise<Volume[]> {\n\tconst catalogHtml = await fetchClient.text(url, { retry });\n\tconst volumeEls = extractVolumesArray(catalogHtml.data);\n\tconst volumes: Volume[] = [];\n\tconst chapterElements: Element[] = [];\n\tfor (const volumeEl of volumeEls) {\n\t\tconst volumeEl$ = cheerio.load(volumeEl);\n\t\tconst volumeName = processVolumeName(title, volumeEl$(\"h2\").text());\n\t\tconst volumeId = parseVolumeOrChapterId(\n\t\t\tvolumeEl$(\"h2 a\").attr(\"href\") ?? \"\",\n\t\t);\n\t\tconst volumeCover: string =\n\t\t\tvolumeEl$(\"a.volume-cover img\").attr(\"data-original\") ?? \"\";\n\t\tconst chapterEls = volumeEl$(\"ul.chapter-list li a\").toArray();\n\t\tconst chapters: Chapter[] = [];\n\t\tfor (const [index, chapterEl] of chapterEls.entries()) {\n\t\t\tchapterElements.push(chapterEl);\n\t\t\tconst chapterEl$ = cheerio.load(chapterEl);\n\t\t\tconst chapterName = chapterEl$.text().trim();\n\t\t\tconst chapterPath = chapterEl.attribs.href ?? \"\";\n\t\t\tlet chapterId = parseVolumeOrChapterId(chapterPath);\n\t\t\tif (chapterId === \"TOBEDETERMINED\" && chapterQueue) {\n\t\t\t\tconst nextChapterEl = chapterEls[index + 1];\n\t\t\t\tif (nextChapterEl) {\n\t\t\t\t\tchapterId = await parseChapterIdFromNextChapter(\n\t\t\t\t\t\tnextChapterEl,\n\t\t\t\t\t\tchapterQueue,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\tchapters.push({\n\t\t\t\tid: chapterId,\n\t\t\t\tplatform: \"linovelib\",\n\t\t\t\ttitle: chapterName,\n\t\t\t\tvolumeId,\n\t\t\t});\n\t\t}\n\t\tvolumes.push({\n\t\t\tid: volumeId,\n\t\t\tplatform: \"linovelib\",\n\t\t\ttitle: volumeName,\n\t\t\tcoverUrl: volumeCover,\n\t\t\tchapters: chapters,\n\t\t});\n\t}\n\treturn volumes;\n}\n\nexport async function getNovelInfo(\n\tid: string,\n\tfetchClient: BrowserFetchClient,\n\tretry: RetryOptions,\n\tchapterQueue?: NovelChapterQueue,\n): Promise<Novel | undefined> {\n\tconst url = `https://www.linovelib.com/novel/${id}.html`;\n\tconst html = (\n\t\tawait fetchClient.text(url, {\n\t\t\tretry,\n\t\t})\n\t).data;\n\tconst $ = cheerio.load(html);\n\tconst title = $(\"h1.book-name\").text().trim();\n\tconst coverUrl = $(\"div.book-img img\").attr(\"src\") || novelIdToCoverUrl(id);\n\tconst summary = (() => {\n\t\tconst $container = $(\".book-dec.Jbook-dec\").clone();\n\t\t$container.find(\".notice\").remove();\n\t\tconst paragraphs: string[] = [];\n\t\t$container\n\t\t\t.find(\"p\")\n\t\t\t.not(\".backupname\")\n\t\t\t.each((_, el) => {\n\t\t\t\tparagraphs.push($(el).text().trim());\n\t\t\t});\n\t\treturn paragraphs.join(\"\\n\");\n\t})();\n\tconst author = $(\"div.au-name a:first\").text().trim();\n\tconst status: NovelStatus = $(\"div.book-label a.state\")\n\t\t.text()\n\t\t.includes(\"完结\")\n\t\t? \"completed\"\n\t\t: \"ongoing\";\n\tconst genres = $(\"div.book-label span\")\n\t\t.children(\"a\")\n\t\t.map((_, el) => $(el).text())\n\t\t.toArray()\n\t\t.join(\",\");\n\tconst novel: Novel = {\n\t\tid,\n\t\tplatform: \"linovelib\",\n\t\ttitle,\n\t\tcoverUrl,\n\t\tsummary,\n\t\tauthor,\n\t\tstatus,\n\t\tgenres: genres.split(\",\").map((g) => g.trim()),\n\t\tvolumes: [], // Volumes and chapters will be fetched separately\n\t};\n\tnovel.volumes = (\n\t\tawait getNovelVolumes(\n\t\t\ttitle,\n\t\t\t`https://www.linovelib.com${$(\"a.read-btn\").attr(\"href\")}`,\n\t\t\tfetchClient,\n\t\t\tretry,\n\t\t\tchapterQueue,\n\t\t)\n\t).map((v) => {\n\t\tv.novelId = novel.id;\n\t\treturn v;\n\t});\n\treturn novel;\n}\n\nexport interface NovelUpdateInfo {\n\tcoverUrl: string;\n\tchapterCount: number;\n}\n\nexport async function getUpdateInfo(\n\tid: string,\n\tfetchClient: BrowserFetchClient,\n\tretry: RetryOptions,\n): Promise<NovelUpdateInfo | null> {\n\tconst url = `https://www.linovelib.com/novel/${id}.html`;\n\tconst html = (\n\t\tawait fetchClient.text(url, {\n\t\t\tretry,\n\t\t})\n\t).data;\n\tconst $ = cheerio.load(html);\n\tif ($(\"h1.book-name\").length === 0) {\n\t\treturn null;\n\t}\n\tconst catalogUrl = `https://www.linovelib.com${$(\"a.read-btn\").attr(\"href\")}`;\n\tconst catalogHtml = (\n\t\tawait fetchClient.text(catalogUrl, {\n\t\t\tretry,\n\t\t})\n\t).data;\n\tconst $catalog = cheerio.load(catalogHtml);\n\tconst chapterCount = $catalog(\n\t\t\"#volume-list div.volume ul.chapter-list li a\",\n\t).length;\n\tconst coverUrl = $(\"div.book-img img\").attr(\"src\") || novelIdToCoverUrl(id);\n\treturn {\n\t\tcoverUrl,\n\t\tchapterCount,\n\t};\n}\n","import { webcrypto } from \"node:crypto\";\nimport type { BrowserFetchClient } from \"@acanthis-dec/browser-fetch\";\nimport type { NovelSearchResult } from \"@acanthis-dec/core\";\nimport * as cheerio from \"cheerio\";\nimport { extractNovelIdFromUrl } from \"./utils\";\n\nfunction k(e: string): Uint8Array<ArrayBuffer> {\n\t// 标准 Base64 映射表\n\tconst t = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\n\n\t// 1. 过滤掉所有不在映射表中的字符 (对应原代码的正则)\n\tconst n = e.replace(/[^A-Za-z0-9+/]/g, \"\");\n\tconst r = n.length;\n\n\t// 2. 计算输出长度:每 4 个字符转为 3 个字节\n\t// 注意:原代码通常不处理末尾填充,直接通过位移计算\n\tconst buf = new Uint8Array(Math.floor(r * 0.75));\n\tlet i = 0, // buf 指针\n\t\ta = 0, // 累加器\n\t\ts = 0, // 当前位深\n\t\tc = 0; // 临时索引\n\tfor (let l = 0; l < r; l++) {\n\t\tc = t.indexOf(n[l] || \"\");\n\t\tif (c === -1) continue; // 安全检查\n\t\ta = (a << 6) | c; // 每个 Base64 字符携带 6 位信息\n\t\ts += 6;\n\t\tif (s >= 8) {\n\t\t\ts -= 8;\n\t\t\t// 提取高 8 位存入字节数组\n\t\t\tbuf[i++] = (a >> s) & 255;\n\t\t}\n\t}\n\t// 关键:必须截取到实际写入的长度\n\t// 并强制转换为 Uint8Array<ArrayBuffer>\n\treturn new Uint8Array(buf.buffer.slice(0, i)) as Uint8Array<ArrayBuffer>;\n}\n\nasync function solveSearchChallenge(\n\ta: string,\n\tb: string,\n\tc: string,\n): Promise<string> {\n\tconst subtle = webcrypto.subtle;\n\t// 使用 as Uint8Array 明确告诉 TS 这是它需要的 BufferSource\n\tconst keyData = k(a);\n\tconst counterData = k(b);\n\tconst encryptedData = k(c);\n\ttry {\n\t\tconst cryptoKey = await subtle.importKey(\n\t\t\t\"raw\",\n\t\t\tkeyData,\n\t\t\t{ name: \"AES-CTR\" },\n\t\t\tfalse,\n\t\t\t[\"decrypt\"],\n\t\t);\n\t\tconst decryptedBuffer = await subtle.decrypt(\n\t\t\t{\n\t\t\t\tname: \"AES-CTR\",\n\t\t\t\tcounter: counterData,\n\t\t\t\tlength: 64,\n\t\t\t},\n\t\t\tcryptoKey,\n\t\t\tencryptedData,\n\t\t);\n\t\t// decryptedBuffer 得到的是 ArrayBuffer,需要转回 Uint8Array 供 TextDecoder 使用\n\t\tconst decoder = new TextDecoder();\n\t\tconst plainText = decoder.decode(new Uint8Array(decryptedBuffer));\n\t\treturn encodeURIComponent(plainText);\n\t} catch (error) {\n\t\tthrow new Error(`解密失败: ${error}`);\n\t}\n}\n\nexport async function searchNovels(\n\tkeyword: string,\n\tfetchClient: BrowserFetchClient,\n): Promise<NovelSearchResult[]> {\n\tlet response = await fetchClient.text(\"https://www.linovelib.com/S6/\", {\n\t\tmethod: \"POST\",\n\t\tbody: new URLSearchParams({\n\t\t\tsearchkey: keyword,\n\t\t}),\n\t\theaders: {\n\t\t\torigin: \"https://www.linovelib.com\",\n\t\t\treferer: \"https://www.linovelib.com/\",\n\t\t},\n\t});\n\tif (response.mimeType !== \"text/html\") {\n\t\tthrow new Error(`Unexpected response type: ${response.mimeType}`);\n\t}\n\tlet $ = cheerio.load(response.data);\n\tif ($(\"#challenge-running\").length > 0) {\n\t\tlet a = \"\",\n\t\t\tb = \"\",\n\t\t\tc = \"\";\n\t\t$(\"script\").each((_, el) => {\n\t\t\tconst scriptContent = $(el).html() || \"\";\n\t\t\tif (/window\\.a\\s*=\\s*'([^']+)'/.test(scriptContent)) {\n\t\t\t\ta = scriptContent.match(/window\\.a\\s*=\\s*'([^']+)'/)?.[1] || \"\";\n\t\t\t\tb = scriptContent.match(/window\\.b\\s*=\\s*'([^']+)'/)?.[1] || \"\";\n\t\t\t\tc = scriptContent.match(/window\\.c\\s*=\\s*'([^']+)'/)?.[1] || \"\";\n\t\t\t}\n\t\t});\n\t\tconst haha = await solveSearchChallenge(a, b, c);\n\t\tawait fetchClient.setCookies([\n\t\t\t{\n\t\t\t\tdomain: \"www.linovelib.com\",\n\t\t\t\tpath: \"/\",\n\t\t\t\tname: \"haha\",\n\t\t\t\tvalue: haha,\n\t\t\t\tmaxAge: 900,\n\t\t\t},\n\t\t]);\n\t\tawait new Promise((r) => setTimeout(r, 3000));\n\t\tresponse = await fetchClient.text(\"https://www.linovelib.com/S6/\", {\n\t\t\tmethod: \"POST\",\n\t\t\tbody: new URLSearchParams({\n\t\t\t\tsearchkey: keyword,\n\t\t\t}),\n\t\t\theaders: {\n\t\t\t\treferer: \"https://www.linovelib.com/S6/\",\n\t\t\t},\n\t\t});\n\t\t$ = cheerio.load(response.data);\n\t}\n\tif ($(\"#challenge-running\").length !== 0) {\n\t\tthrow new Error(\"Failed to solve search challenge\");\n\t}\n\tif ($(\"div.book-html-box\").length > 0) {\n\t\treturn [\n\t\t\t{\n\t\t\t\ttitle: $(\"h1.book-name\").text().trim(),\n\t\t\t\tplatform: \"linovelib\",\n\t\t\t\tid:\n\t\t\t\t\textractNovelIdFromUrl($(\"meta[name=url]\").attr(\"content\") ?? \"\") ||\n\t\t\t\t\t\"\",\n\t\t\t\tcoverUrl: $(\"div.book-img img\").attr(\"src\") || \"\",\n\t\t\t},\n\t\t];\n\t}\n\tif (!response.data.includes(\"有关\")) {\n\t\tthrow new Error(\"Unexpected search result format, keyword not found\");\n\t}\n\tconst pages =\n\t\t$(\"em#pagestats\")\n\t\t\t.text()\n\t\t\t.match(/1\\/(\\d+)/)?.[1] || \"1\";\n\tconst results: NovelSearchResult[] = [];\n\t$(\"div.search-html-box div.search-result-list\").each((_, el) => {\n\t\tconst $el = $(el);\n\t\tconst title = $el.find(\"h2\").text().trim();\n\t\tconst url = $el.find(\"h2 a\").attr(\"href\") || \"\";\n\t\tconst id = extractNovelIdFromUrl(url) ?? \"\";\n\t\tconst coverUrl = $el.find(\"img\").attr(\"src\") || \"\";\n\t\tresults.push({\n\t\t\ttitle,\n\t\t\tplatform: \"linovelib\",\n\t\t\tid,\n\t\t\tcoverUrl,\n\t\t});\n\t});\n\tif (Number(pages) > 1) {\n\t\tlet currentPageHtml = response.data;\n\t\twhile (true) {\n\t\t\tconst $2 = cheerio.load(currentPageHtml);\n\t\t\tif ($2(\"a.next\").length > 0) {\n\t\t\t\tcurrentPageHtml = (\n\t\t\t\t\tawait fetchClient.text(\n\t\t\t\t\t\t`https://www.linovelib.com${$2(\"a.next\").attr(\"href\")}`,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\theaders: {\n\t\t\t\t\t\t\t\thost: \"www.linovelib.com\",\n\t\t\t\t\t\t\t\treferer: \"https://www.linovelib.com/S6/\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t)\n\t\t\t\t).data;\n\t\t\t}\n\t\t\tconst $3 = cheerio.load(currentPageHtml);\n\t\t\t$3(\"div.search-html-box div.search-result-list\").each((_, el) => {\n\t\t\t\tconst $el = $3(el);\n\t\t\t\tconst title = $el.find(\"h2\").text().trim();\n\t\t\t\tconst url = $el.find(\"h2 a\").attr(\"href\") || \"\";\n\t\t\t\tconst id = extractNovelIdFromUrl(url) ?? \"\";\n\t\t\t\tconst coverUrl = $el.find(\"img\").attr(\"src\") || \"\";\n\t\t\t\tresults.push({\n\t\t\t\t\ttitle,\n\t\t\t\t\tplatform: \"linovelib\",\n\t\t\t\t\tid,\n\t\t\t\t\tcoverUrl,\n\t\t\t\t});\n\t\t\t});\n\t\t\tif ($3(\"a.next\").length === 0) break;\n\t\t}\n\t}\n\treturn results;\n}\n","import {\n\ttype BrowserFetchClient,\n\tCloudflareBlockError,\n\tdefaultRetryPolicy,\n\ttype RetryOptions,\n} from \"@acanthis-dec/browser-fetch\";\nimport type { Novel, NovelSearchResult } from \"@acanthis-dec/core\";\nimport PQueue from \"p-queue\";\nimport type { Logger } from \"winston\";\nimport { getNovelInfo, getUpdateInfo, type NovelUpdateInfo } from \"./novel\";\nimport { searchNovels } from \"./search\";\n\n/**\n * Simple backoff strategy for request rate limiting\n * - Normal desktop delay: 500-1000ms random\n * - Normal mobile delay: 2000-5000ms random\n * - Failure delay: 8000ms (8 seconds)\n */\nclass SimpleBackoff {\n\treadonly NORMAL_DELAY_MIN = 500;\n\treadonly NORMAL_DELAY_MAX = 1000;\n\treadonly NORMAL_MOBILE_DELAY_MIN = 2000;\n\treadonly NORMAL_MOBILE_DELAY_MAX = 5000;\n\treadonly FAILURE_DELAY = 15000;\n\n\t/**\n\t * Get delay for normal (successful) operation\n\t * @returns Random delay in range [500, 1000]ms. If isMobile is true, returns random delay in range [2000, 5000]ms\n\t */\n\tgetDelayForSuccess(isMobile: boolean = false): number {\n\t\tif (isMobile) {\n\t\t\treturn (\n\t\t\t\tthis.NORMAL_MOBILE_DELAY_MIN +\n\t\t\t\tMath.random() *\n\t\t\t\t\t(this.NORMAL_MOBILE_DELAY_MAX - this.NORMAL_MOBILE_DELAY_MIN)\n\t\t\t);\n\t\t}\n\t\treturn (\n\t\t\tthis.NORMAL_DELAY_MIN +\n\t\t\tMath.random() * (this.NORMAL_DELAY_MAX - this.NORMAL_DELAY_MIN)\n\t\t);\n\t}\n}\n\nexport class SearchQueue {\n\tprivate queue: PQueue;\n\tprivate client: BrowserFetchClient;\n\tprivate logger?: Logger | undefined;\n\tprivate readonly COOLDOWN_MS = 5000;\n\tprivate lastSearchTime = 0;\n\n\tconstructor(client: BrowserFetchClient, logger?: Logger) {\n\t\tthis.queue = new PQueue({ concurrency: 1 });\n\t\tthis.client = client;\n\t\tthis.logger = logger;\n\t\tthis.queue.on(\"add\", () => {\n\t\t\tthis.logger?.debug(\n\t\t\t\t`[SearchQueue] 任务已添加,当前排队数: ${this.queue.size} (等待中任务数: ${this.queue.pending})`,\n\t\t\t);\n\t\t});\n\t\tthis.queue.on(\"next\", () => {\n\t\t\tthis.logger?.debug(\n\t\t\t\t`[SearchQueue] 任务完成或超时,开始下一个任务。剩余:${this.queue.size} `,\n\t\t\t);\n\t\t});\n\t}\n\n\tasync searchNovels(keyword: string): Promise<NovelSearchResult[]> {\n\t\treturn await this.queue.add(async () => {\n\t\t\tif (Date.now() - this.lastSearchTime < this.COOLDOWN_MS) {\n\t\t\t\tconst waitTime = this.COOLDOWN_MS - (Date.now() - this.lastSearchTime);\n\t\t\t\tthis.logger?.debug(\n\t\t\t\t\t`[SearchQueue] 搜索请求过快,等待 ${waitTime}ms 后重试`,\n\t\t\t\t);\n\t\t\t\tawait new Promise((resolve) => setTimeout(resolve, waitTime));\n\t\t\t}\n\t\t\tthis.logger?.debug(`[SearchQueue] 开始搜索关键词 \"${keyword}\"`);\n\t\t\tconst results = await searchNovels(keyword, this.client);\n\t\t\tthis.logger?.debug(\n\t\t\t\t`[SearchQueue] 搜索完成,关键词 \"${keyword}\" 共找到 ${results.length} 条结果`,\n\t\t\t);\n\t\t\tthis.lastSearchTime = Date.now();\n\t\t\treturn results;\n\t\t});\n\t}\n}\n\nexport class NovelChapterQueue {\n\tprivate queue: PQueue;\n\tprivate client: BrowserFetchClient;\n\tprivate backoff: SimpleBackoff;\n\tprivate logger?: Logger | undefined;\n\n\tconstructor(client: BrowserFetchClient, logger?: Logger) {\n\t\tthis.queue = new PQueue({ concurrency: 1 });\n\t\tthis.client = client;\n\t\tthis.backoff = new SimpleBackoff();\n\t\tthis.logger = logger;\n\t\tthis.queue.on(\"add\", () => {\n\t\t\tthis.logger?.debug(\n\t\t\t\t`[NovelChapterQueue] 任务已添加,当前排队数: ${this.queue.size} (等待中任务数: ${this.queue.pending})`,\n\t\t\t);\n\t\t});\n\t\tthis.queue.on(\"next\", () => {\n\t\t\tthis.logger?.debug(\n\t\t\t\t`[NovelChapterQueue] 任务完成或超时,开始下一个任务。剩余:${this.queue.size} `,\n\t\t\t);\n\t\t});\n\t}\n\n\tprivate async _sleep(ms: number) {\n\t\treturn new Promise((resolve) => setTimeout(resolve, ms));\n\t}\n\n\tasync fetchChapterPart(url: string): Promise<string> {\n\t\treturn await this.queue.add(async () => {\n\t\t\tconst match = url.match(/\\/novel\\/(\\d+)\\/(\\d+)(?:_(\\d+))?\\.html/);\n\t\t\tif (!match) {\n\t\t\t\tthrow new Error(`Invalid chapter URL: ${url}`);\n\t\t\t}\n\t\t\tconst novelId = match[1];\n\t\t\tconst chapterId = match[2];\n\t\t\tconst partId = match[3] || \"1\";\n\t\t\tthis.logger?.debug(\n\t\t\t\t`[NovelChapterQueue] 开始获取小说${novelId}章节${chapterId}的第${partId}部分内容`,\n\t\t\t);\n\n\t\t\tconst retry: RetryOptions = {\n\t\t\t\tretries: 10,\n\t\t\t\tfactor: 2,\n\t\t\t\tminRetryDelayMs: 0,\n\t\t\t\tmaxRetryDelayMs: 0,\n\t\t\t\trandomize: false,\n\t\t\t\tonFailedAttempt: async (ctx) => {\n\t\t\t\t\tif (ctx.error instanceof CloudflareBlockError) {\n\t\t\t\t\t\tthis.logger?.warn(\n\t\t\t\t\t\t\t`[NovelChapterQueue] 请求被 Cloudflare 阻挡,错误信息: ${ctx.error.message}。正在等待 ${this.backoff.FAILURE_DELAY / 1000}s 后重试...`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tawait this._sleep(this.backoff.FAILURE_DELAY);\n\t\t\t\t\t}\n\t\t\t\t\tif (ctx.attemptNumber >= (retry.retries ?? 3)) {\n\t\t\t\t\t\tthis.logger?.error(\n\t\t\t\t\t\t\t`[NovelChapterQueue] 请求重试次数已达上限 (${ctx.attemptNumber} 次),错误信息: ${ctx.error.message}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tshouldRetry: async (ctx) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\tdefaultRetryPolicy(ctx) || ctx.error instanceof CloudflareBlockError\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tlet content = (await this.client.text(url, { retry })).data ?? \"\";\n\t\t\tif (content.match(/沒有可閱讀的章節|没有可阅读的章节/i)) {\n\t\t\t\tcontent = (\n\t\t\t\t\tawait this.client.text(url, {\n\t\t\t\t\t\tprofile: \"chrome149-android\",\n\t\t\t\t\t\tretry: {\n\t\t\t\t\t\t\t...retry,\n\t\t\t\t\t\t\tminRetryDelayMs: this.backoff.NORMAL_MOBILE_DELAY_MIN,\n\t\t\t\t\t\t\tmaxRetryDelayMs: this.backoff.NORMAL_MOBILE_DELAY_MAX,\n\t\t\t\t\t\t},\n\t\t\t\t\t})\n\t\t\t\t).data;\n\t\t\t\tconst delay = this.backoff.getDelayForSuccess(true);\n\t\t\t\tthis.logger?.debug(\n\t\t\t\t\t`[NovelChapterQueue] 小说${novelId}-章节${chapterId}_${partId} 获取成功。下一次请求将在 ${delay.toFixed(0)}ms 后进行`,\n\t\t\t\t);\n\t\t\t\tawait this._sleep(delay);\n\t\t\t\treturn content;\n\t\t\t}\n\t\t\tconst delay = this.backoff.getDelayForSuccess();\n\t\t\tthis.logger?.debug(\n\t\t\t\t`[NovelChapterQueue] 小说${novelId}-章节${chapterId}_${partId} 获取成功。下一次请求将在 ${delay.toFixed(0)}ms 后进行`,\n\t\t\t);\n\t\t\tawait this._sleep(delay);\n\t\t\treturn content;\n\t\t});\n\t}\n}\n\nexport class NovelInfoQueue {\n\tprivate queue: PQueue;\n\tprivate client: BrowserFetchClient;\n\tprivate backoff: SimpleBackoff;\n\tprivate chapterQueue: NovelChapterQueue;\n\tprivate logger?: Logger | undefined;\n\n\tconstructor(\n\t\tclient: BrowserFetchClient,\n\t\tchapterQueue: NovelChapterQueue,\n\t\tlogger?: Logger,\n\t) {\n\t\tthis.queue = new PQueue({ concurrency: 1 });\n\t\tthis.client = client;\n\t\tthis.backoff = new SimpleBackoff();\n\t\tthis.chapterQueue = chapterQueue;\n\t\tthis.logger = logger;\n\t\tthis.queue.on(\"add\", () => {\n\t\t\tthis.logger?.debug(\n\t\t\t\t`[NovelInfoQueue] 任务已添加,当前排队数: ${this.queue.size} (等待中任务数: ${this.queue.pending})`,\n\t\t\t);\n\t\t});\n\t\tthis.queue.on(\"next\", () => {\n\t\t\tthis.logger?.debug(\n\t\t\t\t`[NovelInfoQueue] 任务完成或超时,开始下一个任务。剩余:${this.queue.size} `,\n\t\t\t);\n\t\t});\n\t}\n\n\tprivate async _sleep(ms: number) {\n\t\treturn new Promise((resolve) => setTimeout(resolve, ms));\n\t}\n\n\tasync fetchNovelInfo(id: string): Promise<Novel> {\n\t\treturn await this.queue.add(async () => {\n\t\t\tthis.logger?.debug(`[NovelInfoQueue] 开始获取小说${id}的信息`);\n\t\t\tconst retry: RetryOptions = {\n\t\t\t\tretries: 10,\n\t\t\t\tfactor: 2,\n\t\t\t\tminRetryDelayMs: 0,\n\t\t\t\tmaxRetryDelayMs: 0,\n\t\t\t\trandomize: false,\n\t\t\t\tonFailedAttempt: async (ctx) => {\n\t\t\t\t\tif (ctx.error instanceof CloudflareBlockError) {\n\t\t\t\t\t\tthis.logger?.warn(\n\t\t\t\t\t\t\t`[NovelInfoQueue] 请求被 Cloudflare 阻挡,错误信息: ${ctx.error.message}。正在等待 ${this.backoff.FAILURE_DELAY / 1000}s 后重试...`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tawait this._sleep(this.backoff.FAILURE_DELAY);\n\t\t\t\t\t}\n\t\t\t\t\tif (ctx.attemptNumber >= (retry.retries ?? 3)) {\n\t\t\t\t\t\tthis.logger?.error(\n\t\t\t\t\t\t\t`[NovelInfoQueue] 请求重试次数已达上限 (${ctx.attemptNumber} 次),错误信息: ${ctx.error.message}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tshouldRetry: async (ctx) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\tdefaultRetryPolicy(ctx) || ctx.error instanceof CloudflareBlockError\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tconst novel = await getNovelInfo(\n\t\t\t\tid,\n\t\t\t\tthis.client,\n\t\t\t\tretry,\n\t\t\t\tthis.chapterQueue,\n\t\t\t);\n\t\t\tif (!novel) {\n\t\t\t\tthrow new Error(`无法获取小说信息: ${id}`);\n\t\t\t}\n\t\t\tconst delay = this.backoff.getDelayForSuccess();\n\t\t\tthis.logger?.debug(\n\t\t\t\t`[NovelInfoQueue] 小说${id} 信息获取成功。下一次请求将在 ${delay.toFixed(0)}ms 后进行`,\n\t\t\t);\n\t\t\tawait this._sleep(delay);\n\t\t\treturn novel;\n\t\t});\n\t}\n\n\tasync fetchNovelUpdateInfo(id: string): Promise<NovelUpdateInfo | null> {\n\t\treturn await this.queue.add(async () => {\n\t\t\tthis.logger?.debug(\n\t\t\t\t`[NovelInfoQueue] 开始获取小说${id}的更新信息(封面和章节数)`,\n\t\t\t);\n\t\t\tconst retry: RetryOptions = {\n\t\t\t\tretries: 10,\n\t\t\t\tfactor: 2,\n\t\t\t\tminRetryDelayMs: 0,\n\t\t\t\tmaxRetryDelayMs: 0,\n\t\t\t\trandomize: false,\n\t\t\t\tonFailedAttempt: async (ctx) => {\n\t\t\t\t\tif (ctx.error instanceof CloudflareBlockError) {\n\t\t\t\t\t\tthis.logger?.warn(\n\t\t\t\t\t\t\t`[NovelInfoQueue] 请求被 Cloudflare 阻挡,错误信息: ${ctx.error.message}。正在等待 ${this.backoff.FAILURE_DELAY / 1000}s 后重试...`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tawait this._sleep(this.backoff.FAILURE_DELAY);\n\t\t\t\t\t}\n\t\t\t\t\tif (ctx.attemptNumber >= (retry.retries ?? 3)) {\n\t\t\t\t\t\tthis.logger?.error(\n\t\t\t\t\t\t\t`[NovelInfoQueue] 请求重试次数已达上限 (${ctx.attemptNumber} 次),错误信息: ${ctx.error.message}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tshouldRetry: async (ctx) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\tdefaultRetryPolicy(ctx) || ctx.error instanceof CloudflareBlockError\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tconst updateInfo = await getUpdateInfo(id, this.client, retry);\n\t\t\tif (!updateInfo) {\n\t\t\t\tthis.logger?.warn(\n\t\t\t\t\t`[NovelInfoQueue] 无法获取小说${id}的更新信息,可能是因为小说不存在或已被删除`,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tthis.logger?.debug(\n\t\t\t\t\t`[NovelInfoQueue] 小说${id} 更新信息获取成功。下一次请求将在 ${this.backoff.getDelayForSuccess().toFixed(0)}ms 后进行`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tawait this._sleep(this.backoff.getDelayForSuccess());\n\t\t\treturn updateInfo;\n\t\t});\n\t}\n}\n","import type { BrowserFetchClient } from \"@acanthis-dec/browser-fetch\";\n\nexport interface LoginConfig {\n\tusername: string;\n\tpassword: string;\n}\n\nexport async function refreshSessionId(\n\tfetchClient: BrowserFetchClient,\n\tloginConfig: LoginConfig,\n): Promise<boolean> {\n\tawait fetchClient.request({\n\t\turl: \"https://www.linovelib.com/login.php\",\n\t\tmethod: \"GET\",\n\t\theaders: {\n\t\t\treferer: \"https://www.linovelib.com/\",\n\t\t},\n\t});\n\tconst response = await fetchClient.request({\n\t\turl: \"https://www.linovelib.com/login.php?do=submit&jumpurl=https%3A%2F%2Fwww.linovelib.com%2F\",\n\t\tmethod: \"POST\",\n\t\tbody: new URLSearchParams({\n\t\t\tusername: loginConfig.username,\n\t\t\tpassword: loginConfig.password,\n\t\t\tusecookie: \"3153600000\",\n\t\t\tsubmit: \"登录\",\n\t\t\taction: \"login\",\n\t\t}),\n\t\tfollowRedirects: false,\n\t});\n\treturn (\n\t\tresponse.cookies.findIndex((cookie) => cookie.name === \"PHPSESSID\") !== -1\n\t);\n}\n\nexport async function hasValidSession(\n\tfetchClient: BrowserFetchClient,\n): Promise<boolean> {\n\tconst response = await fetchClient.text(\"https://www.linovelib.com\");\n\tif (response.data.includes(\"用户中心\")) return true;\n\telse return false;\n}\n\nexport async function ensureValidSession(\n\tfetchClient: BrowserFetchClient,\n\tloginConfig: LoginConfig,\n): Promise<boolean> {\n\tif (!(await hasValidSession(fetchClient))) {\n\t\tconst isValid =\n\t\t\t(await refreshSessionId(fetchClient, loginConfig)) &&\n\t\t\t(await hasValidSession(fetchClient));\n\t\tif (!isValid) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n","import {\n\ttype BinaryResponse,\n\tBrowserFetchClient,\n\ttype BrowserFetchClientOptions,\n\ttype BrowserProfileName,\n\ttype FlareSolverrOptions,\n} from \"@acanthis-dec/browser-fetch\";\nimport type {\n\tDescrambleCoefficients,\n\tNovel,\n\tNovelSearchResult,\n} from \"@acanthis-dec/core\";\nimport type { StorageService } from \"@acanthis-dec/storage\";\nimport { deepmerge } from \"deepmerge-ts\";\nimport type { Logger } from \"winston\";\nimport z from \"zod\";\nimport { getChapter } from \"./chapter\";\nimport { descrambleCoefficientsSchema } from \"./coefficients\";\nimport { getCover } from \"./cover\";\nimport type { NovelUpdateInfo } from \"./novel\";\nimport { NovelChapterQueue, NovelInfoQueue, SearchQueue } from \"./queue\";\nimport { ensureValidSession } from \"./session\";\n\nexport type SessionOptions =\n\t| {\n\t\t\tenabled: false;\n\t }\n\t| {\n\t\t\tenabled: true;\n\t\t\tusername: string;\n\t\t\tpassword: string;\n\t };\n\nexport type ImpersonateOptions =\n\t| {\n\t\t\tenabled: true;\n\t\t\tprofile: BrowserProfileName;\n\t }\n\t| {\n\t\t\tenabled: false;\n\t };\n\nexport type CookieStoreOptions =\n\t| {\n\t\t\ttype: \"memory\" | \"database\";\n\t }\n\t| {\n\t\t\ttype: \"file\";\n\t\t\tpath: string;\n\t };\n\nexport type LinovelibClientOptions = {\n\tsession: SessionOptions;\n\tflareSolverr: FlareSolverrOptions;\n\timpersonate: ImpersonateOptions;\n\tcookies: CookieStoreOptions;\n\tproxy?: string | undefined;\n};\n\nexport class LinovelibClient {\n\tprivate storage?: StorageService | undefined;\n\tprivate fetchClient: BrowserFetchClient;\n\tprivate novelChapterQueue: NovelChapterQueue;\n\tprivate novelInfoQueue: NovelInfoQueue;\n\tprivate searchQueue: SearchQueue;\n\tprivate options?: LinovelibClientOptions;\n\tprivate logger?: Logger | undefined;\n\tprivate isSessionValid?: boolean = undefined;\n\n\tconstructor(\n\t\toptions?: LinovelibClientOptions,\n\t\tstorage?: StorageService,\n\t\tlogger?: Logger,\n\t) {\n\t\tconst defaultOptions: LinovelibClientOptions = {\n\t\t\tsession: {\n\t\t\t\tenabled: false,\n\t\t\t},\n\t\t\tflareSolverr: {\n\t\t\t\tenabled: true,\n\t\t\t\thost: \"http://localhost:8191\",\n\t\t\t\ttimeoutMs: 60000,\n\t\t\t\tsessionId: \"acanthis-linovelib-client\",\n\t\t\t},\n\t\t\timpersonate: {\n\t\t\t\tenabled: true,\n\t\t\t\tprofile: \"chrome149-linux\",\n\t\t\t},\n\t\t\tcookies: {\n\t\t\t\ttype: \"memory\",\n\t\t\t},\n\t\t};\n\t\tthis.options = deepmerge(\n\t\t\tdefaultOptions,\n\t\t\toptions ?? {},\n\t\t) as LinovelibClientOptions;\n\t\tthis.storage = storage;\n\t\tthis.logger = logger;\n\t\tconst browserFetchOptions: BrowserFetchClientOptions = {};\n\t\tif (this.options?.flareSolverr.enabled) {\n\t\t\tbrowserFetchOptions.flareSolverr = {\n\t\t\t\tenabled: true,\n\t\t\t\thost: this.options.flareSolverr.host,\n\t\t\t\ttimeoutMs: this.options.flareSolverr.timeoutMs ?? 60000,\n\t\t\t\tsessionId:\n\t\t\t\t\tthis.options.flareSolverr.sessionId ?? \"acanthis-linovelib-client\",\n\t\t\t};\n\t\t} else {\n\t\t\tbrowserFetchOptions.flareSolverr = {\n\t\t\t\tenabled: false,\n\t\t\t};\n\t\t}\n\t\tif (this.options?.proxy) {\n\t\t\tbrowserFetchOptions.proxy = this.options.proxy;\n\t\t}\n\t\tif (this.options?.impersonate.enabled) {\n\t\t\tbrowserFetchOptions.profile = this.options.impersonate.profile;\n\t\t}\n\t\tswitch (this.options?.cookies.type) {\n\t\t\tcase \"memory\":\n\t\t\t\tbrowserFetchOptions.cookieStore = {\n\t\t\t\t\ttype: \"memory\",\n\t\t\t\t};\n\t\t\t\tbreak;\n\t\t\tcase \"file\":\n\t\t\t\tbrowserFetchOptions.cookieStore = {\n\t\t\t\t\ttype: \"file\",\n\t\t\t\t\tpath: this.options.cookies.path,\n\t\t\t\t};\n\t\t\t\tbreak;\n\t\t\tcase \"database\":\n\t\t\t\tif (!this.storage) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\"StorageService is required for database cookie store\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbrowserFetchOptions.cookieStore = {\n\t\t\t\t\ttype: \"custom\",\n\t\t\t\t\tstore: this.storage.getCookieStore(),\n\t\t\t\t};\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tbrowserFetchOptions.cookieStore = {\n\t\t\t\t\ttype: \"memory\",\n\t\t\t\t};\n\t\t}\n\t\tthis.fetchClient = new BrowserFetchClient(browserFetchOptions);\n\t\tthis.novelChapterQueue = new NovelChapterQueue(\n\t\t\tthis.fetchClient,\n\t\t\tthis.logger,\n\t\t);\n\t\tthis.novelInfoQueue = new NovelInfoQueue(\n\t\t\tthis.fetchClient,\n\t\t\tthis.novelChapterQueue,\n\t\t\tthis.logger,\n\t\t);\n\t\tthis.searchQueue = new SearchQueue(this.fetchClient, this.logger);\n\t}\n\n\tasync getNovelInfo(id: string): Promise<Novel | undefined> {\n\t\tif (this.options?.session.enabled && !this.isSessionValid) {\n\t\t\tthis.isSessionValid = await ensureValidSession(this.fetchClient, {\n\t\t\t\tusername: this.options.session.username,\n\t\t\t\tpassword: this.options.session.password,\n\t\t\t});\n\t\t}\n\t\treturn await this.novelInfoQueue.fetchNovelInfo(id);\n\t}\n\n\tasync getNovelUpdateInfo(id: string): Promise<NovelUpdateInfo | null> {\n\t\tif (this.options?.session.enabled && !this.isSessionValid) {\n\t\t\tthis.isSessionValid = await ensureValidSession(this.fetchClient, {\n\t\t\t\tusername: this.options.session.username,\n\t\t\t\tpassword: this.options.session.password,\n\t\t\t});\n\t\t}\n\t\treturn await this.novelInfoQueue.fetchNovelUpdateInfo(id);\n\t}\n\n\tasync searchNovels(keyword: string): Promise<NovelSearchResult[]> {\n\t\tif (this.options?.session.enabled && !this.isSessionValid) {\n\t\t\tthis.isSessionValid = await ensureValidSession(this.fetchClient, {\n\t\t\t\tusername: this.options.session.username,\n\t\t\t\tpassword: this.options.session.password,\n\t\t\t});\n\t\t}\n\t\treturn await this.searchQueue.searchNovels(keyword);\n\t}\n\n\tasync getNovelCover(novelId: string) {\n\t\treturn await getCover(novelId, this.fetchClient);\n\t}\n\n\tasync getCover(url: string): Promise<BinaryResponse> {\n\t\treturn await this.fetchClient.binary(url, {\n\t\t\theaders: {\n\t\t\t\tReferer: \"https://www.linovelib.com/\",\n\t\t\t},\n\t\t});\n\t}\n\n\tasync getChapter(\n\t\tnovelId: string,\n\t\tchapterId: string,\n\t): Promise<string | undefined> {\n\t\tif (this.options?.session.enabled && !this.isSessionValid) {\n\t\t\tthis.isSessionValid = await ensureValidSession(this.fetchClient, {\n\t\t\t\tusername: this.options.session.username,\n\t\t\t\tpassword: this.options.session.password,\n\t\t\t});\n\t\t}\n\t\tconst cachedJsVersion = this.storage\n\t\t\t? ((await this.storage.getCache(\"chapterlog_js_version\", z.string())) ??\n\t\t\t\tundefined)\n\t\t\t: undefined;\n\t\tconst cachedCoefficients = this.storage\n\t\t\t? ((await this.storage.getCache<DescrambleCoefficients>(\n\t\t\t\t\t\"coefficients\",\n\t\t\t\t\tdescrambleCoefficientsSchema,\n\t\t\t\t)) ?? undefined)\n\t\t\t: undefined;\n\t\tconst result = await getChapter(\n\t\t\tchapterId,\n\t\t\tnovelId,\n\t\t\tthis.novelChapterQueue,\n\t\t\tthis.fetchClient,\n\t\t\tcachedJsVersion,\n\t\t\tcachedCoefficients,\n\t\t);\n\t\tif (this.storage && result) {\n\t\t\tawait this.storage.setCache(\"chapterlog_js_version\", result.version);\n\t\t\tawait this.storage.setCache(\"coefficients\", result.coefficients);\n\t\t}\n\t\treturn result?.content;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;AAWA,MAAM,WACJ,eAA6D,WAC9D;AAED,MAAa,+BAA+B,EAAE,OAAO;CACpD,SAAS,EAAE,OAAO,CAAC,CAAC,IAAI;CACxB,WAAW,EAAE,OAAO,CAAC,CAAC,IAAI;CAC1B,YAAY,EAAE,OAAO,CAAC,CAAC,IAAI;CAC3B,YAAY,EAAE,OAAO,CAAC,CAAC,IAAI;CAC3B,gBAAgB,EAAE,OAAO,CAAC,CAAC,IAAI;AAChC,CAAC;AAED,SAAS,kBAAkB,UAA0B;CACpD,OAAO,SACL,MAAM,OAAO,CAAC,CACd,KAAK,SAAS,KAAK,KAAK,CAAC,CAAC,CAC1B,QAAQ,SAAS,SAAS,EAAE,CAAC,CAC7B,MAAM,EAAE,CAAC,CACT,KAAK,IAAI;AACZ;AAEA,eAAsB,oBACrB,QACkC;CAGlC,MA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;GAC3B,MAAM,KAAK,QAAQ,SAAS,yBAAyB,OAAO,OAAO;GACnE,MAAM,KAAK,QAAQ,SAAS,gBAAgB,OAAO,YAAY;EAChE;EACA,OAAO,QAAQ;CAChB;AACD"}
1
+ {"version":3,"file":"index.mjs","names":["z"],"sources":["../src/coefficients.ts","../src/utils.ts","../src/chapter.ts","../src/cover.ts","../src/novel.ts","../src/search.ts","../src/queue.ts","../src/session.ts","../src/client.ts"],"sourcesContent":["import type { BrowserFetchClient } from \"@acanthis-dec/browser-fetch\";\nimport type { DescrambleCoefficients } from \"@acanthis-dec/core\";\nimport { deobfuscate } from \"@acanthis-dec/deobfuscator\";\nimport { parse } from \"@babel/parser\";\nimport traverseModule from \"@babel/traverse\";\nimport * as t from \"@babel/types\";\nimport * as cheerio from \"cheerio\";\nimport { z } from \"zod\";\n\ntype TraverseFunction = typeof traverseModule;\n\nconst traverse =\n\t(traverseModule as unknown as { default?: TraverseFunction }).default ??\n\ttraverseModule;\n\nexport const descrambleCoefficientsSchema = z.object({\n\tmodulus: z.number().int(),\n\tincrement: z.number().int(),\n\tmultiplier: z.number().int(),\n\tseedOffset: z.number().int(),\n\tseedMultiplier: z.number().int(),\n});\n\nfunction getObfuscatedPart(fullCode: string): string {\n\treturn fullCode\n\t\t.split(/\\r?\\n/)\n\t\t.map((line) => line.trim())\n\t\t.filter((line) => line !== \"\")\n\t\t.slice(-2)\n\t\t.join(\"\\n\");\n}\n\nexport async function extractCoefficients(\n\tscript: string,\n): Promise<DescrambleCoefficients> {\n\tconst obfuscatedPart = getObfuscatedPart(script);\n\tconst deObfCode = await deobfuscate(obfuscatedPart);\n\tconst ast = parse(deObfCode, { sourceType: \"module\", plugins: [\"jsx\"] });\n\tconst coefficients: Partial<DescrambleCoefficients> = {};\n\ttraverse(ast, {\n\t\tBinaryExpression(path) {\n\t\t\tconst { node } = path;\n\t\t\tif (\n\t\t\t\tnode.operator === \"%\" &&\n\t\t\t\tt.isNumericLiteral(node.right) &&\n\t\t\t\tt.isBinaryExpression(node.left) &&\n\t\t\t\tnode.left.operator === \"+\" &&\n\t\t\t\tt.isNumericLiteral(node.left.right) &&\n\t\t\t\tt.isBinaryExpression(node.left.left) &&\n\t\t\t\tnode.left.left.operator === \"*\" &&\n\t\t\t\tt.isNumericLiteral(node.left.left.right)\n\t\t\t) {\n\t\t\t\tcoefficients.modulus = node.right.value;\n\t\t\t\tconst leftSide = node.left;\n\t\t\t\tif (t.isBinaryExpression(leftSide) && leftSide.operator === \"+\") {\n\t\t\t\t\tif (t.isNumericLiteral(leftSide.right)) {\n\t\t\t\t\t\tcoefficients.increment = leftSide.right.value;\n\t\t\t\t\t}\n\t\t\t\t\tif (\n\t\t\t\t\t\tt.isBinaryExpression(leftSide.left) &&\n\t\t\t\t\t\tleftSide.left.operator === \"*\"\n\t\t\t\t\t) {\n\t\t\t\t\t\tif (t.isNumericLiteral(leftSide.left.right)) {\n\t\t\t\t\t\t\tcoefficients.multiplier = leftSide.left.right.value;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (\n\t\t\t\tnode.operator === \"+\" &&\n\t\t\t\tt.isNumericLiteral(node.right) &&\n\t\t\t\tt.isBinaryExpression(node.left) &&\n\t\t\t\tnode.left.operator === \"*\" &&\n\t\t\t\tt.isNumericLiteral(node.left.right)\n\t\t\t) {\n\t\t\t\tconst potentialOffset = node.right.value;\n\t\t\t\tconst potentialMultiplier = node.left.right.value;\n\t\t\t\tconst numberTransformed = node.left.left;\n\t\t\t\tif (\n\t\t\t\t\tt.isCallExpression(numberTransformed) &&\n\t\t\t\t\tt.isIdentifier(numberTransformed.callee) &&\n\t\t\t\t\t(numberTransformed.callee.name === \"Number\" ||\n\t\t\t\t\t\tnumberTransformed.callee.name === \"parseInt\")\n\t\t\t\t) {\n\t\t\t\t\tcoefficients.seedOffset = potentialOffset;\n\t\t\t\t\tcoefficients.seedMultiplier = potentialMultiplier;\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t});\n\tif (\n\t\tcoefficients.modulus === undefined ||\n\t\tcoefficients.increment === undefined ||\n\t\tcoefficients.multiplier === undefined ||\n\t\tcoefficients.seedOffset === undefined ||\n\t\tcoefficients.seedMultiplier === undefined\n\t) {\n\t\tthrow new Error(\"Failed to extract all coefficients\");\n\t}\n\treturn coefficients as DescrambleCoefficients;\n}\n\nexport function extractChapterLogScriptUrl(html: string): string {\n\tconst $ = cheerio.load(html);\n\tconst chapterLogScriptUrl =\n\t\t$(\n\t\t\t$(\"script\")\n\t\t\t\t.toArray()\n\t\t\t\t.find((el) => {\n\t\t\t\t\tconst scriptContent = $(el).attr(\"src\") || \"\";\n\t\t\t\t\treturn /chapterlog\\.js/.test(scriptContent);\n\t\t\t\t}),\n\t\t).attr(\"src\") || \"\";\n\treturn chapterLogScriptUrl.startsWith(\"http\")\n\t\t? chapterLogScriptUrl\n\t\t: `https://www.linovelib.com${chapterLogScriptUrl}`;\n}\n\nexport interface CoefficientResult {\n\tcoefficients: DescrambleCoefficients;\n\tversion: string;\n}\n\nexport async function getCoefficientsFromPage(\n\thtml: string,\n\tfetchClient: BrowserFetchClient,\n\tcachedVersion?: string,\n): Promise<CoefficientResult | undefined> {\n\tconst scriptUrl = extractChapterLogScriptUrl(html);\n\tif (!scriptUrl) {\n\t\tthrow new Error(\"Chapter log script URL not found\");\n\t}\n\tconst version = scriptUrl.match(/chapterlog\\.js\\?(v.*)/)?.[1] || \"\";\n\tif (version === cachedVersion) {\n\t\treturn undefined; // No need to fetch and extract again\n\t}\n\tconst scriptContent = await fetchClient.text(scriptUrl);\n\tif (!scriptContent.mimeType.includes(\"javascript\")) {\n\t\tthrow new Error(\"Fetched content is not JavaScript\");\n\t}\n\tconst coefficients = await extractCoefficients(scriptContent.data);\n\treturn {\n\t\tcoefficients,\n\t\tversion: version,\n\t};\n}\n","export function extractNovelIdFromUrl(url: string): string | undefined {\n\tconst match = url.match(/\\/novel\\/(\\d+)\\.html/);\n\treturn match ? match[1] : undefined;\n}\n\nexport interface NovelAndChapterIds {\n\tnovelId: string | undefined;\n\tchapterId: string | undefined;\n}\n\nexport function extractChapterIdFromUrl(\n\turl: string,\n): NovelAndChapterIds | undefined {\n\tconst match = url.match(/\\/novel\\/(\\d+)\\/(\\d+)\\.html/);\n\tif (match) {\n\t\treturn {\n\t\t\tnovelId: match[1],\n\t\t\tchapterId: match[2],\n\t\t};\n\t}\n\treturn undefined;\n}\n\nexport function transformChapterName(name: string): string {\n\tconst chapNameTransDict: Record<string, string> = {\n\t\t\"\\u004e\": \"\\u5973\",\n\t};\n\treturn name.replace(/./g, (char) => chapNameTransDict[char] || char);\n}\n\nexport function transformContent(content: string): string {\n\tconst contentTransDict: Record<string, string> = {\n\t\t\"\\u201c\": \"\\u300c\",\n\t\t\"\\u201d\": \"\\u300d\",\n\t\t\"\\u2018\": \"\\u300e\",\n\t\t\"\\u2019\": \"\\u300f\",\n\t\t\"\\ue82c\": \"\\u7684\",\n\t\t\"\\ue852\": \"\\u4e00\",\n\t\t\"\\ue82d\": \"\\u662f\",\n\t\t\"\\ue819\": \"\\u4e86\",\n\t\t\"\\ue856\": \"\\u6211\",\n\t\t\"\\ue857\": \"\\u4e0d\",\n\t\t\"\\ue816\": \"\\u4eba\",\n\t\t\"\\ue83c\": \"\\u5728\",\n\t\t\"\\ue830\": \"\\u4ed6\",\n\t\t\"\\ue82e\": \"\\u6709\",\n\t\t\"\\ue836\": \"\\u8fd9\",\n\t\t\"\\ue859\": \"\\u4e2a\",\n\t\t\"\\ue80a\": \"\\u4e0a\",\n\t\t\"\\ue855\": \"\\u4eec\",\n\t\t\"\\ue842\": \"\\u6765\",\n\t\t\"\\ue858\": \"\\u5230\",\n\t\t\"\\ue80b\": \"\\u65f6\",\n\t\t\"\\ue81f\": \"\\u5927\",\n\t\t\"\\ue84a\": \"\\u5730\",\n\t\t\"\\ue853\": \"\\u4e3a\",\n\t\t\"\\ue81e\": \"\\u5b50\",\n\t\t\"\\ue822\": \"\\u4e2d\",\n\t\t\"\\ue813\": \"\\u4f60\",\n\t\t\"\\ue85b\": \"\\u8bf4\",\n\t\t\"\\ue807\": \"\\u751f\",\n\t\t\"\\ue818\": \"\\u56fd\",\n\t\t\"\\ue810\": \"\\u5e74\",\n\t\t\"\\ue812\": \"\\u7740\",\n\t\t\"\\ue851\": \"\\u5c31\",\n\t\t\"\\ue801\": \"\\u90a3\",\n\t\t\"\\ue80c\": \"\\u548c\",\n\t\t\"\\ue815\": \"\\u8981\",\n\t\t\"\\ue84c\": \"\\u5979\",\n\t\t\"\\ue840\": \"\\u51fa\",\n\t\t\"\\ue848\": \"\\u4e5f\",\n\t\t\"\\ue835\": \"\\u5f97\",\n\t\t\"\\ue800\": \"\\u91cc\",\n\t\t\"\\ue826\": \"\\u540e\",\n\t\t\"\\ue863\": \"\\u81ea\",\n\t\t\"\\ue861\": \"\\u4ee5\",\n\t\t\"\\ue854\": \"\\u4f1a\",\n\t\t\"\\ue827\": \"\\u5bb6\",\n\t\t\"\\ue83b\": \"\\u53ef\",\n\t\t\"\\ue85d\": \"\\u4e0b\",\n\t\t\"\\ue84d\": \"\\u800c\",\n\t\t\"\\ue862\": \"\\u8fc7\",\n\t\t\"\\ue81c\": \"\\u5929\",\n\t\t\"\\ue81d\": \"\\u53bb\",\n\t\t\"\\ue860\": \"\\u80fd\",\n\t\t\"\\ue843\": \"\\u5bf9\",\n\t\t\"\\ue82f\": \"\\u5c0f\",\n\t\t\"\\ue802\": \"\\u591a\",\n\t\t\"\\ue831\": \"\\u7136\",\n\t\t\"\\ue84b\": \"\\u4e8e\",\n\t\t\"\\ue837\": \"\\u5fc3\",\n\t\t\"\\ue829\": \"\\u5b66\",\n\t\t\"\\ue85e\": \"\\u4e48\",\n\t\t\"\\ue83a\": \"\\u4e4b\",\n\t\t\"\\ue832\": \"\\u90fd\",\n\t\t\"\\ue808\": \"\\u597d\",\n\t\t\"\\ue841\": \"\\u770b\",\n\t\t\"\\ue821\": \"\\u8d77\",\n\t\t\"\\ue845\": \"\\u53d1\",\n\t\t\"\\ue803\": \"\\u5f53\",\n\t\t\"\\ue828\": \"\\u6ca1\",\n\t\t\"\\ue81b\": \"\\u6210\",\n\t\t\"\\ue83e\": \"\\u53ea\",\n\t\t\"\\ue820\": \"\\u5982\",\n\t\t\"\\ue84e\": \"\\u4e8b\",\n\t\t\"\\ue85a\": \"\\u628a\",\n\t\t\"\\ue806\": \"\\u8fd8\",\n\t\t\"\\ue83f\": \"\\u7528\",\n\t\t\"\\ue833\": \"\\u7b2c\",\n\t\t\"\\ue811\": \"\\u6837\",\n\t\t\"\\ue804\": \"\\u9053\",\n\t\t\"\\ue814\": \"\\u60f3\",\n\t\t\"\\ue80f\": \"\\u4f5c\",\n\t\t\"\\ue84f\": \"\\u79cd\",\n\t\t\"\\ue80e\": \"\\u5f00\",\n\t\t\"\\ue823\": \"\\u7f8e\",\n\t\t\"\\ue849\": \"\\u4e73\",\n\t\t\"\\ue805\": \"\\u9634\",\n\t\t\"\\ue809\": \"\\u6db2\",\n\t\t\"\\ue81a\": \"\\u830e\",\n\t\t\"\\ue844\": \"\\u6b32\",\n\t\t\"\\ue847\": \"\\u547b\",\n\t\t\"\\ue850\": \"\\u8089\",\n\t\t\"\\ue824\": \"\\u4ea4\",\n\t\t\"\\ue85f\": \"\\u6027\",\n\t\t\"\\ue817\": \"\\u80f8\",\n\t\t\"\\ue85c\": \"\\u79c1\",\n\t\t\"\\ue838\": \"\\u7a74\",\n\t\t\"\\ue82a\": \"\\u6deb\",\n\t\t\"\\ue83d\": \"\\u81c0\",\n\t\t\"\\ue82b\": \"\\u8214\",\n\t\t\"\\ue80d\": \"\\u5c04\",\n\t\t\"\\ue839\": \"\\u8131\",\n\t\t\"\\ue834\": \"\\u88f8\",\n\t\t\"\\ue846\": \"\\u9a9a\",\n\t\t\"\\ue825\": \"\\u5507\",\n\t};\n\treturn content.replace(/./g, (char) => contentTransDict[char] || char);\n}\n","import type { BrowserFetchClient } from \"@acanthis-dec/browser-fetch\";\nimport {\n\tbuildDescrambleMapping,\n\ttype DescrambleCoefficients,\n} from \"@acanthis-dec/core\";\nimport * as cheerio from \"cheerio\";\nimport type { AnyNode, Element } from \"domhandler\";\nimport { getCoefficientsFromPage } from \"./coefficients\";\nimport type { NovelChapterQueue } from \"./queue\";\nimport { transformContent } from \"./utils\";\n\nfunction extractChapterId($: cheerio.CheerioAPI): string {\n\tconst scriptTags = $(\"script\");\n\tlet chapterId = \"\";\n\tscriptTags.each((_, el) => {\n\t\tconst scriptContent = $(el).html();\n\t\tif (scriptContent) {\n\t\t\tconst match = scriptContent.match(/chapterid\\s*:\\s*'(\\d+)'/);\n\t\t\tif (match?.[1]) {\n\t\t\t\tchapterId = match[1];\n\t\t\t\treturn false; // Break the loop\n\t\t\t}\n\t\t}\n\t});\n\treturn chapterId;\n}\n\nexport interface DecryptResult {\n\tcontent: string;\n\tversion: string;\n\tcoefficients: DescrambleCoefficients;\n}\n\nasync function decrypt(\n\thtml: string,\n\tfetchClient: BrowserFetchClient,\n\tcachedJsVersion?: string,\n\tcachedCoefficients?: DescrambleCoefficients,\n): Promise<DecryptResult> {\n\tconst $ = cheerio.load(html);\n\tconst coefficientResult = await getCoefficientsFromPage(\n\t\thtml,\n\t\tfetchClient,\n\t\tcachedJsVersion,\n\t);\n\tconst version = coefficientResult?.version || cachedJsVersion;\n\tconst coefficients = coefficientResult?.coefficients || cachedCoefficients;\n\tif (!version) {\n\t\tthrow new Error(\"Failed to determine chapterlog.js version\");\n\t}\n\tif (!coefficients) {\n\t\tthrow new Error(\"Failed to obtain descrambling coefficients\");\n\t}\n\tconst chapterId = extractChapterId($);\n\tconst container = $(\"#TextContent, #acontent\");\n\tif (!container.length) {\n\t\treturn {\n\t\t\tcontent: \"\",\n\t\t\tversion,\n\t\t\tcoefficients: coefficients,\n\t\t};\n\t}\n\n\tcontainer.find(\"p\").each((_, el) => {\n\t\tconst $el = $(el);\n\t\tconst innerHtml = $el.html();\n\t\tif (innerHtml) {\n\t\t\tconst cleanedHtml = innerHtml.replace(/^\\s+|(?<=>)\\s+/g, \"\");\n\t\t\t$el.html(cleanedHtml);\n\t\t}\n\t});\n\n\tcontainer.find(\"img.imagecontent\").each((_, el) => {\n\t\tconst imgSrc = $(el).attr(\"data-src\") || $(el).attr(\"src\");\n\t\tif (imgSrc) {\n\t\t\t$(el).attr(\"src\", imgSrc).removeAttr(\"data-src\");\n\t\t}\n\t});\n\n\tcontainer.find(\"div.dag\").remove();\n\tcontainer.find(\"script\").remove();\n\n\tconst allChildren = container\n\t\t.contents()\n\t\t.toArray()\n\t\t.filter((node) => !(node.type === \"tag\" && node.tagName === \"div\"));\n\tconst sortableEntries: { element: Element; originalPos: number }[] = [];\n\tallChildren.forEach((node, index) => {\n\t\tif (node.type === \"tag\" && node.tagName === \"p\") {\n\t\t\tconst text = $(node).text().trim();\n\t\t\tif (text.length > 0) {\n\t\t\t\tsortableEntries.push({ element: node, originalPos: index });\n\t\t\t}\n\t\t}\n\t});\n\n\tconst seed =\n\t\tparseInt(chapterId, 10) * coefficients?.seedMultiplier +\n\t\tcoefficients?.seedOffset;\n\n\tconst mapping = buildDescrambleMapping(\n\t\tsortableEntries.length,\n\t\tseed,\n\t\tcoefficients,\n\t\t20,\n\t);\n\n\tconst restoredChildren: (AnyNode | null)[] = [...allChildren];\n\n\tsortableEntries.forEach((entry, i) => {\n\t\tconst targetIndex = mapping[i] ?? i;\n\t\tconst actualSlot = sortableEntries[targetIndex]?.originalPos ?? 0;\n\t\trestoredChildren[actualSlot] = entry.element;\n\t});\n\n\tconst newContainer = $(\"<div></div>\");\n\trestoredChildren.forEach((node) => {\n\t\tif (node && node.type === \"tag\") {\n\t\t\tnewContainer.append(node);\n\t\t\tnewContainer.append(\"\\n\");\n\t\t}\n\t});\n\n\treturn {\n\t\tcontent: newContainer.html() || \"\",\n\t\tversion,\n\t\tcoefficients: coefficients,\n\t};\n}\n\nexport async function getChapter(\n\tid: string,\n\tnovelId: string,\n\tchapterQueue: NovelChapterQueue,\n\tfetchClient: BrowserFetchClient,\n\tcachedJsVersion?: string,\n\tcachedCoefficients?: DescrambleCoefficients,\n): Promise<DecryptResult | undefined> {\n\tconst firstPageHtml = await chapterQueue.fetchChapterPart(\n\t\t`https://www.linovelib.com/novel/${novelId}/${id}.html`,\n\t);\n\tlet $ = cheerio.load(firstPageHtml);\n\tconst chapterName = $(\"h1\").text().trim();\n\tlet nextPageId =\n\t\t$(\"div.mlfy_page a:last\")\n\t\t\t.attr(\"href\")\n\t\t\t?.match(/\\/novel\\/(\\d+)\\/([\\d_]+)\\.html/)?.[2] ||\n\t\tfirstPageHtml.match(/url_next:'\\/novel\\/(\\d+)\\/([\\d_]+)\\.html'/)?.[2] ||\n\t\t\"\";\n\tlet content = await decrypt(\n\t\tfirstPageHtml,\n\t\tfetchClient,\n\t\tcachedJsVersion,\n\t\tcachedCoefficients,\n\t);\n\tcachedCoefficients = content.coefficients;\n\tcachedJsVersion = content.version;\n\twhile (nextPageId?.includes(id)) {\n\t\tconst nextPageHtml = await chapterQueue.fetchChapterPart(\n\t\t\t`https://www.linovelib.com/novel/${novelId}/${nextPageId}.html`,\n\t\t);\n\t\tconst nextContent = await decrypt(\n\t\t\tnextPageHtml,\n\t\t\tfetchClient,\n\t\t\tcachedJsVersion,\n\t\t\tcachedCoefficients,\n\t\t);\n\t\tcontent = {\n\t\t\t...content,\n\t\t\tcontent: content.content + nextContent.content,\n\t\t};\n\t\t$ = cheerio.load(nextPageHtml);\n\t\tnextPageId =\n\t\t\t$(\"div.mlfy_page a:last\")\n\t\t\t\t.attr(\"href\")\n\t\t\t\t?.match(/\\/novel\\/(\\d+)\\/([\\d_]+)\\.html/)?.[2] ||\n\t\t\tnextPageHtml.match(/url_next:'\\/novel\\/(\\d+)\\/([\\d_]+)\\.html/)?.[2] ||\n\t\t\t\"\";\n\t}\n\t// content = `<h2>${chapterName}</h2>\\n${transformContent(content)}`;\n\tcontent = {\n\t\t...content,\n\t\tcontent: `<h2>${chapterName}</h2>\\n${transformContent(content.content)}`,\n\t};\n\treturn content;\n}\n","import type {\n\tBinaryResponse,\n\tBrowserFetchClient,\n} from \"@acanthis-dec/browser-fetch\";\n\nexport function novelIdToCoverUrl(novelId: string): string {\n\tconst prefix = novelId.length > 3 ? novelId[0] : \"0\";\n\treturn `https://www.linovelib.com/files/article/image/${prefix}/${novelId}/${novelId}s.jpg`;\n}\n\nexport async function getCover(\n\tnovelId: string,\n\tfetchClient: BrowserFetchClient,\n): Promise<BinaryResponse> {\n\tconst url = novelIdToCoverUrl(novelId);\n\tconst response = await fetchClient.binary(url);\n\treturn response;\n}\n","import type {\n\tBrowserFetchClient,\n\tRetryOptions,\n} from \"@acanthis-dec/browser-fetch\";\nimport type { Chapter, Novel, NovelStatus, Volume } from \"@acanthis-dec/core\";\nimport * as cheerio from \"cheerio\";\nimport type { Element } from \"domhandler\";\nimport { novelIdToCoverUrl } from \"./cover\";\nimport type { NovelChapterQueue } from \"./queue\";\n\nfunction extractVolumesArray(catalog: string): Element[] {\n\tconst $ = cheerio.load(catalog);\n\tconst results: Element[] = [];\n\t$(\"#volume-list div.volume\").each((_, elem) => {\n\t\t$(elem).remove(\"div.volume\");\n\t\tresults.push(elem);\n\t});\n\treturn results;\n}\n\nfunction processVolumeName(novelTitle: string, volumeName: string): string {\n\t// Remove novel title from volume name if present\n\tif (volumeName.startsWith(novelTitle)) {\n\t\treturn volumeName.slice(novelTitle.length).trim();\n\t}\n\tif (!Number.isNaN(Number(volumeName))) {\n\t\treturn `第 ${volumeName} 卷`;\n\t}\n\treturn volumeName.trim();\n}\n\nfunction parseVolumeOrChapterId(url: string): string {\n\tif (url.includes(\"javascript:cid(0)\")) {\n\t\treturn \"TOBEDETERMINED\";\n\t}\n\tconst match = url.match(/\\/novel\\/\\d+\\/(\\d+|vol_\\d+)\\.html/);\n\treturn match ? (match[1] ?? \"\") : \"\";\n}\n\nasync function parseChapterIdFromNextChapter(\n\tnextChapterEl: Element,\n\tchapterQueue: NovelChapterQueue,\n): Promise<string> {\n\tconst nextChapterPath = nextChapterEl.attribs.href ?? \"\";\n\tconst nextChapterContent = await chapterQueue.fetchChapterPart(\n\t\t`https://www.linovelib.com${nextChapterPath}`,\n\t);\n\tconst $temp = cheerio.load(nextChapterContent);\n\tconst chapterPath =\n\t\t$temp(\"div.mlfy_page a:first\").attr(\"href\") ??\n\t\tnextChapterContent.match(\n\t\t\t/url_previous:'(\\/novel\\/\\d+\\/[\\d_]+\\.html)'/,\n\t\t)?.[1] ??\n\t\t\"\";\n\treturn parseVolumeOrChapterId(chapterPath);\n}\n\nasync function getNovelVolumes(\n\ttitle: string,\n\turl: string,\n\tfetchClient: BrowserFetchClient,\n\tretry: RetryOptions,\n\tchapterQueue?: NovelChapterQueue,\n): Promise<Volume[]> {\n\tconst catalogHtml = await fetchClient.text(url, { retry });\n\tconst volumeEls = extractVolumesArray(catalogHtml.data);\n\tconst volumes: Volume[] = [];\n\tconst chapterElements: Element[] = [];\n\tfor (const volumeEl of volumeEls) {\n\t\tconst volumeEl$ = cheerio.load(volumeEl);\n\t\tconst volumeName = processVolumeName(title, volumeEl$(\"h2\").text());\n\t\tconst volumeId = parseVolumeOrChapterId(\n\t\t\tvolumeEl$(\"h2 a\").attr(\"href\") ?? \"\",\n\t\t);\n\t\tconst volumeCover: string =\n\t\t\tvolumeEl$(\"a.volume-cover img\").attr(\"data-original\") ?? \"\";\n\t\tconst chapterEls = volumeEl$(\"ul.chapter-list li a\").toArray();\n\t\tconst chapters: Chapter[] = [];\n\t\tfor (const [index, chapterEl] of chapterEls.entries()) {\n\t\t\tchapterElements.push(chapterEl);\n\t\t\tconst chapterEl$ = cheerio.load(chapterEl);\n\t\t\tconst chapterName = chapterEl$.text().trim();\n\t\t\tconst chapterPath = chapterEl.attribs.href ?? \"\";\n\t\t\tlet chapterId = parseVolumeOrChapterId(chapterPath);\n\t\t\tif (chapterId === \"TOBEDETERMINED\" && chapterQueue) {\n\t\t\t\tconst nextChapterEl = chapterEls[index + 1];\n\t\t\t\tif (nextChapterEl) {\n\t\t\t\t\tchapterId = await parseChapterIdFromNextChapter(\n\t\t\t\t\t\tnextChapterEl,\n\t\t\t\t\t\tchapterQueue,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\tchapters.push({\n\t\t\t\tid: chapterId,\n\t\t\t\tplatform: \"linovelib\",\n\t\t\t\ttitle: chapterName,\n\t\t\t\tvolumeId,\n\t\t\t});\n\t\t}\n\t\tvolumes.push({\n\t\t\tid: volumeId,\n\t\t\tplatform: \"linovelib\",\n\t\t\ttitle: volumeName,\n\t\t\tcoverUrl: volumeCover,\n\t\t\tchapters: chapters,\n\t\t});\n\t}\n\treturn volumes;\n}\n\nexport async function getNovelInfo(\n\tid: string,\n\tfetchClient: BrowserFetchClient,\n\tretry: RetryOptions,\n\tchapterQueue?: NovelChapterQueue,\n): Promise<Novel | undefined> {\n\tconst url = `https://www.linovelib.com/novel/${id}.html`;\n\tconst html = (\n\t\tawait fetchClient.text(url, {\n\t\t\tretry,\n\t\t})\n\t).data;\n\tconst $ = cheerio.load(html);\n\tconst title = $(\"h1.book-name\").text().trim();\n\tconst coverUrl = $(\"div.book-img img\").attr(\"src\") || novelIdToCoverUrl(id);\n\tconst summary = (() => {\n\t\tconst $container = $(\".book-dec.Jbook-dec\").clone();\n\t\t$container.find(\".notice\").remove();\n\t\tconst paragraphs: string[] = [];\n\t\t$container\n\t\t\t.find(\"p\")\n\t\t\t.not(\".backupname\")\n\t\t\t.each((_, el) => {\n\t\t\t\tparagraphs.push($(el).text().trim());\n\t\t\t});\n\t\treturn paragraphs.join(\"\\n\");\n\t})();\n\tconst author = $(\"div.au-name a:first\").text().trim();\n\tconst status: NovelStatus = $(\"div.book-label a.state\")\n\t\t.text()\n\t\t.includes(\"完结\")\n\t\t? \"completed\"\n\t\t: \"ongoing\";\n\tconst genres = $(\"div.book-label span\")\n\t\t.children(\"a\")\n\t\t.map((_, el) => $(el).text())\n\t\t.toArray()\n\t\t.join(\",\");\n\tconst novel: Novel = {\n\t\tid,\n\t\tplatform: \"linovelib\",\n\t\ttitle,\n\t\tcoverUrl,\n\t\tsummary,\n\t\tauthor,\n\t\tstatus,\n\t\tgenres: genres.split(\",\").map((g) => g.trim()),\n\t\tvolumes: [], // Volumes and chapters will be fetched separately\n\t};\n\tnovel.volumes = (\n\t\tawait getNovelVolumes(\n\t\t\ttitle,\n\t\t\t`https://www.linovelib.com${$(\"a.read-btn\").attr(\"href\")}`,\n\t\t\tfetchClient,\n\t\t\tretry,\n\t\t\tchapterQueue,\n\t\t)\n\t).map((v) => {\n\t\tv.novelId = novel.id;\n\t\treturn v;\n\t});\n\treturn novel;\n}\n\nexport interface NovelUpdateInfo {\n\tcoverUrl: string;\n\tchapterCount: number;\n}\n\nexport async function getUpdateInfo(\n\tid: string,\n\tfetchClient: BrowserFetchClient,\n\tretry: RetryOptions,\n): Promise<NovelUpdateInfo | null> {\n\tconst url = `https://www.linovelib.com/novel/${id}.html`;\n\tconst html = (\n\t\tawait fetchClient.text(url, {\n\t\t\tretry,\n\t\t})\n\t).data;\n\tconst $ = cheerio.load(html);\n\tif ($(\"h1.book-name\").length === 0) {\n\t\treturn null;\n\t}\n\tconst catalogUrl = `https://www.linovelib.com${$(\"a.read-btn\").attr(\"href\")}`;\n\tconst catalogHtml = (\n\t\tawait fetchClient.text(catalogUrl, {\n\t\t\tretry,\n\t\t})\n\t).data;\n\tconst $catalog = cheerio.load(catalogHtml);\n\tconst chapterCount = $catalog(\n\t\t\"#volume-list div.volume ul.chapter-list li a\",\n\t).length;\n\tconst coverUrl = $(\"div.book-img img\").attr(\"src\") || novelIdToCoverUrl(id);\n\treturn {\n\t\tcoverUrl,\n\t\tchapterCount,\n\t};\n}\n","import { webcrypto } from \"node:crypto\";\nimport type { BrowserFetchClient } from \"@acanthis-dec/browser-fetch\";\nimport type { NovelSearchResult } from \"@acanthis-dec/core\";\nimport * as cheerio from \"cheerio\";\nimport { extractNovelIdFromUrl } from \"./utils\";\n\nfunction k(e: string): Uint8Array<ArrayBuffer> {\n\t// 标准 Base64 映射表\n\tconst t = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\n\n\t// 1. 过滤掉所有不在映射表中的字符 (对应原代码的正则)\n\tconst n = e.replace(/[^A-Za-z0-9+/]/g, \"\");\n\tconst r = n.length;\n\n\t// 2. 计算输出长度:每 4 个字符转为 3 个字节\n\t// 注意:原代码通常不处理末尾填充,直接通过位移计算\n\tconst buf = new Uint8Array(Math.floor(r * 0.75));\n\tlet i = 0, // buf 指针\n\t\ta = 0, // 累加器\n\t\ts = 0, // 当前位深\n\t\tc = 0; // 临时索引\n\tfor (let l = 0; l < r; l++) {\n\t\tc = t.indexOf(n[l] || \"\");\n\t\tif (c === -1) continue; // 安全检查\n\t\ta = (a << 6) | c; // 每个 Base64 字符携带 6 位信息\n\t\ts += 6;\n\t\tif (s >= 8) {\n\t\t\ts -= 8;\n\t\t\t// 提取高 8 位存入字节数组\n\t\t\tbuf[i++] = (a >> s) & 255;\n\t\t}\n\t}\n\t// 关键:必须截取到实际写入的长度\n\t// 并强制转换为 Uint8Array<ArrayBuffer>\n\treturn new Uint8Array(buf.buffer.slice(0, i)) as Uint8Array<ArrayBuffer>;\n}\n\nasync function solveSearchChallenge(\n\ta: string,\n\tb: string,\n\tc: string,\n): Promise<string> {\n\tconst subtle = webcrypto.subtle;\n\t// 使用 as Uint8Array 明确告诉 TS 这是它需要的 BufferSource\n\tconst keyData = k(a);\n\tconst counterData = k(b);\n\tconst encryptedData = k(c);\n\ttry {\n\t\tconst cryptoKey = await subtle.importKey(\n\t\t\t\"raw\",\n\t\t\tkeyData,\n\t\t\t{ name: \"AES-CTR\" },\n\t\t\tfalse,\n\t\t\t[\"decrypt\"],\n\t\t);\n\t\tconst decryptedBuffer = await subtle.decrypt(\n\t\t\t{\n\t\t\t\tname: \"AES-CTR\",\n\t\t\t\tcounter: counterData,\n\t\t\t\tlength: 64,\n\t\t\t},\n\t\t\tcryptoKey,\n\t\t\tencryptedData,\n\t\t);\n\t\t// decryptedBuffer 得到的是 ArrayBuffer,需要转回 Uint8Array 供 TextDecoder 使用\n\t\tconst decoder = new TextDecoder();\n\t\tconst plainText = decoder.decode(new Uint8Array(decryptedBuffer));\n\t\treturn encodeURIComponent(plainText);\n\t} catch (error) {\n\t\tthrow new Error(`解密失败: ${error}`);\n\t}\n}\n\nexport async function searchNovels(\n\tkeyword: string,\n\tfetchClient: BrowserFetchClient,\n): Promise<NovelSearchResult[]> {\n\tlet response = await fetchClient.text(\"https://www.linovelib.com/S6/\", {\n\t\tmethod: \"POST\",\n\t\tbody: new URLSearchParams({\n\t\t\tsearchkey: keyword,\n\t\t}),\n\t\theaders: {\n\t\t\torigin: \"https://www.linovelib.com\",\n\t\t\treferer: \"https://www.linovelib.com/\",\n\t\t},\n\t});\n\tif (response.mimeType !== \"text/html\") {\n\t\tthrow new Error(`Unexpected response type: ${response.mimeType}`);\n\t}\n\tlet $ = cheerio.load(response.data);\n\tif ($(\"#challenge-running\").length > 0) {\n\t\tlet a = \"\",\n\t\t\tb = \"\",\n\t\t\tc = \"\";\n\t\t$(\"script\").each((_, el) => {\n\t\t\tconst scriptContent = $(el).html() || \"\";\n\t\t\tif (/window\\.a\\s*=\\s*'([^']+)'/.test(scriptContent)) {\n\t\t\t\ta = scriptContent.match(/window\\.a\\s*=\\s*'([^']+)'/)?.[1] || \"\";\n\t\t\t\tb = scriptContent.match(/window\\.b\\s*=\\s*'([^']+)'/)?.[1] || \"\";\n\t\t\t\tc = scriptContent.match(/window\\.c\\s*=\\s*'([^']+)'/)?.[1] || \"\";\n\t\t\t}\n\t\t});\n\t\tconst haha = await solveSearchChallenge(a, b, c);\n\t\tawait fetchClient.setCookies([\n\t\t\t{\n\t\t\t\tdomain: \"www.linovelib.com\",\n\t\t\t\tpath: \"/\",\n\t\t\t\tname: \"haha\",\n\t\t\t\tvalue: haha,\n\t\t\t\tmaxAge: 900,\n\t\t\t},\n\t\t]);\n\t\tawait new Promise((r) => setTimeout(r, 3000));\n\t\tresponse = await fetchClient.text(\"https://www.linovelib.com/S6/\", {\n\t\t\tmethod: \"POST\",\n\t\t\tbody: new URLSearchParams({\n\t\t\t\tsearchkey: keyword,\n\t\t\t}),\n\t\t\theaders: {\n\t\t\t\treferer: \"https://www.linovelib.com/S6/\",\n\t\t\t},\n\t\t});\n\t\t$ = cheerio.load(response.data);\n\t}\n\tif ($(\"#challenge-running\").length !== 0) {\n\t\tthrow new Error(\"Failed to solve search challenge\");\n\t}\n\tif ($(\"div.book-html-box\").length > 0) {\n\t\treturn [\n\t\t\t{\n\t\t\t\ttitle: $(\"h1.book-name\").text().trim(),\n\t\t\t\tplatform: \"linovelib\",\n\t\t\t\tid:\n\t\t\t\t\textractNovelIdFromUrl($(\"meta[name=url]\").attr(\"content\") ?? \"\") ||\n\t\t\t\t\t\"\",\n\t\t\t\tcoverUrl: $(\"div.book-img img\").attr(\"src\") || \"\",\n\t\t\t},\n\t\t];\n\t}\n\tif (!response.data.includes(\"有关\")) {\n\t\tthrow new Error(\"Unexpected search result format, keyword not found\");\n\t}\n\tconst pages =\n\t\t$(\"em#pagestats\")\n\t\t\t.text()\n\t\t\t.match(/1\\/(\\d+)/)?.[1] || \"1\";\n\tconst results: NovelSearchResult[] = [];\n\t$(\"div.search-html-box div.search-result-list\").each((_, el) => {\n\t\tconst $el = $(el);\n\t\tconst title = $el.find(\"h2\").text().trim();\n\t\tconst url = $el.find(\"h2 a\").attr(\"href\") || \"\";\n\t\tconst id = extractNovelIdFromUrl(url) ?? \"\";\n\t\tconst coverUrl = $el.find(\"img\").attr(\"src\") || \"\";\n\t\tresults.push({\n\t\t\ttitle,\n\t\t\tplatform: \"linovelib\",\n\t\t\tid,\n\t\t\tcoverUrl,\n\t\t});\n\t});\n\tif (Number(pages) > 1) {\n\t\tlet currentPageHtml = response.data;\n\t\twhile (true) {\n\t\t\tconst $2 = cheerio.load(currentPageHtml);\n\t\t\tif ($2(\"a.next\").length > 0) {\n\t\t\t\tawait new Promise((r) =>\n\t\t\t\t\tsetTimeout(r, Math.random() * (1000 - 500) + 500),\n\t\t\t\t); // 避免请求过快\n\t\t\t\tcurrentPageHtml = (\n\t\t\t\t\tawait fetchClient.text(\n\t\t\t\t\t\t`https://www.linovelib.com${$2(\"a.next\").attr(\"href\")}`,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\theaders: {\n\t\t\t\t\t\t\t\thost: \"www.linovelib.com\",\n\t\t\t\t\t\t\t\treferer: \"https://www.linovelib.com/S6/\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t)\n\t\t\t\t).data;\n\t\t\t}\n\t\t\tconst $3 = cheerio.load(currentPageHtml);\n\t\t\t$3(\"div.search-html-box div.search-result-list\").each((_, el) => {\n\t\t\t\tconst $el = $3(el);\n\t\t\t\tconst title = $el.find(\"h2\").text().trim();\n\t\t\t\tconst url = $el.find(\"h2 a\").attr(\"href\") || \"\";\n\t\t\t\tconst id = extractNovelIdFromUrl(url) ?? \"\";\n\t\t\t\tconst coverUrl = $el.find(\"img\").attr(\"src\") || \"\";\n\t\t\t\tresults.push({\n\t\t\t\t\ttitle,\n\t\t\t\t\tplatform: \"linovelib\",\n\t\t\t\t\tid,\n\t\t\t\t\tcoverUrl,\n\t\t\t\t});\n\t\t\t});\n\t\t\tif ($3(\"a.next\").length === 0) break;\n\t\t}\n\t}\n\treturn results;\n}\n","import {\n\ttype BrowserFetchClient,\n\tCloudflareBlockError,\n\tdefaultRetryPolicy,\n\ttype RetryOptions,\n} from \"@acanthis-dec/browser-fetch\";\nimport type { Novel, NovelSearchResult } from \"@acanthis-dec/core\";\nimport PQueue from \"p-queue\";\nimport type { Logger } from \"winston\";\nimport { getNovelInfo, getUpdateInfo, type NovelUpdateInfo } from \"./novel\";\nimport { searchNovels } from \"./search\";\n\n/**\n * Simple backoff strategy for request rate limiting\n * - Normal delay: 500-1000ms random\n * - Failure delay: 8000ms (8 seconds)\n */\nclass SimpleBackoff {\n\treadonly NORMAL_DELAY_MIN = 500;\n\treadonly NORMAL_DELAY_MAX = 1000;\n\treadonly FAILURE_DELAY = 15000;\n\n\t/**\n\t * Get delay for normal (successful) operation\n\t * @returns Random delay in range [500, 1000]ms. If isMobile is true, returns random delay in range [2000, 5000]ms\n\t */\n\tgetDelayForSuccess(): number {\n\t\treturn (\n\t\t\tthis.NORMAL_DELAY_MIN +\n\t\t\tMath.random() * (this.NORMAL_DELAY_MAX - this.NORMAL_DELAY_MIN)\n\t\t);\n\t}\n}\n\nexport class SearchQueue {\n\tprivate queue: PQueue;\n\tprivate client: BrowserFetchClient;\n\tprivate logger?: Logger | undefined;\n\tprivate readonly COOLDOWN_MS = 5000;\n\tprivate lastSearchTime = 0;\n\n\tconstructor(client: BrowserFetchClient, logger?: Logger) {\n\t\tthis.queue = new PQueue({ concurrency: 1 });\n\t\tthis.client = client;\n\t\tthis.logger = logger;\n\t\tthis.queue.on(\"add\", () => {\n\t\t\tthis.logger?.debug(\n\t\t\t\t`[SearchQueue] 任务已添加,当前排队数: ${this.queue.size} (等待中任务数: ${this.queue.pending})`,\n\t\t\t);\n\t\t});\n\t\tthis.queue.on(\"next\", () => {\n\t\t\tthis.logger?.debug(\n\t\t\t\t`[SearchQueue] 任务完成或超时,开始下一个任务。剩余:${this.queue.size} `,\n\t\t\t);\n\t\t});\n\t}\n\n\tprivate async _sleep(ms: number) {\n\t\treturn new Promise((resolve) => setTimeout(resolve, ms));\n\t}\n\n\tasync searchNovels(keyword: string): Promise<NovelSearchResult[]> {\n\t\treturn await this.queue.add(async () => {\n\t\t\tif (Date.now() - this.lastSearchTime < this.COOLDOWN_MS) {\n\t\t\t\tconst waitTime = this.COOLDOWN_MS - (Date.now() - this.lastSearchTime);\n\t\t\t\tthis.logger?.debug(\n\t\t\t\t\t`[SearchQueue] 搜索请求过快,等待 ${waitTime}ms 后重试`,\n\t\t\t\t);\n\t\t\t\tawait this._sleep(waitTime);\n\t\t\t}\n\t\t\tthis.logger?.debug(`[SearchQueue] 开始搜索关键词 \"${keyword}\"`);\n\t\t\tconst results = await searchNovels(keyword, this.client);\n\t\t\tthis.logger?.debug(\n\t\t\t\t`[SearchQueue] 搜索完成,关键词 \"${keyword}\" 共找到 ${results.length} 条结果`,\n\t\t\t);\n\t\t\tthis.lastSearchTime = Date.now();\n\t\t\treturn results;\n\t\t});\n\t}\n}\n\nexport class NovelChapterQueue {\n\tprivate queue: PQueue;\n\tprivate client: BrowserFetchClient;\n\tprivate backoff: SimpleBackoff;\n\tprivate logger?: Logger | undefined;\n\tprivate lastFetchTime = 0;\n\n\tconstructor(client: BrowserFetchClient, logger?: Logger) {\n\t\tthis.queue = new PQueue({ concurrency: 1 });\n\t\tthis.client = client;\n\t\tthis.backoff = new SimpleBackoff();\n\t\tthis.logger = logger;\n\t\tthis.queue.on(\"add\", () => {\n\t\t\tthis.logger?.debug(\n\t\t\t\t`[NovelChapterQueue] 任务已添加,当前排队数: ${this.queue.size} (等待中任务数: ${this.queue.pending})`,\n\t\t\t);\n\t\t});\n\t\tthis.queue.on(\"next\", () => {\n\t\t\tthis.logger?.debug(\n\t\t\t\t`[NovelChapterQueue] 任务完成或超时,开始下一个任务。剩余:${this.queue.size} `,\n\t\t\t);\n\t\t});\n\t}\n\n\tprivate async _sleep(ms: number) {\n\t\treturn new Promise((resolve) => setTimeout(resolve, ms));\n\t}\n\n\tasync fetchChapterPart(url: string): Promise<string> {\n\t\treturn await this.queue.add(async () => {\n\t\t\tconst delay = this.backoff.getDelayForSuccess();\n\t\t\tif (Date.now() - this.lastFetchTime < delay) {\n\t\t\t\tconst waitTime = delay - (Date.now() - this.lastFetchTime);\n\t\t\t\tthis.logger?.debug(`[NovelChapterQueue] 请求过快,等待 ${waitTime}ms`);\n\t\t\t\tawait this._sleep(waitTime);\n\t\t\t}\n\t\t\tconst match = url.match(/\\/novel\\/(\\d+)\\/(\\d+)(?:_(\\d+))?\\.html/);\n\t\t\tif (!match) {\n\t\t\t\tthrow new Error(`Invalid chapter URL: ${url}`);\n\t\t\t}\n\t\t\tconst novelId = match[1];\n\t\t\tconst chapterId = match[2];\n\t\t\tconst partId = match[3] || \"1\";\n\t\t\tthis.logger?.debug(\n\t\t\t\t`[NovelChapterQueue] 开始获取小说${novelId}章节${chapterId}的第${partId}部分内容`,\n\t\t\t);\n\n\t\t\tconst retry: RetryOptions = {\n\t\t\t\tretries: 10,\n\t\t\t\tfactor: 2,\n\t\t\t\tminRetryDelayMs: 0,\n\t\t\t\tmaxRetryDelayMs: 0,\n\t\t\t\trandomize: false,\n\t\t\t\tonFailedAttempt: async (ctx) => {\n\t\t\t\t\tif (ctx.error instanceof CloudflareBlockError) {\n\t\t\t\t\t\tthis.logger?.warn(\n\t\t\t\t\t\t\t`[NovelChapterQueue] 请求被 Cloudflare 阻挡,错误信息: ${ctx.error.message}。正在等待 ${this.backoff.FAILURE_DELAY / 1000}s 后重试...`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tawait this._sleep(this.backoff.FAILURE_DELAY);\n\t\t\t\t\t}\n\t\t\t\t\tif (ctx.attemptNumber >= (retry.retries ?? 3)) {\n\t\t\t\t\t\tthis.logger?.error(\n\t\t\t\t\t\t\t`[NovelChapterQueue] 请求重试次数已达上限 (${ctx.attemptNumber} 次),错误信息: ${ctx.error.message}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tshouldRetry: async (ctx) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\tdefaultRetryPolicy(ctx) || ctx.error instanceof CloudflareBlockError\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tconst content = (await this.client.text(url, { retry })).data ?? \"\";\n\t\t\tthis.lastFetchTime = Date.now();\n\t\t\tthis.logger?.debug(\n\t\t\t\t`[NovelChapterQueue] 小说${novelId}-章节${chapterId}_${partId} 获取成功。`,\n\t\t\t);\n\t\t\treturn content;\n\t\t});\n\t}\n}\n\nexport class NovelInfoQueue {\n\tprivate queue: PQueue;\n\tprivate client: BrowserFetchClient;\n\tprivate backoff: SimpleBackoff;\n\tprivate chapterQueue: NovelChapterQueue;\n\tprivate logger?: Logger | undefined;\n\tprivate lastFetchTime = 0;\n\n\tconstructor(\n\t\tclient: BrowserFetchClient,\n\t\tchapterQueue: NovelChapterQueue,\n\t\tlogger?: Logger,\n\t) {\n\t\tthis.queue = new PQueue({ concurrency: 1 });\n\t\tthis.client = client;\n\t\tthis.backoff = new SimpleBackoff();\n\t\tthis.chapterQueue = chapterQueue;\n\t\tthis.logger = logger;\n\t\tthis.queue.on(\"add\", () => {\n\t\t\tthis.logger?.debug(\n\t\t\t\t`[NovelInfoQueue] 任务已添加,当前排队数: ${this.queue.size} (等待中任务数: ${this.queue.pending})`,\n\t\t\t);\n\t\t});\n\t\tthis.queue.on(\"next\", () => {\n\t\t\tthis.logger?.debug(\n\t\t\t\t`[NovelInfoQueue] 任务完成或超时,开始下一个任务。剩余:${this.queue.size} `,\n\t\t\t);\n\t\t});\n\t}\n\n\tprivate async _sleep(ms: number) {\n\t\treturn new Promise((resolve) => setTimeout(resolve, ms));\n\t}\n\n\tasync fetchNovelInfo(id: string): Promise<Novel> {\n\t\treturn await this.queue.add(async () => {\n\t\t\tconst delay = this.backoff.getDelayForSuccess();\n\t\t\tif (Date.now() - this.lastFetchTime < delay) {\n\t\t\t\tconst waitTime = delay - (Date.now() - this.lastFetchTime);\n\t\t\t\tthis.logger?.debug(`[NovelInfoQueue] 请求过快,等待 ${waitTime}ms`);\n\t\t\t\tawait this._sleep(waitTime);\n\t\t\t}\n\t\t\tthis.logger?.debug(`[NovelInfoQueue] 开始获取小说${id}的信息`);\n\t\t\tconst retry: RetryOptions = {\n\t\t\t\tretries: 10,\n\t\t\t\tfactor: 2,\n\t\t\t\tminRetryDelayMs: 0,\n\t\t\t\tmaxRetryDelayMs: 0,\n\t\t\t\trandomize: false,\n\t\t\t\tonFailedAttempt: async (ctx) => {\n\t\t\t\t\tif (ctx.error instanceof CloudflareBlockError) {\n\t\t\t\t\t\tthis.logger?.warn(\n\t\t\t\t\t\t\t`[NovelInfoQueue] 请求被 Cloudflare 阻挡,错误信息: ${ctx.error.message}。正在等待 ${this.backoff.FAILURE_DELAY / 1000}s 后重试...`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tawait this._sleep(this.backoff.FAILURE_DELAY);\n\t\t\t\t\t}\n\t\t\t\t\tif (ctx.attemptNumber >= (retry.retries ?? 3)) {\n\t\t\t\t\t\tthis.logger?.error(\n\t\t\t\t\t\t\t`[NovelInfoQueue] 请求重试次数已达上限 (${ctx.attemptNumber} 次),错误信息: ${ctx.error.message}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tshouldRetry: async (ctx) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\tdefaultRetryPolicy(ctx) || ctx.error instanceof CloudflareBlockError\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tconst novel = await getNovelInfo(\n\t\t\t\tid,\n\t\t\t\tthis.client,\n\t\t\t\tretry,\n\t\t\t\tthis.chapterQueue,\n\t\t\t);\n\t\t\tif (!novel) {\n\t\t\t\tthrow new Error(`无法获取小说信息: ${id}`);\n\t\t\t}\n\t\t\tthis.logger?.debug(`[NovelInfoQueue] 小说${id} 信息获取成功。`);\n\t\t\tthis.lastFetchTime = Date.now();\n\t\t\treturn novel;\n\t\t});\n\t}\n\n\tasync fetchNovelUpdateInfo(id: string): Promise<NovelUpdateInfo | null> {\n\t\treturn await this.queue.add(async () => {\n\t\t\tconst delay = this.backoff.getDelayForSuccess();\n\t\t\tif (Date.now() - this.lastFetchTime < delay) {\n\t\t\t\tconst waitTime = delay - (Date.now() - this.lastFetchTime);\n\t\t\t\tthis.logger?.debug(`[NovelInfoQueue] 请求过快,等待 ${waitTime}ms`);\n\t\t\t\tawait this._sleep(waitTime);\n\t\t\t}\n\t\t\tthis.logger?.debug(\n\t\t\t\t`[NovelInfoQueue] 开始获取小说${id}的更新信息(封面和章节数)`,\n\t\t\t);\n\t\t\tconst retry: RetryOptions = {\n\t\t\t\tretries: 10,\n\t\t\t\tfactor: 2,\n\t\t\t\tminRetryDelayMs: 0,\n\t\t\t\tmaxRetryDelayMs: 0,\n\t\t\t\trandomize: false,\n\t\t\t\tonFailedAttempt: async (ctx) => {\n\t\t\t\t\tif (ctx.error instanceof CloudflareBlockError) {\n\t\t\t\t\t\tthis.logger?.warn(\n\t\t\t\t\t\t\t`[NovelInfoQueue] 请求被 Cloudflare 阻挡,错误信息: ${ctx.error.message}。正在等待 ${this.backoff.FAILURE_DELAY / 1000}s 后重试...`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tawait this._sleep(this.backoff.FAILURE_DELAY);\n\t\t\t\t\t}\n\t\t\t\t\tif (ctx.attemptNumber >= (retry.retries ?? 3)) {\n\t\t\t\t\t\tthis.logger?.error(\n\t\t\t\t\t\t\t`[NovelInfoQueue] 请求重试次数已达上限 (${ctx.attemptNumber} 次),错误信息: ${ctx.error.message}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tshouldRetry: async (ctx) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\tdefaultRetryPolicy(ctx) || ctx.error instanceof CloudflareBlockError\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tconst updateInfo = await getUpdateInfo(id, this.client, retry);\n\t\t\tif (!updateInfo) {\n\t\t\t\tthis.logger?.warn(\n\t\t\t\t\t`[NovelInfoQueue] 无法获取小说${id}的更新信息,可能是因为小说不存在或已被删除`,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tthis.logger?.debug(\n\t\t\t\t\t`[NovelInfoQueue] 小说${id} 更新信息获取成功。 封面: ${updateInfo.coverUrl}, 章节数: ${updateInfo.chapterCount}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthis.lastFetchTime = Date.now();\n\t\t\treturn updateInfo;\n\t\t});\n\t}\n}\n","import type { BrowserFetchClient } from \"@acanthis-dec/browser-fetch\";\n\nexport interface LoginConfig {\n\tusername: string;\n\tpassword: string;\n}\n\nexport async function refreshSessionId(\n\tfetchClient: BrowserFetchClient,\n\tloginConfig: LoginConfig,\n): Promise<boolean> {\n\tawait fetchClient.request({\n\t\turl: \"https://www.linovelib.com/login.php\",\n\t\tmethod: \"GET\",\n\t\theaders: {\n\t\t\treferer: \"https://www.linovelib.com/\",\n\t\t},\n\t});\n\tconst response = await fetchClient.request({\n\t\turl: \"https://www.linovelib.com/login.php?do=submit&jumpurl=https%3A%2F%2Fwww.linovelib.com%2F\",\n\t\tmethod: \"POST\",\n\t\tbody: new URLSearchParams({\n\t\t\tusername: loginConfig.username,\n\t\t\tpassword: loginConfig.password,\n\t\t\tusecookie: \"3153600000\",\n\t\t\tsubmit: \"登录\",\n\t\t\taction: \"login\",\n\t\t}),\n\t\tfollowRedirects: false,\n\t});\n\treturn (\n\t\tresponse.cookies.findIndex((cookie) => cookie.name === \"PHPSESSID\") !== -1\n\t);\n}\n\nexport async function hasValidSession(\n\tfetchClient: BrowserFetchClient,\n): Promise<boolean> {\n\tconst response = await fetchClient.text(\"https://www.linovelib.com\");\n\tif (response.data.includes(\"用户中心\")) return true;\n\telse return false;\n}\n\nexport async function ensureValidSession(\n\tfetchClient: BrowserFetchClient,\n\tloginConfig: LoginConfig,\n): Promise<boolean> {\n\tif (!(await hasValidSession(fetchClient))) {\n\t\tconst isValid =\n\t\t\t(await refreshSessionId(fetchClient, loginConfig)) &&\n\t\t\t(await hasValidSession(fetchClient));\n\t\tif (!isValid) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n","import {\n\ttype BinaryResponse,\n\tBrowserFetchClient,\n\ttype BrowserFetchClientOptions,\n\ttype BrowserProfileName,\n\ttype FlareSolverrOptions,\n} from \"@acanthis-dec/browser-fetch\";\nimport type {\n\tDescrambleCoefficients,\n\tNovel,\n\tNovelSearchResult,\n} from \"@acanthis-dec/core\";\nimport type { StorageService } from \"@acanthis-dec/storage\";\nimport { deepmerge } from \"deepmerge-ts\";\nimport type { Logger } from \"winston\";\nimport z from \"zod\";\nimport { getChapter } from \"./chapter\";\nimport { descrambleCoefficientsSchema } from \"./coefficients\";\nimport { getCover } from \"./cover\";\nimport type { NovelUpdateInfo } from \"./novel\";\nimport { NovelChapterQueue, NovelInfoQueue, SearchQueue } from \"./queue\";\nimport { ensureValidSession } from \"./session\";\n\nexport type SessionOptions =\n\t| {\n\t\t\tenabled: false;\n\t }\n\t| {\n\t\t\tenabled: true;\n\t\t\tusername: string;\n\t\t\tpassword: string;\n\t };\n\nexport type ImpersonateOptions =\n\t| {\n\t\t\tenabled: true;\n\t\t\tprofile: BrowserProfileName;\n\t }\n\t| {\n\t\t\tenabled: false;\n\t };\n\nexport type CookieStoreOptions =\n\t| {\n\t\t\ttype: \"memory\" | \"database\";\n\t }\n\t| {\n\t\t\ttype: \"file\";\n\t\t\tpath: string;\n\t };\n\nexport type LinovelibClientOptions = {\n\tsession: SessionOptions;\n\tflareSolverr: FlareSolverrOptions;\n\timpersonate: ImpersonateOptions;\n\tcookies: CookieStoreOptions;\n\tproxy?: string | undefined;\n};\n\nexport class LinovelibClient {\n\tprivate storage?: StorageService | undefined;\n\tprivate fetchClient: BrowserFetchClient;\n\tprivate novelChapterQueue: NovelChapterQueue;\n\tprivate novelInfoQueue: NovelInfoQueue;\n\tprivate searchQueue: SearchQueue;\n\tprivate options?: LinovelibClientOptions;\n\tprivate logger?: Logger | undefined;\n\tprivate isSessionValid?: boolean = undefined;\n\n\tconstructor(\n\t\toptions?: LinovelibClientOptions,\n\t\tstorage?: StorageService,\n\t\tlogger?: Logger,\n\t) {\n\t\tconst defaultOptions: LinovelibClientOptions = {\n\t\t\tsession: {\n\t\t\t\tenabled: false,\n\t\t\t},\n\t\t\tflareSolverr: {\n\t\t\t\tenabled: true,\n\t\t\t\thost: \"http://localhost:8191\",\n\t\t\t\ttimeoutMs: 60000,\n\t\t\t\tsessionId: \"acanthis-linovelib-client\",\n\t\t\t},\n\t\t\timpersonate: {\n\t\t\t\tenabled: true,\n\t\t\t\tprofile: \"chrome149-linux\",\n\t\t\t},\n\t\t\tcookies: {\n\t\t\t\ttype: \"memory\",\n\t\t\t},\n\t\t};\n\t\tthis.options = deepmerge(\n\t\t\tdefaultOptions,\n\t\t\toptions ?? {},\n\t\t) as LinovelibClientOptions;\n\t\tthis.storage = storage;\n\t\tthis.logger = logger;\n\t\tconst browserFetchOptions: BrowserFetchClientOptions = {};\n\t\tif (this.options?.flareSolverr.enabled) {\n\t\t\tbrowserFetchOptions.flareSolverr = {\n\t\t\t\tenabled: true,\n\t\t\t\thost: this.options.flareSolverr.host,\n\t\t\t\ttimeoutMs: this.options.flareSolverr.timeoutMs ?? 60000,\n\t\t\t\tsessionId:\n\t\t\t\t\tthis.options.flareSolverr.sessionId ?? \"acanthis-linovelib-client\",\n\t\t\t};\n\t\t} else {\n\t\t\tbrowserFetchOptions.flareSolverr = {\n\t\t\t\tenabled: false,\n\t\t\t};\n\t\t}\n\t\tif (this.options?.proxy) {\n\t\t\tbrowserFetchOptions.proxy = this.options.proxy;\n\t\t}\n\t\tif (this.options?.impersonate.enabled) {\n\t\t\tbrowserFetchOptions.profile = this.options.impersonate.profile;\n\t\t}\n\t\tswitch (this.options?.cookies.type) {\n\t\t\tcase \"memory\":\n\t\t\t\tbrowserFetchOptions.cookieStore = {\n\t\t\t\t\ttype: \"memory\",\n\t\t\t\t};\n\t\t\t\tbreak;\n\t\t\tcase \"file\":\n\t\t\t\tbrowserFetchOptions.cookieStore = {\n\t\t\t\t\ttype: \"file\",\n\t\t\t\t\tpath: this.options.cookies.path,\n\t\t\t\t};\n\t\t\t\tbreak;\n\t\t\tcase \"database\":\n\t\t\t\tif (!this.storage) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\"StorageService is required for database cookie store\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbrowserFetchOptions.cookieStore = {\n\t\t\t\t\ttype: \"custom\",\n\t\t\t\t\tstore: this.storage.getCookieStore(),\n\t\t\t\t};\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tbrowserFetchOptions.cookieStore = {\n\t\t\t\t\ttype: \"memory\",\n\t\t\t\t};\n\t\t}\n\t\tthis.fetchClient = new BrowserFetchClient(browserFetchOptions);\n\t\tthis.novelChapterQueue = new NovelChapterQueue(\n\t\t\tthis.fetchClient,\n\t\t\tthis.logger,\n\t\t);\n\t\tthis.novelInfoQueue = new NovelInfoQueue(\n\t\t\tthis.fetchClient,\n\t\t\tthis.novelChapterQueue,\n\t\t\tthis.logger,\n\t\t);\n\t\tthis.searchQueue = new SearchQueue(this.fetchClient, this.logger);\n\t}\n\n\tasync getNovelInfo(id: string): Promise<Novel | undefined> {\n\t\tif (this.options?.session.enabled && !this.isSessionValid) {\n\t\t\tthis.isSessionValid = await ensureValidSession(this.fetchClient, {\n\t\t\t\tusername: this.options.session.username,\n\t\t\t\tpassword: this.options.session.password,\n\t\t\t});\n\t\t}\n\t\treturn await this.novelInfoQueue.fetchNovelInfo(id);\n\t}\n\n\tasync getNovelUpdateInfo(id: string): Promise<NovelUpdateInfo | null> {\n\t\tif (this.options?.session.enabled && !this.isSessionValid) {\n\t\t\tthis.isSessionValid = await ensureValidSession(this.fetchClient, {\n\t\t\t\tusername: this.options.session.username,\n\t\t\t\tpassword: this.options.session.password,\n\t\t\t});\n\t\t}\n\t\treturn await this.novelInfoQueue.fetchNovelUpdateInfo(id);\n\t}\n\n\tasync searchNovels(keyword: string): Promise<NovelSearchResult[]> {\n\t\tif (this.options?.session.enabled && !this.isSessionValid) {\n\t\t\tthis.isSessionValid = await ensureValidSession(this.fetchClient, {\n\t\t\t\tusername: this.options.session.username,\n\t\t\t\tpassword: this.options.session.password,\n\t\t\t});\n\t\t}\n\t\treturn await this.searchQueue.searchNovels(keyword);\n\t}\n\n\tasync getNovelCover(novelId: string) {\n\t\treturn await getCover(novelId, this.fetchClient);\n\t}\n\n\tasync getCover(url: string): Promise<BinaryResponse> {\n\t\treturn await this.fetchClient.binary(url, {\n\t\t\theaders: {\n\t\t\t\tReferer: \"https://www.linovelib.com/\",\n\t\t\t},\n\t\t});\n\t}\n\n\tasync getChapter(\n\t\tnovelId: string,\n\t\tchapterId: string,\n\t): Promise<string | undefined> {\n\t\tif (this.options?.session.enabled && !this.isSessionValid) {\n\t\t\tthis.isSessionValid = await ensureValidSession(this.fetchClient, {\n\t\t\t\tusername: this.options.session.username,\n\t\t\t\tpassword: this.options.session.password,\n\t\t\t});\n\t\t}\n\t\tconst cachedJsVersion = this.storage\n\t\t\t? ((await this.storage.getCache(\"chapterlog_js_version\", z.string())) ??\n\t\t\t\tundefined)\n\t\t\t: undefined;\n\t\tconst cachedCoefficients = this.storage\n\t\t\t? ((await this.storage.getCache<DescrambleCoefficients>(\n\t\t\t\t\t\"coefficients\",\n\t\t\t\t\tdescrambleCoefficientsSchema,\n\t\t\t\t)) ?? undefined)\n\t\t\t: undefined;\n\t\tconst result = await getChapter(\n\t\t\tchapterId,\n\t\t\tnovelId,\n\t\t\tthis.novelChapterQueue,\n\t\t\tthis.fetchClient,\n\t\t\tcachedJsVersion,\n\t\t\tcachedCoefficients,\n\t\t);\n\t\tif (this.storage && result) {\n\t\t\tawait this.storage.setCache(\"chapterlog_js_version\", result.version);\n\t\t\tawait this.storage.setCache(\"coefficients\", result.coefficients);\n\t\t}\n\t\treturn result?.content;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;AAWA,MAAM,WACJ,eAA6D,WAC9D;AAED,MAAa,+BAA+B,EAAE,OAAO;CACpD,SAAS,EAAE,OAAO,CAAC,CAAC,IAAI;CACxB,WAAW,EAAE,OAAO,CAAC,CAAC,IAAI;CAC1B,YAAY,EAAE,OAAO,CAAC,CAAC,IAAI;CAC3B,YAAY,EAAE,OAAO,CAAC,CAAC,IAAI;CAC3B,gBAAgB,EAAE,OAAO,CAAC,CAAC,IAAI;AAChC,CAA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9C,OAAO,QAAQ,MAAM,KAAK,KAAA;AAC3B;AA2BA,SAAgB,iBAAiB,SAAyB;CACzD,MAAM,mBAA2C;EAChD,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;EACV,KAAU;CACX;CACA,OA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GAChE,UAAU,KAAK,QAAQ,QAAQ;GAC/B,UAAU,KAAK,QAAQ,QAAQ;EAChC,CAAC;EAEF,MAAM,kBAAkB,KAAK,UACxB,MAAM,KAAK,QAAQ,SAAS,yBAAyBA,IAAE,OAAO,CAAC,KAClE,KAAA,IACC,KAAA;EACH,MAAM,qBAAqB,KAAK,UAC3B,MAAM,KAAK,QAAQ,SACrB,gBACA,4BACD,KAAM,KAAA,IACL,KAAA;EACH,MAAM,SAAS,MAAM,WACpB,WACA,SACA,KAAK,mBACL,KAAK,aACL,iBACA,kBACD;EACA,IAAI,KAAK,WAAW,QAAQ;GAC3B,MAAM,KAAK,QAAQ,SAAS,yBAAyB,OAAO,OAAO;GACnE,MAAM,KAAK,QAAQ,SAAS,gBAAgB,OAAO,YAAY;EAChE;EACA,OAAO,QAAQ;CAChB;AACD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@acanthis-dec/linovelib",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "An Acanthis adapter for Linovelib site.",
5
5
  "author": "ConstasJ <constasj@qq.com>",
6
6
  "license": "MIT",
@@ -34,10 +34,10 @@
34
34
  "p-queue": "^9.3.0",
35
35
  "zod": "^4.4.3",
36
36
  "winston": "^3.19.0",
37
- "@acanthis-dec/deobfuscator": "1.0.0",
38
- "@acanthis-dec/browser-fetch": "1.0.0",
39
- "@acanthis-dec/storage": "1.0.0",
40
- "@acanthis-dec/core": "1.0.0"
37
+ "@acanthis-dec/browser-fetch": "1.0.1",
38
+ "@acanthis-dec/core": "1.0.1",
39
+ "@acanthis-dec/deobfuscator": "1.0.1",
40
+ "@acanthis-dec/storage": "1.0.1"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@types/babel__traverse": "^7.28.0",
@@ -52,5 +52,6 @@
52
52
  "scripts": {
53
53
  "build": "tsdown",
54
54
  "check-types": "tsc --noEmit"
55
- }
55
+ },
56
+ "types": "./src/index.d.mts"
56
57
  }