Greasy Fork is available in English.

小说下载器

一个可扩展的通用型小说下载器。

< Feedback on 小说下载器

Review: Good - script works

§
Posted: 15.05.2021

请问可以把章节标题变成“第xx章 xxxx”的形式吗?或者增加一个自定义章节格式的功能?

bgmeAuthor
§
Posted: 15.05.2021

现在的章节标题是直接采用原文标题,尽量保证为原章节标题。

不太理解什么意思,可以具体举例说明一下吗?

bgmeAuthor
§
Posted: 15.05.2021

如果需要在保存前对章节标题进行修改,可以在 save 函数中进行一些修改。

§
Posted: 18.05.2021

如果需要在保存前对章节标题进行修改,可以在 save 函数中进行一些修改。

比如图上这样,插件默认的标题格式都是##+标题名的格式,没有章节数

如果可以的话,希望在标题里能够增加章节数这个参数
因为大部分阅读软件都是特定按关键词识别章节的,##这种形式很难定位章节。本来想手动改一下,但是发现文本编辑的软件里很难找到有递增替换功能的,如果可以,希望能进行一下这方面的优化,不胜感激OTZ

bgmeAuthor
§
Posted: 20.05.2021

如果需要实现图二的效果,打上如下patch即可。

diff --git a/src/index_helper.ts b/src/index_helper.ts
index 799c8c3..c9c7981 100644
--- a/src/index_helper.ts
+++ b/src/index_helper.ts
@@ -202,7 +202,7 @@ a.disabled {

       if (chapter.contentText) {
         const chapterText = this.genChapterText(
-          chapterName,
+          `第${chapter.chapterNumber}章 ` + chapterName,
           chapter.contentText
         );
         this.savedTextArray.push(chapterText);
@@ -468,7 +468,7 @@ a.disabled {
   }

   private genChapterText(chapterName: string, contentText: string) {
-    return `## ${chapterName}\n\n${contentText}\n\n`;
+    return `${chapterName}\n\n${contentText}\n\n`;
   }

   private genSectionHtmlFile(sectionName: string) {  

具体操作为下:

  1. 将上述内容保存为 patch.txt 文件。
  2. git clone https://github.com/yingziwu/novel-downloader.git 本地创建项目。
  3. git apply patch.txt 应用补丁。
  4. npm install && npm run build 编译生成新脚本文件(需安装node.js及npm)。
  5. dist/bundle.user.js 即为修改后的新脚本。

这个需求好像比较小众,所以就不在主线里修改了。

bgmeAuthor
§
Posted: 23.05.2021

添加了自定义保存参数,具体内容参见脚本说明。

你可以F12打开Console,在Console中运行如下代码:

const saveOptions = {
    getchapterName: (chapter) => {
        if (chapter.chapterName) {
            return `第${chapter.chapterNumber.toString()}章 ${chapter.chapterName}`;
        } else {
            return `第${chapter.chapterNumber.toString()}章`;
        }
    }
}
window.saveOptions = saveOptions

如果你想在某一站点总是运行该代码,可使用如下用户脚本进行自运注入:

// ==UserScript==
// @name         auto inject saveOptions
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  auto inject saveOptions
// @author       You
// @match        *://*/*
// @grant        unsafeWindow
// ==/UserScript==

(function() {
    'use strict';

    const saveOptions = {
        getchapterName: (chapter) => {
            if (chapter.chapterName) {
                return `第${chapter.chapterNumber.toString()}章 ${chapter.chapterName}`;
            } else {
                return `第${chapter.chapterNumber.toString()}章`;
            }
        }
    }
    unsafeWindow.saveOptions = saveOptions
})();

自定义筛选函数同理也可自运注入。

Post reply

Sign in to post a reply.