Skip to content

Commit f446daf

Browse files
committed
fix
1 parent 27ce8b8 commit f446daf

1 file changed

Lines changed: 21 additions & 7 deletions

File tree

DownloadAllContent/DownloadAllContent.user.js

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
// @name:zh-TW 懶人小説下載器
55
// @name:ja 怠惰者小説ダウンロードツール
66
// @namespace hoothin
7-
// @version 1.10
8-
// @description Fetch and download main content on current page,provide special support for chinese novel
7+
// @version 1.11
8+
// @description Fetch and download main content on current page, provide special support for chinese novel
99
// @description:zh-CN 通用网站内容抓取工具,可批量抓取小说、论坛内容等并保存为TXT文档
1010
// @description:zh-TW 通用網站內容抓取工具,可批量抓取小說、論壇內容等並保存為TXT文檔
1111
// @description:ja ユニバーサルサイトコンテンツクロールツール、クロール、フォーラム内容など
@@ -32,14 +32,18 @@
3232
i18n={
3333
fetch:"开始下载小说或其他【Ctrl+F9】",
3434
info:"本文是使用懒人小说下载器(DownloadAllContent)脚本下载的",
35-
error:"该段内容获取失败"
35+
error:"该段内容获取失败",
36+
downloading:"已下载完成 %s 段,剩余 %s 段<br>正在下载 %s",
37+
complete:"已全部下载完成,共 %s 段"
3638
};
3739
break;
3840
default:
3941
i18n={
4042
fetch:"Download All Content[Ctrl+F9]",
4143
info:"The TXT is downloaded by 'DownloadAllContent'",
42-
error:"Failed in downloading current chapter"
44+
error:"Failed in downloading current chapter",
45+
downloading:"%s pages are downloaded, there are still %s pages left<br>Downloading %s ......",
46+
complete:"Completed! The pages totalled %s"
4347
};
4448
break;
4549
}
@@ -78,9 +82,9 @@
7882
j++;
7983
rCats[i]=(aTag.textContent+"\r\n"+getPageContent(doc));
8084
txtDownContent.style.display="block";
81-
txtDownWords.innerHTML="已下载完成 "+j+" 段,剩余 "+(aEles.length-j)+" 段"+"<br>正在下载 "+aTag.textContent;
85+
txtDownWords.innerHTML=getI18n("downloading",[j,(aEles.length-j),aTag.textContent]);
8286
if(j==aEles.length){
83-
txtDownWords.innerHTML="已全部下载完成,共 "+j+" 段";
87+
txtDownWords.innerHTML=getI18n("complete",[j]);
8488
var blob = new Blob([i18n.info+"\r\n"+document.title+"\r\n\r\n"+rCats.join("\r\n\r\n")], {type: "text/plain;charset=utf-8"});
8589
saveAs(blob, document.title+".txt");
8690
}
@@ -187,6 +191,16 @@
187191
return rStr;
188192
}
189193

194+
function getI18n(key, args){
195+
var resultStr=i18n[key];
196+
if(args && args.length>0){
197+
args.forEach(function(item){
198+
resultStr=resultStr.replace(/%s/,item);
199+
});
200+
}
201+
return resultStr;
202+
}
203+
190204
function getDepth(dom){
191205
var pa=dom,i=0;
192206
while(pa.parentNode){
@@ -200,7 +214,7 @@
200214
var aEles=document.querySelectorAll("a"),list=[];
201215
for(var i=0;i<aEles.length;i++){
202216
var aEle=aEles[i];
203-
if(aEle.href && /.+[|||||||]||\s*|\s*|\s*|\s*|\s*|\s*|\s*|\s*|\s*|\s*|[\d|||||||||||||||||-]+(|)/.test(aEle.innerHTML)){
217+
if(aEle.href && /PART\b|Prologue|Chapter\s*\d+|.+[|||||||]||\s*|\s*|\s*|\s*|\s*|\s*|\s*|\s*|\s*|\s*|[\d|||||||||||||||||-]+(|)/i.test(aEle.innerHTML)){
204218
list.push(aEle);
205219
}
206220
}

0 commit comments

Comments
 (0)