Skip to content

Commit bc01c81

Browse files
committed
fix
1 parent ce6a89c commit bc01c81

1 file changed

Lines changed: 11 additions & 10 deletions

File tree

DownloadAllContent/DownloadAllContent.user.js

Lines changed: 11 additions & 10 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.23
7+
// @version 1.25
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文檔
@@ -121,9 +121,12 @@
121121

122122
function getPageContent(doc){
123123
if(!doc)return i18n.error;
124+
[].forEach.call(doc.querySelectorAll("span,div"),function(item){
125+
var thisStyle=doc.defaultView.getComputedStyle(item);
126+
if(thisStyle && (thisStyle.display=="none"||thisStyle.fontSize=="0px"))
127+
item.parentNode.removeChild(item);
128+
});
124129
var i,j,k,rStr="",pageData=(doc.body?doc.body:doc).cloneNode(true),delList=[];
125-
[].forEach.call(pageData.querySelectorAll("script,style,link,img,noscript"),function(item){delList.push(item);});
126-
[].forEach.call(delList,function(item){item.parentNode.removeChild(item);});
127130
[].forEach.call(pageData.querySelectorAll("font.jammer"),function(item){
128131
item.parentNode.removeChild(item);
129132
});
@@ -133,10 +136,8 @@
133136
item.parentNode.removeChild(item);
134137
});
135138
}
136-
[].forEach.call(pageData.querySelectorAll("span"),function(item){
137-
if(item.style && item.style.display=="none")
138-
item.parentNode.removeChild(item);
139-
});
139+
[].forEach.call(pageData.querySelectorAll("script,style,link,img,noscript"),function(item){delList.push(item);});
140+
[].forEach.call(delList,function(item){item.parentNode.removeChild(item);});
140141
var largestContent,contents=pageData.querySelectorAll("span,div,article,p,td"),largestNum=0;
141142
for(i=0;i<contents.length;i++){
142143
let content=contents[i],hasText=false,allSingle=true,item,curNum=0;
@@ -187,7 +188,7 @@
187188
}
188189
}
189190
if(!largestContent)return i18n.error;
190-
var childlist=pageData.querySelectorAll(largestContent.tagName+(largestContent.className?"."+largestContent.className.replace(/(^\s*)|(\s*$)/g, '').replace(/\s+/g, '.'):""));
191+
var childlist=pageData.querySelectorAll(largestContent.tagName);//+(largestContent.className?"."+largestContent.className.replace(/(^\s*)|(\s*$)/g, '').replace(/\s+/g, '.'):""));
191192
function getRightStr(ele, noTextEnable){
192193
let childNodes=ele.childNodes,cStr="\r\n",hasText=false;
193194
for(let j=0;j<childNodes.length;j++){
@@ -206,7 +207,7 @@
206207
for(i=0;i<childlist.length;i++){
207208
var child=childlist[i];
208209
if(getDepth(child)==getDepth(largestContent)){
209-
if(largestContent.className && largestContent.className==child.className){
210+
if((largestContent.className && largestContent.className==child.className)||largestContent.parentNode ==child.parentNode){
210211
getRightStr(child, true);
211212
}else {
212213
getRightStr(child, false);
@@ -247,7 +248,7 @@
247248
break;
248249
}
249250
}
250-
if(!has && aEle.href && /^http/i.test(aEle.href) && /PART\b|Prologue||Chapter\s*\d+|.+[|||||||]|^$|\s*|\s*|\s*|\s*|\s*|\s*|\s*|\s*|\s*|\s*|\s*|[\d|||||||||||||||||-]+(||\.)/i.test(aEle.innerText)){
251+
if(!has && aEle.href && /^http/i.test(aEle.href) && /PART\b|Prologue|-\d+||Chapter\s*\d+|.+[|||||||]|^$|\s*|\s*|\s*|\s*|\s*|\s*|\s*|\s*|\s*|\s*|\s*|[\d|||||||||||||||||-]+(||\.)/i.test(aEle.innerText)){
251252
list.push(aEle);
252253
}
253254
}

0 commit comments

Comments
 (0)