|
4 | 4 | // @name:zh-TW 懶人小説下載器 |
5 | 5 | // @name:ja 怠惰者小説ダウンロードツール |
6 | 6 | // @namespace hoothin |
7 | | -// @version 1.12 |
| 7 | +// @version 1.13 |
8 | 8 | // @description Fetch and download main content on current page, provide special support for chinese novel |
9 | 9 | // @description:zh-CN 通用网站内容抓取工具,可批量抓取小说、论坛内容等并保存为TXT文档 |
10 | 10 | // @description:zh-TW 通用網站內容抓取工具,可批量抓取小說、論壇內容等並保存為TXT文檔 |
|
113 | 113 | let content=contents[i],hasText=false,allSingle=true,item; |
114 | 114 | for(j=content.childNodes.length-1;j>=0;j--){ |
115 | 115 | 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)) |
117 | 117 | item.parentNode.removeChild(item); |
118 | 118 | } |
119 | 119 | for(j=content.childNodes.length-1;j>=0;j--){ |
120 | 120 | 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)) |
122 | 122 | item.parentNode.removeChild(item); |
123 | 123 | } |
| 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 | + }); |
124 | 131 | [].forEach.call(content.childNodes,function(item){ |
125 | 132 | if(item.nodeType==3 && item.data && !/^\s*$/.test(item.data)) |
126 | 133 | hasText=true; |
|
173 | 180 | for(let j=0;j<childNodes.length;j++){ |
174 | 181 | let childNode=childNodes[j]; |
175 | 182 | 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 | | - } |
179 | 183 | if(childNode.textContent){ |
180 | 184 | cStr+=childNode.textContent.replace(/ +/g," ").replace(/([^\r]|^)\n([^\r]|$)/g,"$1\r\n$2"); |
181 | 185 | } |
| 186 | + if(childNode.innerHTML){ |
| 187 | + childNode.innerHTML=childNode.innerHTML.replace(/\<\s*br\s*\>/gi,"\r\n"); |
| 188 | + } |
182 | 189 | if(childNode.nodeType!=3 && !/^(I|A|STRONG|B|FONT)$/.test(childNode.tagName))cStr+="\r\n"; |
183 | 190 | } |
184 | 191 | if(hasText || noTextEnable || ele==largestContent)rStr+=cStr+"\r\n"; |
|
0 commit comments