TamperMonkey油猴/暴力猴浏览器脚本插件中文网(原TMchina)

打印 上一主题 下一主题

[辅助] 油猴脚本暴力猴脚本:将小说用浏览器下载到电脑

[复制链接]
跳转到指定楼层
楼主
发表于 2022-5-22 11:32:24 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多网友,浏览器插件/脚本不再愁!

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
一个可扩展的通用型小说下载器,方便保存这些质量上乘,但不够热门,没有被其他网站转载,彻底从互联网上消失的作品。



本脚本为404小说文库项目的组成部分之一,对于无登录墙的小说网站,如您同意,本脚本将会尝试将当前书籍详情页及目录页(如果存在)存档至互联网档案馆(archive.org),以备日后(被删除后)查看。

存档过程中将会搜集并上报您如下信息:IP地址、User-Agent、Referer、当前书籍详情页URL、当前书籍目录页URL(如果存在)、当前小说下载器脚本版本、当前脚本管理器版本。除上述信息外,不会搜集您任何其他信息。

安装
本软件为油猴脚本,需先在浏览器安装油猴脚本管理器(Tampermonkey)或暴力猴,再安装本脚本。具体可参见本站主菜单栏的信息。

使用方法
本脚本执行下载任务时将播放无声音频,以保证脚本后台运行时不被休眠。

如果本脚本支持该小说网站,当打开小说目录页时,网页右上角会出现下载图标,点击该图标即可开始下载。

如果你要下载的小说章节较多,等待时间可能较长,此时请耐心等待。

你通过右下角进度条了解当前下载进度,或者按下 F12,打开网页控制台查看当前下载状态。

下载完成后,本脚本将会自动下载一个TXT文档及EPUB文件。

TXT文档请使用记事本或其它阅读软件进行阅读。

EPUB文件请使用相应阅读器阅读。

目前支持小说网站
特别提醒:如欲下载支持列表中网站的付费章节,请登录相应网站帐户,并确定已购买相应付费章节。未登录网站帐户,或未购买的付费章节,下载时将直接忽略,无法进行下载。

  1. yruan.com,shuquge.com,hetushu.com,xkzw.org,qidian.com,ciweimao.com,sfacg.com,gebiqu.com,uukanshu.com,dingdiann.net,266ks.com,shouda88.com,viviyzw.com,jjwxc.net,zongheng.com,17k.com,shuhai.com,81book.com,lewenn.com,gongzicp.com,linovel.net,tadu.com,qimao.com,xinwanben.com,idejian.com,wenku8.net,dmzj.com,sosad.funwenzhan.org,sosadfun.com,xn--pxtr7m5ny.com,xn--pxtr7m.com,xn--pxtr7m5ny.net,xn--pxtr7m.net,sosadfun.linkwestnovel.com,xbiquge.solinovelib.com,luoqiuzw.com,fushuwang.org,soxscc,.net,soxscc,.org,soxs.cc,sizhicn,.com,1pwx.com,shubaowa.org,fuguoduxs.com,630shu.net,trxs.cc,trxs123.com,tongrenquan.org,jpxs123.com,imiaobige.com,soshuw.com,biquge66.com,lofter.com,tongrenquan.melwxs9.org,shubl.com,yushuge123.com,soshuwu.org,haitangtxt.net,banzhuer.org,longmabook.com,longmabookcn,.com,lmbooks.com,lmebooks.com,haitbook.com,htwhbook.com,myhtebook.com,lovehtbooks.com,myhtebooks.com,myhtlmebook.com,urhtbooks.com,newhtbook.com,lvhtebook.com,htlvbooks.com,81zw.com,soxscc,.cc,soshuwu.com,dijiubook.net,mht99.com,256wenku.com,kubiji.net,25zw.com,bz01.org,yibige.cc,kanunu8.com,ciyuanji.com,wanben.org,ranwen.labaihexs.com,quanshuzhai.com,masiro.mepixiv.net,kakuyomu.jpsyosetu.com,zhaoze.artmyrics.com,lusetxt.com,a7xs.com,shencou.com,tianyabooks.com,lstxt.cc,aixiawx.com,jingcaiyuedu6.com,hanwujinian.com,syosetu.org,bilibili.com,aixdzs.com,liuxs.lacool18.com,b5200.net,dushu369.com,18kanshu.com,xiaoshuowu.com,xrzww.com,colorful-fantasybooks.com,hongyeshuzhal.com,xbiquwx.lazmcc,x.com,wangshuge.com,biqu55.net,xsyq.cc,bxwx888.org,dizishu.com,yqbiqu.com,xbiquge.laakatsuki-novels.com,alphapolis.co.jpnovelup.plusimbg.cc,69shu.com,houhuayuan.vipreadmoo.com
复制代码


高阶使用技巧
启用调试功能
设置菜单中按击开启。

自定义筛选函数
如欲只下载部分章节,请在点击运行按钮前,按下 F12 打开开发者工具,在 window 下创建 chapterFilter 函数,具体格式如下:

  1. declare enum Status {
  2.     pending = 0,
  3.     downloading = 1,
  4.     failed = 2,
  5.     finished = 3,
  6.     aborted = 4,
  7.     saved = 5
  8. }
  9. interface ChapterAdditionalMetadate {
  10.     lastModified?: number;
  11. }
  12. declare class Chapter {
  13.     bookUrl: string;
  14.     bookname: string;
  15.     chapterUrl: string;
  16.     chapterNumber: number;
  17.     chapterName: string | null;
  18.     isVIP: boolean;
  19.     isPaid: boolean | null;
  20.     sectionName: string | null;
  21.     sectionNumber: number | null;
  22.     sectionChapterNumber: number | null;
  23.     chapterParse: BaseRuleClass["chapterParse"];
  24.     charset: string;
  25.     options: object;
  26.     status: Status;
  27.     retryTime: number;
  28.     contentRaw: HTMLElement | null;
  29.     contentText: string | null;
  30.     contentHTML: HTMLElement | null;
  31.     contentImages: attachmentClass[] | null;
  32.     additionalMetadate: ChapterAdditionalMetadate | null;
  33.     chapterHtmlFileName: string | number;
  34.     constructor(bookUrl: string, bookname: string, chapterUrl: string, chapterNumber: number, chapterName: string | null, isVIP: boolean, isPaid: boolean | null, sectionName: string | null, sectionNumber: number | null, sectionChapterNumber: number | null, chapterParse: BaseRuleClass["chapterParse"], charset: string, options: object);
  35.     init(): Promise<this>;
  36.     private parse;
  37. }
  38. declare class attachmentClass {
  39.     url: string;
  40.     name: string;
  41.     mode: "naive" | "TM";
  42.     headers?: {
  43.         [index: string]: string;
  44.     };
  45.     private defaultHeader;
  46.     status: Status;
  47.     retryTime: number;
  48.     imageBlob: Blob | null | void;
  49.     constructor(imageUrl: string, name: string, mode: "naive" | "TM");
  50.     init(): Promise<Blob | null>;
  51.     private downloadImage;
  52.     private tmDownloadImage;
  53. }

  54. interface chapterFilter {
  55.     (chapter: Chapter): boolean;
  56. }
复制代码


自定义筛选函数示例:

只下载该本小说前100章内容:

  1. function chapterFilter(chapter) {
  2.   return chapter.chapterNumber <= 100
  3. }
复制代码


只下载第一卷内容:

  1. function chapterFilter(chapter) {
  2.   return chapter.sectionNumber === 1
  3. }
复制代码

只下载章节名称中含有“武器”的章节:

  1. function chapterFilter(chapter) {
  2.   return chapter.chapterName.includes("武器")
  3. }
复制代码


自定义保存参数
自定义保存参数允许您修改保存文件的样式,章节标题等内容。

使用方法大致同自定义筛选函数,即在 window 下创建 saveOptions 对象,具体格式如下:

  1. declare class saveBook {
  2.     protected book: Book;
  3.     mainStyleText: string;
  4.     tocStyleText: string;
  5.     constructor(book: Book);
  6.     saveTxt(): void;
  7.     saveLog(): void;
  8.     saveZip(runSaveChapters?: boolean): Promise<void>;
  9.     addChapter(chapter: Chapter): void;
  10.     getchapterName(chapter: Chapter): string;
  11.     genSectionText(sectionName: string): string;
  12.     genChapterText(chapterName: string, contentText: string): string;
  13.     genSectionHtmlFile(chapterObj: Chapter): Blob;
  14.     genChapterHtmlFile(chapterObj: Chapter): Blob;
  15.     chapterSort(a: Chapter, b: Chapter): 0 | 1 | -1;
  16. }
  17. interface saveOptions {
  18.     mainStyleText?: saveBook["mainStyleText"];
  19.     tocStyleText?: saveBook["tocStyleText"];
  20.     getchapterName?: saveBook["getchapterName"];
  21.     genSectionText?: saveBook["genSectionText"];
  22.     genChapterText?: saveBook["genChapterText"];
  23.     genSectionHtmlFile?: saveBook["genSectionHtmlFile"];
  24.     genChapterHtmlFile?: saveBook["genChapterHtmlFile"];
  25.     chapterSort?: saveBook["chapterSort"];
  26. }
复制代码


自定义保存参数示例:

将章节名称格式修改为 第xx章 xxxx :

  1. const saveOptions = {
  2.     getchapterName: (chapter) => {
  3.         if (chapter.chapterName) {
  4.             return `第${chapter.chapterNumber.toString()}章 ${chapter.chapterName}`;
  5.         } else {
  6.             return `第${chapter.chapterNumber.toString()}章`;
  7.         }
  8.     }
  9. }
  10. window.saveOptions = saveOptions
复制代码


更改ZIP文档中章节HTML文件样式:

  1. const saveOptions = {
  2.     "mainStyleText": `p {
  3.   text-indent: 4em;
  4.   display: block;
  5.   line-height: 1.3em;
  6.   margin-top: 0.4em;
  7.   margin-bottom: 0.4em;
  8. }`
  9. }
  10. window.saveOptions = saveOptions
复制代码


txt文档每个自然段前加两个空格

  1. const saveOptions = {
  2.     genChapterText: (chapterName, contentText) => {
  3.         contentText = contentText
  4.                     .split('\n')
  5.                     .map(line => {
  6.                             if (line.trim() === "") {
  7.                                 return line
  8.                             } else {
  9.                                 return line.replace(/^/,'    ')
  10.                             }
  11.                         })
  12.                     .join('\n')
  13.         return `## ${chapterName}\n\n${contentText}\n\n`;
  14.     }
  15. }
  16. window.saveOptions = saveOptions
复制代码


保存章节时倒序排列

  1. const saveOptions = {
  2.     chapterSort: (a, b) => {
  3.         if (a.chapterNumber > b.chapterNumber) {
  4.             return -1;
  5.         }
  6.         if (a.chapterNumber === b.chapterNumber) {
  7.             return 0;
  8.         }
  9.         if (a.chapterNumber < b.chapterNumber) {
  10.             return 1;
  11.         }
  12.             return 0;
  13.     }
  14. }
  15. window.saveOptions = saveOptions
复制代码


使用用户脚本自动注入自定义保存参数:

如您总是想使用某一自定义保存参数,你可以使用如下用户脚本(根据实际需要修改相应数值),自动向页面注入自定义保存参数。

  1. // ==UserScript==
  2. // @name         auto inject saveOptions
  3. // @namespace    http://tampermonkey.net/
  4. // @version      0.1
  5. // @description  auto inject saveOptions
  6. // @author       You
  7. // @match        *://*/*
  8. // @grant        none
  9. // ==/UserScript==

  10. (function() {
  11.     'use strict';

  12.     const saveOptions = {
  13.         getchapterName: (chapter) => {
  14.             if (chapter.chapterName) {
  15.                 return `第${chapter.chapterNumber.toString()}章 ${chapter.chapterName}`;
  16.             } else {
  17.                 return `第${chapter.chapterNumber.toString()}章`;
  18.             }
  19.         }
  20.     }
  21.     window.saveOptions = saveOptions
  22. })();
复制代码


自定义筛选函数同理也可使用用户脚本自动注入。

自定义完成回调函数
  1. interface customFinishCallback {
  2.     (): void;
  3. }
复制代码

自定义完成回调函数将在下载完成并生成ZIP文件后自动执行。

使用自定义完成回调函数可在下载完成后自动完成某些工作,例如:关闭当前窗口。

  1. function customFinishCallback(book: Book) {
  2.     window.close();
  3. }
  4. window.customFinishCallback = customFinishCallback;
复制代码


将小说用浏览器下载到电脑 v4.9.0.692



创建日期:2020/6/26
最近更新:2022/5/22
novel-downloader v4.9.0.693 tampermonkey_scripts.zip (305.7 KB, 下载次数: 2)

TM中文网 - 脚本安装指南

1、本站ZIP导入包一般命名类似为tampermonkey.cn_xxx_script.zip,一般无需解压直接导入(导入不成功则解压看是否里面还有ZIP文件,有的话再导入)。
2、JS版为代码版,可在油猴/暴力猴控制台直接添加脚本的方式把JS文件内的代码复制粘贴进去,保存即可成功安装脚本。
3、脚本导入的相关教程《油猴脚本导入教程》/《暴力猴脚本导入教程


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

最近更新的脚本

免责声明

油猴中文网所发布的一切浏览器脚本及应用的帖子仅限用于学习和研究目的;不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。本站信息来自网络,版权争议与本站无关。您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容。如果您喜欢该应用,请支持开发者,若有VIP相关脚本,我们推荐您购买VIP得到更好的官方服务。(如有侵犯了您权益的应用请点此处联系我们处理

联系我们|Archiver|小黑屋|sitemap|, Processed in 0.044528 second(s), 15 queries , File On.   
快速回复 返回顶部 返回列表