Skip to content

Commit 13d28c0

Browse files
committed
fix
1 parent 4431e5a commit 13d28c0

1 file changed

Lines changed: 18 additions & 9 deletions

File tree

DownloadAllContent/DownloadAllContent.user.js

Lines changed: 18 additions & 9 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 0.5
7+
// @version 0.6
88
// @description Fetch and download main content on current page
99
// @description:zh-CN 通用网站内容抓取工具,可批量抓取小说、论坛内容等并保存为TXT文档
1010
// @description:zh-TW 通用網站內容抓取工具,可批量抓取小說、論壇內容等並保存為TXT文檔
@@ -123,10 +123,10 @@
123123
if(content.firstChild && (
124124
(content.firstChild.nodeType!=3 && !/^[I|A]$/.test(content.firstChild.tagName)) ||
125125
(/^\s*$/.test(content.firstChild.data) &&
126-
(!content.childNodes[1]||!/^[I|A]$/.test(content.childNodes[1].tagName)))
126+
(!content.childNodes[1] || !/^[I|A]$/.test(content.childNodes[1].tagName)))
127127
))
128128
continue;
129-
if(pageData==document && content.offsetWidth <= 0 && content.offsetHeight <= 0)
129+
if(pageData==document && content.offsetWidth<=0 && content.offsetHeight<=0)
130130
continue;
131131
if(navigator.userAgent.toLowerCase().indexOf('firefox')!=-1){
132132
if(!largestContent || largestContent.textContent.length<content.textContent.length){
@@ -142,16 +142,25 @@
142142
for(i=0;i<childlist.length;i++){
143143
var child=childlist[i];
144144
if(largestContent.className && largestContent.className==child.className){
145-
}else if(child.firstChild && ((child.firstChild.nodeType!=3 && !/^[I|A]$/.test(child.firstChild.tagName)) || (/^\s*$/.test(child.firstChild.data) && (!child.childNodes[1] || !/^[I|A]$/.test(child.childNodes[1].tagName)))))continue;
146-
if(getDepth(child)==getDepth(largestContent)){
147145
let childNodes=child.childNodes,cStr="\r\n",hasText=false;
148-
for(var j=0;j<childNodes.length;j++){
149-
var childNode=childNodes[j];
150-
if(childNode.nodeType==3 && childNode.data && !/^\s*$/.test(childNode.data))hasText=true;
146+
for(let j=0;j<childNodes.length;j++){
147+
let childNode=childNodes[j];
151148
if(childNode.tagName=="BR")cStr+="\r\n";
152149
else if(!/SCRIPT|STYLE/.test(childNode.tagName) && childNode.textContent)cStr+=childNode.textContent.replace(/\s*/," ");
153150
}
154-
if(hasText)rStr+=cStr;
151+
rStr+=cStr;
152+
}else {
153+
if(child.firstChild && ((child.firstChild.nodeType!=3 && !/^[I|A]$/.test(child.firstChild.tagName)) || (/^\s*$/.test(child.firstChild.data) && (!child.childNodes[1] || !/^[I|A]$/.test(child.childNodes[1].tagName)))))continue;
154+
if(getDepth(child)==getDepth(largestContent)){
155+
let childNodes=child.childNodes,cStr="\r\n",hasText=false;
156+
for(let j=0;j<childNodes.length;j++){
157+
let childNode=childNodes[j];
158+
if(childNode.nodeType==3 && childNode.data && !/^\s*$/.test(childNode.data))hasText=true;
159+
if(childNode.tagName=="BR")cStr+="\r\n";
160+
else if(!/SCRIPT|STYLE/.test(childNode.tagName) && childNode.textContent)cStr+=childNode.textContent.replace(/\s*/," ");
161+
}
162+
if(hasText)rStr+=cStr;
163+
}
155164
}
156165
}
157166
return rStr;

0 commit comments

Comments
 (0)