Skip to content

Commit b235b5e

Browse files
committed
fix
1 parent 225f2ea commit b235b5e

2 files changed

Lines changed: 17 additions & 10 deletions

File tree

DownloadAllContent/DownloadAllContent.user.js

Lines changed: 16 additions & 9 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.05
8-
// @description Fetch and download main content on current page
7+
// @version 1.06
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 ユニバーサルサイトコンテンツクロールツール、クロール、フォーラム内容など
@@ -14,8 +14,6 @@
1414
// @grant GM_xmlhttpRequest
1515
// @grant GM_registerMenuCommand
1616
// @require https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/1.3.3/FileSaver.min.js
17-
// @updateURL https://greasyfork.org/scripts/25068/code/DownloadAllContent.user.js
18-
// @downloadURL https://greasyfork.org/scripts/25068/code/DownloadAllContent.user.js
1917
// @license MIT License
2018
// @compatible chrome
2119
// @compatible firefox
@@ -103,7 +101,7 @@
103101
}
104102

105103
function getPageContent(doc){
106-
var i,j,rStr="",pageData=(doc.body?doc.body:doc).cloneNode(true),delList=[];
104+
var i,j,k,rStr="",pageData=(doc.body?doc.body:doc).cloneNode(true),delList=[];
107105
[].forEach.call(pageData.querySelectorAll("script,style,link"),function(item){delList.push(item);});
108106
[].forEach.call(delList,function(item){item.parentNode.removeChild(item);});
109107
var largestContent,contents=pageData.querySelectorAll("span,div,article,p,td");
@@ -121,9 +119,18 @@
121119
if(content.childNodes.length>1){
122120
for(j=0;j<content.childNodes.length;j++){
123121
item=content.childNodes[j];
124-
if(item.nodeType==1 && item.firstChild && item.firstChild.nodeType!=3){
125-
allSingle=false;
126-
break;
122+
if(item.nodeType==1){
123+
for(k=0;k<item.childNodes.length;k++){
124+
var childNode=item.childNodes[k];
125+
if(childNode.nodeType!=3 && !/^(I|A|STRONG|B|FONT|BR)$/.test(childNode.tagName)){
126+
allSingle=false;
127+
break;
128+
}
129+
}
130+
if(!allSingle)break;
131+
delList=[];
132+
[].forEach.call(item.childNodes,function(n){if((n.nodeType==3 && /^\s*$/.test(n.data)) || (n.nodeType==1 && /^\s*$/.test(n.textContent)))delList.push(n);});
133+
[].forEach.call(delList,function(n){n.parentNode.removeChild(n);});
127134
}
128135
}
129136
}else{
@@ -159,7 +166,7 @@
159166
if(childNode.tagName=="BR")cStr+="\r\n";
160167
else if(childNode.textContent)cStr+=childNode.textContent.replace(/ +/g," ").replace(/([^\r]|^)\n([^\r]|$)/g,"$1\r\n$2");
161168
}
162-
if(hasText || noTextEnable)rStr+=cStr+"\r\n";
169+
if(hasText || noTextEnable || ele==largestContent)rStr+=cStr+"\r\n";
163170
}
164171
for(i=0;i<childlist.length;i++){
165172
var child=childlist[i];

Easy offline/Easy offline.user.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// @name Easy offline
33
// @name:zh-CN 一键离线下载
44
// @name:zh-TW 一鍵離綫下載
5-
// @description Be easy to find out all magnet links and torrents and video links in current page, and stream them from cloud storage automatically.
5+
// @description Find out all magnet links and torrents and video links in current page, and stream them from cloud storage automatically.
66
// @description:zh-CN 一键自动将磁链、bt种子或其他下载资源离线下载至网盘
77
// @description:zh-TW 一鍵自動將磁鏈、bt種子或其他下載資源離綫下載至網槃
88
// @namespace http://tampermonkey.net/

0 commit comments

Comments
 (0)