Skip to content

Commit 8820802

Browse files
committed
fix
1 parent 5f429c9 commit 8820802

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

DownloadAllContent/DownloadAllContent.user.js

Lines changed: 13 additions & 6 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.12
7+
// @version 1.13
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文檔
@@ -113,14 +113,21 @@
113113
let content=contents[i],hasText=false,allSingle=true,item;
114114
for(j=content.childNodes.length-1;j>=0;j--){
115115
item=content.childNodes[j];
116-
if((item.nodeType==3 && /^\s*$/.test(item.data)) || (item.tagName=="FONT" && item.className=="jammer") || (item.style && item.style.display=="none"))
116+
if(item.nodeType==3 && /^\s*$/.test(item.data))
117117
item.parentNode.removeChild(item);
118118
}
119119
for(j=content.childNodes.length-1;j>=0;j--){
120120
item=content.childNodes[j];
121-
if(item.nodeType==1 && /^\s*$/.test(item.innerHTML))
121+
if(item.nodeType==1 && !/^(I|A|STRONG|B|FONT|BR)$/.test(item.tagName) && /^\s*$/.test(item.innerHTML))
122122
item.parentNode.removeChild(item);
123123
}
124+
[].forEach.call(content.querySelectorAll("font.jammer"),function(item){
125+
item.parentNode.removeChild(item);
126+
});
127+
[].forEach.call(content.querySelectorAll("span"),function(item){
128+
if(item.style && item.style.display=="none")
129+
item.parentNode.removeChild(item);
130+
});
124131
[].forEach.call(content.childNodes,function(item){
125132
if(item.nodeType==3 && item.data && !/^\s*$/.test(item.data))
126133
hasText=true;
@@ -173,12 +180,12 @@
173180
for(let j=0;j<childNodes.length;j++){
174181
let childNode=childNodes[j];
175182
if(childNode.nodeType==3 && childNode.data && !/^\s*$/.test(childNode.data))hasText=true;
176-
if(childNode.innerHTML){
177-
childNode.innerHTML=childNode.innerHTML.replace(/\<\s*br\s*\>/gi,"\r\n");
178-
}
179183
if(childNode.textContent){
180184
cStr+=childNode.textContent.replace(/ +/g," ").replace(/([^\r]|^)\n([^\r]|$)/g,"$1\r\n$2");
181185
}
186+
if(childNode.innerHTML){
187+
childNode.innerHTML=childNode.innerHTML.replace(/\<\s*br\s*\>/gi,"\r\n");
188+
}
182189
if(childNode.nodeType!=3 && !/^(I|A|STRONG|B|FONT)$/.test(childNode.tagName))cStr+="\r\n";
183190
}
184191
if(hasText || noTextEnable || ele==largestContent)rStr+=cStr+"\r\n";

0 commit comments

Comments
 (0)