44// @name :zh-TW 怠惰小説下載器
55// @name :ja 怠惰者小説ダウンロードツール
66// @namespace hoothin
7- // @version 2.8.3.14
7+ // @version 2.8.3.15
88// @description Lightweight web scraping script. Fetch and download main textual content from the current page, provide special support for novels
99// @description :zh-CN 通用网站内容爬虫抓取工具,可批量抓取任意站点的小说、论坛内容等并保存为TXT文档
1010// @description :zh-TW 通用網站內容爬蟲抓取工具,可批量抓取任意站點的小說、論壇內容等並保存為TXT文檔
@@ -268,10 +268,11 @@ if (window.top != window.self) {
268268 dacSaveAsZip :"下载为 zip" ,
269269 dacSetCustomRule :"修改规则" ,
270270 dacAddUrl :"添加章节" ,
271+ prefix :"给章节名称添加前缀" ,
271272 dacStartDownload :"下载选中" ,
272- downloadShortcut :"下载章节 " ,
273- downloadSingleShortcut :"下载单页 " ,
274- downloadCustomShortcut :"自定义下载 "
273+ downloadShortcut :"下载章节快捷键 " ,
274+ downloadSingleShortcut :"下载单页快捷键 " ,
275+ downloadCustomShortcut :"自定义下载快捷键 "
275276 } ;
276277 break ;
277278 case "zh" :
@@ -316,10 +317,11 @@ if (window.top != window.self) {
316317 dacSaveAsZip :"下載為 zip" ,
317318 dacSetCustomRule :"修改規則" ,
318319 dacAddUrl :"新增章節" ,
320+ prefix :"為章節名稱加上前綴" ,
319321 dacStartDownload :"下載選取" ,
320- downloadShortcut :"下載章節 " ,
321- downloadSingleShortcut :"下載單頁 " ,
322- downloadCustomShortcut :"自設下載 "
322+ downloadShortcut :"下載章節快速鍵 " ,
323+ downloadSingleShortcut :"下載單頁快速鍵 " ,
324+ downloadCustomShortcut :"自設下載快速鍵 "
323325 } ;
324326 break ;
325327 case "ar" :
@@ -379,6 +381,7 @@ if (window.top != window.self) {
379381 dacSaveAsZip : "zip%20%D8%AD%D9%81%D8%B8%20%D9%83%D9%80" ,
380382 dacSetCustomRule : "%D8%AA%D8%B9%D8%AF%D9%8A%D9%84%20%D8%A7%D9%84%D9%82%D9%88%D8%A7%D8%B9%D8%AF" ,
381383 dacAddUrl : "%D8%A5%D8%B6%D8%A7%D9%81%D8%A9%20%D9%81%D8%B5%D9%84" ,
384+ prefix :"Prefix%20of%20chapter%20name" ,
382385 dacStartDownload : "%D8%AA%D8%AD%D9%85%D9%8A%D9%84%20%D8%A7%D9%84%D9%85%D8%AD%D8%AF%D8%AF" ,
383386 downloadShortcut : "%D8%AA%D8%AD%D9%85%D9%8A%D9%84%20%D8%A7%D9%84%D9%81%D8%B5%D9%84" ,
384387 downloadSingleShortcut : "%D8%AA%D8%AD%D9%85%D9%8A%D9%84%20%D8%B5%D9%81%D8%AD%D8%A9%20%D9%88%D8%A7%D8%AD%D8%AF%D8%A9" ,
@@ -425,10 +428,11 @@ if (window.top != window.self) {
425428 dacSaveAsZip : "Save as zip" ,
426429 dacSetCustomRule :"Modify rules" ,
427430 dacAddUrl :"Add Chapter" ,
431+ prefix :"Prefix of chapter name" ,
428432 dacStartDownload :"Download selected" ,
429- downloadShortcut :"Download chapter" ,
430- downloadSingleShortcut :"Download single page" ,
431- downloadCustomShortcut :"Custom download"
433+ downloadShortcut :"Download chapter Shortcut " ,
434+ downloadSingleShortcut :"Download single page Shortcut " ,
435+ downloadCustomShortcut :"Custom download Shortcut "
432436 } ;
433437 break ;
434438 }
@@ -966,6 +970,7 @@ if (window.top != window.self) {
966970 const minute = 60000 ;
967971 var minTxtLength = GM_getValue ( "minTxtLength" ) || 100 ;
968972 var customTitle = GM_getValue ( "customTitle" ) ;
973+ var prefix = GM_getValue ( "prefix" ) ;
969974 var disableNextPage = ! ! GM_getValue ( "disableNextPage" ) ;
970975 var customNextPageReg = GM_getValue ( "nextPageReg" ) ;
971976 var maxDlPerMin = GM_getValue ( "maxDlPerMin" ) || 0 ;
@@ -977,6 +982,23 @@ if (window.top != window.self) {
977982 console . warn ( e ) ;
978983 }
979984 }
985+ var linkIndex = 1 ;
986+ function packLink ( doc , item ) {
987+ if ( customTitle ) {
988+ try {
989+ let title = doc . querySelector ( customTitle ) ;
990+ if ( title && title . innerText ) {
991+ item . innerText = title . innerText ;
992+ }
993+ } catch ( e ) {
994+ console . warn ( e ) ;
995+ }
996+ }
997+ if ( prefix ) {
998+ item . innerText = prefix . replace ( / \$ i / g, linkIndex ) + item . innerText ;
999+ linkIndex ++ ;
1000+ }
1001+ }
9801002 var insertSigns = [ ] ;
9811003 // var j=0,rCats=[];
9821004 var downIndex = 0 , downNum = 0 , downOnce = function ( wait ) {
@@ -999,6 +1021,9 @@ if (window.top != window.self) {
9991021 let curIndex = downIndex ;
10001022 let aTag = aEles [ curIndex ] ;
10011023 let request = ( aTag , curIndex ) => {
1024+ if ( aTag && aTag . cloneNode ) {
1025+ aTag = aTag . cloneNode ( true ) ;
1026+ }
10021027 let tryTimes = 0 ;
10031028 let validTimes = 0 ;
10041029 function requestDoc ( _charset ) {
@@ -1075,16 +1100,7 @@ if (window.top != window.self) {
10751100 } else {
10761101 console . log ( result . status ) ;
10771102 }
1078- if ( customTitle ) {
1079- try {
1080- let title = doc . querySelector ( customTitle ) ;
1081- if ( title && title . innerText ) {
1082- aTag . innerText = title . innerText ;
1083- }
1084- } catch ( e ) {
1085- console . warn ( e ) ;
1086- }
1087- }
1103+ packLink ( doc , aTag ) ;
10881104 let validData = processDoc ( curIndex , aTag , doc , ( result . status >= 400 ?` status: ${ result . status } from: ${ aTag . href } ` :"" ) , validTimes < 5 ) ;
10891105 if ( ! validData && validTimes ++ < 5 ) {
10901106 downIndex -- ;
@@ -1211,16 +1227,7 @@ if (window.top != window.self) {
12111227 }
12121228 } ) ;
12131229 }
1214- if ( customTitle ) {
1215- try {
1216- let title = doc . querySelector ( customTitle ) ;
1217- if ( title && title . innerText ) {
1218- aTag . innerText = title . innerText ;
1219- }
1220- } catch ( e ) {
1221- console . warn ( e ) ;
1222- }
1223- }
1230+ packLink ( doc , aTag ) ;
12241231 downIndex ++ ;
12251232 downNum ++ ;
12261233 let validData = processDoc ( curIndex , aTag , doc , "" , failedTimes < 2 ) ;
@@ -2122,10 +2129,12 @@ if (window.top != window.self) {
21222129 reSortUrl . name = "sort" ;
21232130 contentSort . name = "sort" ;
21242131 let reverse = createOption ( i18n . reverseOrder , ! ! GM_getValue ( "reverse" ) , "checkbox" ) ;
2132+ let prefix = createOption ( i18n . prefix , GM_getValue ( "prefix" ) || "" ) ;
21252133 let disableNextPage = ! ! GM_getValue ( "disableNextPage" ) ;
21262134 let nextPage = createOption ( i18n . nextPage , ! disableNextPage , "checkbox" ) ;
21272135 let nextPageReg = createOption ( i18n . nextPageReg , GM_getValue ( "nextPageReg" ) || "" ) ;
21282136 let retainImage = createOption ( i18n . retainImage , ! ! GM_getValue ( "retainImage" ) , "checkbox" ) ;
2137+ prefix . setAttribute ( "placeHolder" , "第 $i 章:" ) ;
21292138 nextPageReg . setAttribute ( "placeHolder" , "^\\s*(下一[页頁张張]|next\\s*page|次のページ)" ) ;
21302139 if ( disableNextPage ) {
21312140 nextPageReg . parentNode . style . display = "none" ;
@@ -2159,6 +2168,7 @@ if (window.top != window.self) {
21592168 GM_setValue ( "showFilterList" , showFilterList . checked ) ;
21602169 GM_setValue ( "disableNextPage" , ! nextPage . checked ) ;
21612170 GM_setValue ( "nextPageReg" , nextPageReg . value || "" ) ;
2171+ GM_setValue ( "prefix" , prefix . value || "" ) ;
21622172 GM_setValue ( "downloadShortcut" , geneShortcutData ( downloadShortcutInput . value ) || "" ) ;
21632173 GM_setValue ( "downloadSingleShortcut" , geneShortcutData ( downloadSingleShortcutInput . value ) || "" ) ;
21642174 GM_setValue ( "downloadCustomShortcut" , geneShortcutData ( downloadCustomShortcutInput . value ) || "" ) ;
0 commit comments