Skip to content

Commit a6778ec

Browse files
committed
fix
1 parent f939eba commit a6778ec

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

DownloadAllContent/DownloadAllContent.user.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// @name:zh-TW 懶人小説下載器
55
// @name:ja 怠惰者小説ダウンロードツール
66
// @namespace hoothin
7-
// @version 1.08
7+
// @version 1.09
88
// @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文檔
@@ -31,13 +31,15 @@
3131
case "zh-CN":
3232
i18n={
3333
fetch:"开始下载小说或其他【Ctrl+F9】",
34-
info:"本文是使用懒人小说下载器(DownloadAllContent)脚本下载的"
34+
info:"本文是使用懒人小说下载器(DownloadAllContent)脚本下载的",
35+
error:"该段内容获取失败"
3536
};
3637
break;
3738
default:
3839
i18n={
3940
fetch:"Download All Content[Ctrl+F9]",
40-
info:"The TXT is downloaded by 'DownloadAllContent'"
41+
info:"The TXT is downloaded by 'DownloadAllContent'",
42+
error:"Failed in downloading current chapter"
4143
};
4244
break;
4345
}
@@ -98,7 +100,7 @@
98100
}
99101

100102
function getPageContent(doc){
101-
if(!doc)return "该段内容获取失败";
103+
if(!doc)return i18n.error;
102104
var i,j,k,rStr="",pageData=(doc.body?doc.body:doc).cloneNode(true),delList=[];
103105
[].forEach.call(pageData.querySelectorAll("script,style,link"),function(item){delList.push(item);});
104106
[].forEach.call(delList,function(item){item.parentNode.removeChild(item);});
@@ -107,7 +109,7 @@
107109
let content=contents[i],hasText=false,allSingle=true,item;
108110
for(j=content.childNodes.length-1;j>=0;j--){
109111
item=content.childNodes[j];
110-
if(item.nodeType==3 && /^\s*$/.test(item.data))
112+
if((item.nodeType==3 && /^\s*$/.test(item.data)) || (item.tagName=="FONT" && item.className=="jammer") || (item.style && item.style.display=="none"))
111113
item.parentNode.removeChild(item);
112114
}
113115
[].forEach.call(content.childNodes,function(item){
@@ -155,7 +157,7 @@
155157
}
156158
}
157159
}
158-
if(!largestContent)return "该段内容获取失败";
160+
if(!largestContent)return i18n.error;
159161
var childlist=pageData.querySelectorAll(largestContent.tagName+(largestContent.className?"."+largestContent.className.replace(/(^\s*)|(\s*$)/g, '').replace(/\s+/g, '.'):""));
160162
function getRightStr(ele, noTextEnable){
161163
let childNodes=ele.childNodes,cStr="\r\n",hasText=false;
@@ -165,7 +167,7 @@
165167
if(childNode.textContent){
166168
cStr+=childNode.textContent.replace(/ +/g," ").replace(/([^\r]|^)\n([^\r]|$)/g,"$1\r\n$2");
167169
}
168-
if(childNode.nodeType!=3)cStr+="\r\n";
170+
if(childNode.nodeType!=3 && !/^(I|A|STRONG|B|FONT)$/.test(childNode.tagName))cStr+="\r\n";
169171
}
170172
if(hasText || noTextEnable || ele==largestContent)rStr+=cStr+"\r\n";
171173
}

0 commit comments

Comments
 (0)