-
-
Notifications
You must be signed in to change notification settings - Fork 124
/
Copy pathnovelDownloader3.user.js
4205 lines (4082 loc) · 176 KB
/
novelDownloader3.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* eslint-env browser */
// ==UserScript==
// @name novelDownloader3
// @description 菜单```Download Novel```或**双击页面最左侧**来显示面板
// @version 3.5.451
// @created 2020-03-16 16:59:04
// @modified 2024-07-27 18:27:11
// @author dodying
// @namespace https://github.com/dodying/UserJs
// @supportURL https://github.com/dodying/UserJs/issues
// @icon https://github.com/dodying/UserJs/raw/master/Logo.png
// @downloadURL https://github.com/dodying/UserJs/raw/master/novel/novelDownloader/novelDownloader3.user.js#bypass=true
// @updateURL https://github.com/dodying/UserJs/raw/master/novel/novelDownloader/novelDownloader3.user.js#bypass=true
// @require https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.js
// @require https://greasyfork.org/scripts/398502-download/code/download.js?version=977735
// require https://github.com/dodying/UserJs/raw/master/lib/download.js
// require http://127.0.0.1:8082/download.js
// @require https://greasyfork.org/scripts/21541-chs2cht/code/chs2cht.js?version=605976
// require https://greasyfork.org/scripts/32483-base64/code/base64.js?version=213081
// @require https://cdnjs.cloudflare.com/ajax/libs/jszip/3.0.0/jszip.min.js
// @require https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/1.3.8/FileSaver.min.js
// @require https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.0.0/crypto-js.min.js
// @require https://cdn.jsdelivr.net/npm/opentype.js@1.3.4/dist/opentype.min.js
// @require https://cdn.jsdelivr.net/npm/async@3.2.5/dist/async.min.js
// resource fontLib https://github.com/dodying/UserJs/raw/master/novel/novelDownloader/SourceHanSansCN-Regular-Often.json?v=2
// @resource fontLib https://github.com/dodying/UserJs/raw/master/novel/novelDownloader/SourceHanSansCN-Regular-Often.json?v=2
// resource fontLib file:///E:/Desktop/_/GitHub/UserJs/novel/novelDownloader/起点自定义字体/often.json?v=2
// @grant GM_xmlhttpRequest
// @grant unsafeWindow
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_deleteValue
// @grant GM_addValueChangeListener
// @grant GM_registerMenuCommand
// @grant GM_getResourceText
// @run-at document-end
// @connect *
// @include *
// @noframes
// ==/UserScript==
/* global unsafeWindow GM_info GM_setValue GM_getValue GM_deleteValue GM_addValueChangeListener GM_registerMenuCommand GM_getResourceText */
/* eslint-disable no-debugger */
/* global $ xhr tranStr JSZip saveAs CryptoJS opentype async */
; (function () { // eslint-disable-line no-extra-semi
let fontLib;
/*
* interface Chapter {
* title?: string;
* url?: string;
* volume?: string;
* document?: string;
* contentRaw?: string;
* content?: string;
* }
*/
let Storage = null;
Storage = {
debug: {
book: false,
content: false,
},
mode: null, // 1=index 2=chapter
rule: null, // 当前规则
book: {
image: [],
},
xhr,
};
const Config = {
thread: 5,
retry: 3,
timeout: 60000,
reference: true,
format: true,
useCommon: true,
modeManual: true,
templateRule: true,
volume: true,
failedCount: 5,
failedWait: 60,
image: true,
addChapterNext: true,
removeEmptyLine: 'auto',
css: 'body {\n line-height: 130%;\n text-align: justify;\n font-family: \\"Microsoft YaHei\\";\n font-size: 22px;\n margin: 0 auto;\n background-color: #CCE8CF;\n color: #000;\n}\n\nh1 {\n text-align: center;\n font-weight: bold;\n font-size: 28px;\n}\n\nh2 {\n text-align: center;\n font-weight: bold;\n font-size: 26px;\n}\n\nh3 {\n text-align: center;\n font-weight: bold;\n font-size: 24px;\n}\n\np {\n text-indent: 2em;\n}',
customize: '[]',
...GM_getValue('config', {}),
};
const Rule = {
// 如无说明,所有可以为*选择器*都可以是async (doc)=>string
// 章节内async (doc,res,request)
// 快速查找脚本的相应位置:rule.key
// ?siteName
siteName: '通用规则',
// 以下三个必须有一个
// ?url: string[]/regexp[]
// ?chapterUrl: string[]/regexp[]
// ?filter: function=> 0=notmatched 1=index 2=chapter
url: [/(index|0|list|default)\.(s?html?|php)$/i],
chapterUrl: [/\d+\/\d+\.(s?html?|php)$/i],
// ?infoPage: 选择器 或 async (doc)=>url
// 如果存在infoPage,则基本信息(title,writer,intro,cover)从infoPage页面获取
// 当infoPage与当前页相同时,直接从当前页获取(极少数情况)
// title 书籍名称:选择器
title: ['.h1title > .shuming > a[title]', '.chapter_nav > div:first > a:last', '#header > .readNav > span > a:last', 'div[align="center"] > .border_b > a:last', '.ydselect > .weizhi > a:last', '.bdsub > .bdsite > a:last', '#sitebar > a:last', '.con_top > a:last', '.breadCrumb > a:last'].join(','),
// titleRegExp 从<title>获取标题,返回$1
titleRegExp: /^(.*?)(_|-|\(| |最新|小说|无弹窗|目录|全文|全本|txt|5200章节)/i,
// ?titleReplace:[[find,replace]]
// ?writer:选择器
writer: '#info>p:eq(0):maxsize(20),:contains(作):contains(者):maxsize(20):last',
// ?intro:选择器
intro: '#intro>p:eq(0)',
// ?cover:选择器
// chapter:选择器(应包含vip章节) 或 async (doc)=>url[]或{url,title}[]
chapter: [
'.dir a', '#BookText a', '#Chapters a', '#TabCss a',
'#Table1 a', '#at a', '#book a', '#booktext a',
'#catalog_list a', '#chapterList a', '#chapterlist a', '#container1 a',
'#content_1 a', '#contenttable a', '#dir a', '#htmlList a',
'#list a', '#oneboolt a', '#read.chapter a', '#readerlist a',
'#readerlists a', '#readlist a', '#tbchapterlist a', '#xslist a',
'#zcontent a', '.Chapter a', '.L a', '.TabCss>dl>dd>a',
'.Volume a', '._chapter a', '.aarti a', '.acss a',
'.all-catalog a', '.art_fnlistbox a', '.art_listmain_main a', '.article_texttitleb a',
'.as a', '.bd a', '.book a', '.book-chapter-list a',
'.bookUpdate a', '.book_02 a', '.book_article_listtext a', '.book_con_list a',
'.book_dirbox a', '.book_list a', '.booklist a', '#booklist a',
'.box-item a', '.box1 a', '.box_box a', '.box_chap a',
'.catalog a', '.catalog-list a', '.catebg a', '.category a',
'.ccss a', '.centent a', '.chapname a', '.chapter a',
'.chapter-list a', '.chapterBean a', '.chapterNum a', '.chapterTable a',
'.chapter_box_ul a', '.chapter_list_chapter a', '.chapterlist a', '.chapterlistxx a',
'.chapters a', '.chapters_list a', '.chaptertable a', '.chaptertd a',
'.columns a', '.con_05 a', '.content a', '.contentlist a',
'.conter a', '.css a', '.d_contarin a', '.dccss a',
'.detail-chapters a', '.dir_main_section a', '.dirbox a', '.dirconone a',
'.dirinfo_list a', '.dit-list a', '.download_rtx a', '.entry_video_list a',
'.float-list a', '.index a', '.indexlist a', '.info_chapterlist a',
'.insert_list a', '.item a', '.kui-item a', '.l_mulu_table a',
'.lb a', '.liebiao a', '.liebiao_bottom a', '.list a',
'.list-directory a', '.list-group a', '.list01a', '.list_Content a',
'.list_box a', '.listmain a', '.lists a', '.lrlb a',
'.m10 a', '.main a', '.mb_content a', '.menu-area a',
'.ml-list1 a', '.ml_main a', '.mls a', '.mod_container a',
'.mread a', '.mulu a', '.mulu_list a', '.nav a',
'.nolooking a', '.novel_leftright a', '.novel_list a', '.ocon a',
'.opf a', '.qq', '.read_list a', '.readout a',
'.td_0 a', '.td_con a', '.third a', '.uclist a',
'.uk-table a', '.volume a', '.volumes a', '.wiki-content-table a',
'.www a', '.xiaoshuo_list a', '.xsList a', '.zhangjieUl a',
'.zjbox a', '.zjlist a', '.zjlist4 a', '.zl a',
'.zp_li a', 'dd a', '.chapter-list a', '.directoryArea a',
'[id*="list"] a', '[class*="list"] a',
'[id*="chapter"] a', '[class*="chapter"] a',
].join(','),
// vipChapter:选择器 或 async (doc)=>url[]或{url,title}[]
// volume:
// 选择器/async (doc)=>elem[];原理 $(chaptes).add(volumes);
// async (doc,chapters)=>chapters;尽量不要生成新的对象,而是在原有对象上增加键"volume"(方便重新下载)
// 以下在章节页面内使用
// ?chapterTitle:选择器 省略留空时,为chapter的textContent
chapterTitle: '.bookname>h1,h2',
// iframe: boolean 或 async (win)=>null
// 使用时,只能一个一个获取(慎用)
// popup: boolean 或 async ()=>null
// 仅当X-Frame-Options:DENY时使用,使用时,只能一个一个获取(慎用)
// deal: async(chapter)=>content||object
// 不请求章节相对网页,而直接获得内容(请求其他网址)
// 可以直接给chapter赋值,也可以返回content或需要的属性如title
// content:选择器
content: [
'#pagecontent', '#contentbox', '#bmsy_content', '#bookpartinfo',
'#htmlContent', '#text_area', '#chapter_content', '#chapterContent', '#chaptercontent',
'#partbody', '#BookContent', '#article_content', '#BookTextRead',
'#booktext', '#BookText', '#readtext', '#readcon',
'#text_c', '#txt_td', '#TXT', '#txt',
'#zjneirong', '.novel_content', '.readmain_inner', '.noveltext',
'.booktext', '.yd_text2', '#contentTxt', '#oldtext',
'#a_content', '#contents', '#content2', '#contentts',
'#content1', '#content', '.content', '#arctext',
'[itemprop="acticleBody"]', '.readerCon',
'[id*="article"]:minsize(100)', '[class*="article"]:minsize(100)',
'[id*="content"]:minsize(100)', '[class*="content"]:minsize(100)',
].join(','),
// ?contentCheck: 检查页面是否正确,true时保留,否则content=null
// 选择器 存在元素则为true
// 或 async (doc,res,request)=>boolean
// ?elementRemove:选择器 或 async (contentHTML)=>contentHTML
// 如果需要下载图片,请不要移除图片元素
elementRemove: 'script,style,iframe,*:emptyHuman:not(br,p,img),:hiddenHuman,a:not(:has(img))',
// ?contentReplace:[[find,replace]]
// 如果有图片,请不要移除图片元素
// ?chapterPrev,chapterNext:选择器 或 async (doc)=>url
chapterPrev: 'a[rel="prev"],a:regexp("[上前]一?[章页话集节卷篇]+"),#prevUrl',
chapterNext: 'a[rel="next"],a:regexp("[下后]一?[章页话集节卷篇]+"),#nextUrl',
// ?ignoreUrl:url[] 忽略的网站(用于过滤chapterPrev,chapterNext)
// ?getChapters 在章节页面时使用,获取全部章节
// async (doc)=>url[]或{url,title,vip,volume}[]
// ?charset:utf-8||gb2312||other
// 通常来说不用设置
// ?thread:下载线程数 通常来说不用设置
// ?vip:{} 对于vip页面
// 可用key: chapterTitle,iframe,deal,content,contentCheck,elementRemove,contentReplace,chapterPrev,chapterNext
};
Rule.special = [
// 漫画
{ // https://manhua.dmzj.com/
siteName: '动漫之家',
url: '://manhua.dmzj.com/[a-z0-9]+/',
chapterUrl: '://manhua.dmzj.com/[a-z0-9]+/\\d+.shtml',
title: '.anim_title_text h1',
writer: '.anim-main_list a[href^="../tags/"]',
intro: '.line_height_content',
cover: '#cover_pic',
chapter: '[class^="cartoon_online_border"]>ul>li>a',
volume: '.h2_title2>h2',
chapterTitle: '.display_middle',
content: '#center_box',
iframe: true,
contentReplace: [
[/<img id="img_\d+" style=".*?" data-original="(.*?)" src=".*?">/g, '<img src="$1">'],
],
},
{ // https://www.manhuabei.com/ https://www.manhuafen.com/
siteName: '漫画堆',
filter: () => ($('.dmzj-logo').length && $('.wrap_intro_l_comic').length && $('.wrap_intro_r').length && $('.list_con_li').length
? 1
: $('.foot-detail:contains("漫画")').length && $('.dm_logo').length && $('.chapter-view').length ? 2 : 0),
title: '.comic_deCon>h1',
writer: '.comic_deCon_liO>li>a[href^="/author/"]',
intro: '.comic_deCon_d',
cover: '.comic_i_img>img',
chapter: '.list_con_li>li>a',
volume: '.zj_list_head>h2>em',
chapterTitle: '.head_title>h2',
iframe: (win) => $('<div class="nd3-images">').html(win.chapterImages.map((item, index, arr) => `<img data-src="${win.SinMH.getChapterImage(index + 1)}" /><p class="img_info">(${index + 1}/${arr.length})</p>`).join('')).appendTo(win.document.body),
content: '.nd3-images',
contentReplace: [
[/<img data-src/g, '<img src'],
],
},
{ // https://www.manhuagui.com/
siteName: '漫画柜',
url: '://www.manhuagui.com/comic/\\d+/$',
chapterUrl: '://www.manhuagui.com/comic/\\d+/\\d+.html',
title: '.book-title>h1',
writer: '.detail-list [href^="/author/"]',
intro: '#intro-all',
cover: '.book-cover>.hcover>img',
chapter: '.chapter-list a',
volume: 'h4>span',
chapterTitle: '.title h2',
content: (doc, res, request) => {
let info = res.responseText.match(/window\["\\x65\\x76\\x61\\x6c"\](.*?)<\/script>/)[1];
info = window.eval(info); // eslint-disable-line no-eval
info = info.match(/^SMH.imgData(.*?).preInit\(\);/)[1];
info = window.eval(info); // eslint-disable-line no-eval
const a = info.files.map((item, index, arr) => `<img src="https://us.hamreus.com${info.path}${item}?e=${info.sl.e}&m=${info.sl.m}" /><p class="img_info">(${index + 1}/${arr.length})</p>`);
return a.join('');
},
contentReplace: [
[/<img id="img_\d+" style=".*?" data-original="(.*?)" src=".*?">/g, '<img src="$1">'],
],
},
// 文学
{ // http://gj.zdic.net
siteName: '汉典古籍',
filter: () => (window.location.host === 'gj.zdic.net' ? ($('#ml_1').length ? 1 : 2) : 0),
title: '#shuye>h1',
intro: '#jj_2',
chapter: '.mls>li>a',
chapterTitle: '#snr1>h1',
content: '#snr2',
elementRemove: '.pagenav1',
chapterPrev: 'a:contains("上一篇")',
chapterNext: 'a:contains("下一篇")',
},
{ // https://www.99csw.com
siteName: '九九藏书网',
url: /99csw.com\/book\/\d+\/(index\.htm)?$/,
chapterUrl: /99csw.com\/book\/\d+\/\d+.htm/,
title: '#book_info>h2',
writer: 'h4:contains("作者")>a',
intro: '.intro',
cover: '#book_info>img',
chapter: '#dir a',
volume: '#dir>dt:nochild',
iframe: async (win) => {
while (win.content.showNext() !== false) {
await waitInMs(200);
}
},
content: '#content>div:visible',
// content: function (doc, res, request) {
// const content = [];
// const box = $('#content', doc).get(0);
// const star = 0; // ? 可能根本没用
// var e = CryptoJS.enc.Base64.parse($('meta[name="client"]', doc).attr('content')).toString(CryptoJS.enc.Utf8).split(/[A-Z]+%/);
// var j = 0;
// function r (a) {
// return a;
// }
// for (var i = 0; i < e.length; i++) {
// if (e[i] < 3) {
// content[e[i]] = r(box.childNodes[i + star]);
// j++;
// } else {
// content[e[i] - j] = r(box.childNodes[i + star]);
// j = j + 2;
// }
// }
// return content.map(i => i.outerHTML).join('<br>');
// }
},
{ // https://www.kanunu8.com/book2/11107/index.html
siteName: '努努书坊',
filter: () => (window.location.href.match(/kanunu8.com\/book2/) ? ($('.book').length ? 1 : 2) : 0),
title: '.book>h1',
writer: '.book>h2>a',
intro: '.description>p',
chapter: '.book>dl>dd>a',
volume: '.book>dl>dt',
content: '#Article>.text',
elementRemove: 'table,a',
},
{ // https://www.kanunu8.com
siteName: '努努书坊',
filter: () => (window.location.host === 'www.kanunu8.com' ? ($(['body>div:nth-child(1)>table:nth-child(10)>tbody>tr:nth-child(4)>td>table:nth-child(2)>tbody>tr>td>a', 'body>div>table>tbody>tr>td>table>tbody>tr>td>table:not(:has([class^="p"])) a'].join(',')).length ? 1 : 2) : 0),
title: 'h1>strong>font,h2>b',
writer: 'body > div:nth-child(1) > table:nth-child(10) > tbody > tr:nth-child(2) > td,body > div:nth-child(1) > table:nth-child(10) > tbody > tr > td:nth-child(2) > table:nth-child(2) > tbody > tr:nth-child(2) > td',
intro: '[align="left"]>[class^="p"]',
cover: 'img[height="160"]',
chapter: ['body>div:nth-child(1)>table:nth-child(10)>tbody>tr:nth-child(4)>td>table:nth-child(2)>tbody>tr>td>a', 'body>div>table>tbody>tr>td>table>tbody>tr>td>table:not(:has([class^="p"])) a'].join(','),
content: 'body > div:nth-child(1) > table:nth-child(5) > tbody > tr > td:nth-child(2) > p',
},
{ // http://www.my2852.com
siteName: '梦远书城',
filter: () => (window.location.href.match(/my2852?.com/) ? ($('a:contains("回目录")').length ? 2 : 1) : 0),
titleRegExp: /(.*?)[|_]/,
title: '.book>h1',
writer: 'b:contains("作者")',
intro: '.zhj,body > div:nth-child(4) > table > tbody > tr > td.td6 > div > table > tbody > tr > td:nth-child(1) > div > table > tbody > tr:nth-child(1) > td',
cover: 'img[alt="封面"]',
chapter: () => $('a[href]').toArray().filter((i) => $(i).attr('href').match(/^\d+\.htm/)).map((i) => ({ url: $(i).attr('href'), title: $(i).text().trim() })),
content: 'td:has(br)',
},
{ // https://www.tianyabooks.com
siteName: '天涯书库',
url: /tianyabooks\.com\/.*?\/$/,
chapterUrl: /tianyabooks\.com\/.*?\.html$/,
title: '.book>h1',
writer: 'h2>a[href^="/author/"]',
intro: '.description>p',
chapter: '.book>dl>dd>a',
volume: '.book>dl>dt',
chapterTitle: 'h1',
content: '[align="center"]+p',
},
{ // https://www.51xs.com/
siteName: '我要小说网',
url: '://www.51xs.com/.*?/index.html',
chapterUrl: '://www.51xs.com/.*?/\\d+.htm',
title: '[style="FONT-FAMILY: 宋体; FONT-SIZE:12pt"]',
writer: '[href="../index.html"]',
chapter: '[style="FONT-FAMILY: 宋体; FONT-SIZE:12pt"]+center a',
volume: '[bgcolor="#D9DDE8"]',
chapterTitle: '.tt2>center>b',
content: '.tt2',
},
// 正版
{ // https://www.qidian.com https://www.hongxiu.com https://www.readnovel.com https://www.xs8.cn
siteName: '起点中文网',
url: /(qidian.com|hongxiu.com|readnovel.com|xs8.cn)\/book\/\d+/,
chapterUrl: /(qidian.com|hongxiu.com|readnovel.com|xs8.cn)\/chapter/,
title: '#bookName',
writer: '.author',
intro: '#book-intro-detail',
cover: '#bookImg>img',
chapter: '.catalog-volume li>a',
vipChapter: '.catalog-volume:has(.vip) li>a',
volume: () => $('.volume-name').toArray().map((i) => i.childNodes[0]),
chapterTitle: '.title',
content: '.content',
elementRemove: '.review',
vip: {
// iframe: async (win) => { return $('.content',win.document).length},
popup: async () => { await waitFor(() => $('.content:visible').length, 5 * 1000); },
},
},
{ // https://www.ciweimao.com
siteName: '刺猬猫',
url: /:\/\/(www.)?ciweimao.com\/(book|chapter-list)\/\d+/,
chapterUrl: /:\/\/(www.)?ciweimao.com\/chapter\/\d+/,
infoPage: () => `https://www.ciweimao.com/book/${window.location.href.match(/\d+/)[0]}`,
title: 'h3',
writer: '.book-info [href*="reader/"]',
intro: '.book-intro-cnt>div:nth-child(1)',
cover: '.cover>img',
chapter: '.book-chapter-list a',
vipChapter: '.book-chapter-list a:has(.icon-lock),.book-chapter-list a:has(.icon-unlock)',
volume: '.book-chapter-box>.sub-tit',
chapterTitle: 'h3.chapter',
deal: async (chapter) => {
if (!unsafeWindow.CryptoJS) {
const result = await Promise.all([
'/resources/js/enjs.min.js',
'/resources/js/myEncrytExtend-min.js',
'/resources/js/jquery-plugins/jquery.base64.min.js',
].map((i) => `https://www.ciweimao.com${i}`).map((i) => xhr.sync(i, null, { cache: true })));
for (const res of result) unsafeWindow.eval(res.responseText);
}
const chapterId = chapter.url.split('/').slice(-1)[0];
const res1 = await new Promise((resolve, reject) => {
xhr.add({
chapter,
method: 'POST',
url: `${window.location.origin}/chapter/ajax_get_session_code`,
headers: {
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
Referer: chapter.url,
'X-Requested-With': 'XMLHttpRequest',
},
data: `chapter_id=${chapterId}`,
responseType: 'json',
onload(res) {
resolve(res);
},
}, null, 0, true);
});
const accessKey = res1.response.chapter_access_key;
const content = await new Promise((resolve, reject) => {
xhr.add({
chapter,
method: 'POST',
url: `${window.location.origin}/chapter/get_book_chapter_detail_info`,
headers: {
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
Referer: chapter.url,
'X-Requested-With': 'XMLHttpRequest',
},
data: `chapter_id=${chapterId}&chapter_access_key=${accessKey}`,
// responseType: 'json',
onload(res, request) {
try {
const json = JSON.parse(res.responseText);
const content = unsafeWindow.$.myDecrypt({
content: json.chapter_content,
keys: json.encryt_keys,
accessKey,
});
resolve(content);
} catch (error) {
console.error(error);
resolve('');
}
},
}, null, 0, true);
});
return content;
},
elementRemove: 'span',
chapterPrev: '#J_BtnPagePrev',
chapterNext: '#J_BtnPageNext',
thread: 1,
vip: {
deal: null,
iframe: async (win) => {
win.getDataUrl = async (img) => {
const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d');
canvas.width = img.width;
canvas.height = img.height;
ctx.drawImage(img, 0, 0);
const url = canvas.toDataURL('image/jpeg', 0.5);
img.src = url;
// return new Promise((resolve, reject) => {
// canvas.toBlob(function (blob) {
// const url = URL.createObjectURL(blob);
// img.src = url;
// resolve();
// });
// });
};
await waitFor(() => $('#J_BookImage', win.document).css('background-image').match(/^url\("?(.*?)"?\)/));
let src = $('#J_BookImage', win.document).css('background-image').match(/^url\("?(.*?)"?\)/)[1];
await new Promise((resolve, reject) => {
$('#realBookImage', win.document).one('load', async () => {
src = await win.getDataUrl($('#realBookImage', win.document).get(0));
window.history.back();
resolve();
}).attr('src', src);
});
},
content: '#J_BookImage',
elementRemove: 'i',
},
},
{ // https://www.shubl.com/
siteName: '书耽',
url: '://www.shubl.com/book/book_detail/\\d+',
chapterUrl: '://www.shubl.com/chapter/book_chapter_detail/\\d+',
title: '.book-title>span',
writer: '.right>.box>.user-info .username',
intro: '.book-brief',
cover: '.book-img',
chapter: '#chapter_list .chapter_item>a',
vipChapter: '#chapter_list .chapter_item:has(.lock)>a',
chapterTitle: '.article-title',
deal: async (chapter) => Rule.special.find((i) => i.siteName === '刺猬猫').deal(chapter),
elementRemove: 'span',
chapterPrev: '#J_BtnPagePrev',
chapterNext: '#J_BtnPageNext',
thread: 1,
},
{ // http://chuangshi.qq.com http://yunqi.qq.com
siteName: '创世中文网',
url: /(chuangshi|yunqi).qq.com\/bk\/.*?-l.html/,
chapterUrl: /(chuangshi|yunqi).qq.com\/bk\/.*?-r-\d+.html/,
infoPage: '.title>a,.bookNav>a:nth-child(4)',
title: '.title>a>b',
writer: '.au_name a',
intro: '.info',
cover: '.bookcover>img',
chapter: 'div.list>ul>li>a',
vipChapter: 'div.list:has(span.f900)>ul>li>a',
volume: '.juan_height',
deal: async (chapter) => {
const content = await new Promise((resolve, reject) => {
xhr.add({
chapter,
url: `${window.location.origin}/index.php/Bookreader/${$('.title a:eq(0)').attr('href').match(/\/(\d+).html/)[1]}/${chapter.url.match(/-(\d+).html/)[1]}`,
method: 'POST',
data: 'lang=zhs',
headers: {
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
Referer: chapter.url,
'X-Requested-With': 'XMLHttpRequest',
},
onload(res, request) {
try {
const json = JSON.parse(res.responseText);
let content = json.Content;
const base = 30;
const arrStr = [];
const arrText = content.split('\\');
for (let i = 1, len = arrText.length; i < len; i++) {
arrStr.push(String.fromCharCode(parseInt(arrText[i], base)));
}
let html = arrStr.join('');
if ($('<div>').html(html).text().match(/url\((https?:\/\/yuewen-skythunder-\d+.*?\.ttf)\)/)) {
if (!fontLib) fontLib = JSON.parse(GM_getResourceText('fontLib')).reverse();
const font = $('<div>').html(html).text().match(/url\((https?:\/\/yuewen-skythunder-\d+.*?\.ttf)\)/)[1];
opentype.load(font, (err, font) => {
if (err) resolve('');
const obj = {};
const undefinedFont = [];
for (const i in font.glyphs.glyphs) {
const data = font.glyphs.glyphs[i].path.toPathData();
const key = fontLib.find((i) => i.path === data);
if (key) obj[font.glyphs.glyphs[i].unicode] = key.unicode;
if (!key) undefinedFont.push(data);
}
if (undefinedFont.length) console.error('未确定字符', undefinedFont);
html = html.replace(/&#(\d+);/g, (matched, m1) => (m1 in obj ? obj[m1] : matched));
content = $('.bookreadercontent', html).html();
resolve(content);
});
} else {
content = $('.bookreadercontent', html).html();
resolve(content);
}
} catch (error) {
console.error(error);
resolve('');
}
},
}, null, 0, true);
});
return content;
},
},
{ // http://dushu.qq.com 待测试:http://book.qq.com
siteName: 'QQ阅读',
url: /(book|dushu).qq.com\/intro.html\?bid=\d+/,
chapterUrl: /(book|dushu).qq.com\/read.html\?bid=\d+&cid=\d+/,
title: 'h3>a',
writer: '.w_au>a',
intro: '.book_intro',
cover: '.bookBox>a>img',
chapter: '#chapterList>div>ol>li>a',
vipChapter: '#chapterList>div>ol>li:not(:has(span.free))>a',
deal: async (chapter) => {
const content = await new Promise((resolve, reject) => {
xhr.add({
chapter,
url: `${window.location.origin}/read/${unsafeWindow.bid}/${chapter.url.match(/cid=(\d+)/)[1]}`,
method: 'POST',
data: 'lang=zhs',
headers: {
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
Referer: chapter.url,
'X-Requested-With': 'XMLHttpRequest',
},
onload(res, request) {
try {
const json = JSON.parse(res.responseText);
let content = json.Content;
content = $('.bookreadercontent', content).html();
resolve(content);
} catch (error) {
console.error(error);
resolve('');
}
},
}, null, 0, true);
});
return content;
},
},
{ // https://www.webnovel.com
siteName: '起点国际',
url: /webnovel.com\/book\/\d+(#contents)?$/,
chapterUrl: /webnovel.com\/book\/\d+\/\d+/,
title: 'h2',
writer: 'address span',
intro: '#about .g_txt_over',
cover: '.det-info .g_thumb',
chapter: '.content-list a',
volume: '.volume-item>h4',
content: '.cha-words',
elementRemove: 'pirate',
},
{ // https://book.tianya.cn/
siteName: '天涯文学',
url: /book.tianya.cn\/html2\/dir.aspx\?bookid=\d+/,
chapterUrl: /book.tianya.cn\/chapter-\d+-\d+/,
infoPage: () => `https://book.tianya.cn/book/${window.location.href.split('/').slice(-1)[0].match(/\d+/)[0]}.aspx`,
title: '.book-name>a',
writer: '.bd>p>span',
intro: '#brief_intro',
cover: '.lft-pic>a>img',
chapter: 'ul.dit-list>li>a',
vipChapter: 'ul.dit-list>li:not(:has(.free))>a',
deal: async (chapter) => {
const result = await new Promise((resolve, reject) => {
const urlArr = chapter.url.split('-');
xhr.add({
chapter,
url: 'https://app3g.tianya.cn/webservice/web/read_chapter.jsp',
method: 'POST',
data: `bookid=${urlArr[1]}&chapterid=${urlArr[2]}`,
headers: {
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
Referer: 'https://app3g.tianya.cn/webservice/web/proxy.html',
'X-Requested-With': 'XMLHttpRequest',
},
onload(res, request) {
try {
const json = JSON.parse(res.responseText);
const title = json.data.curChapterName;
const content = json.data.chapterContent;
resolve({ title, content });
} catch (error) {
console.error(error);
resolve('');
}
},
}, null, 0, true);
});
return result;
},
},
{ // http://www.3gsc.com.cn
siteName: '3G书城',
url: /3gsc\.com\.cn\/bookreader\/\d+/,
chapterUrl: /3gsc.com.cn\/bookcon\//,
infoPage: '[href^="/book/"]',
title: 'h1.RecArticle',
writer: '.author',
intro: '.RecReview',
cover: '.RecBook img[onerror]',
chapter: '.menu-area>p>a',
vipChapter: '.menu-area>p>a:has(span.vip)',
volume: '.menu-area>h2',
chapterTitle: 'h1',
content: '.menu-area',
},
{ // http://www.zongheng.com/
siteName: '纵横',
url: /www\.zongheng\.com\/detail\/\d+/,
chapterUrl: /(read|book)\.zongheng\.com\/chapter\/\d+\/\d+\.html/,
title: '.book-info--title>span',
writer: '.author-info--name',
intro: '.detail-work-info--introduction',
cover: '.book-info--coverImage-img',
chapter: '.chapter-list--item',
vipChapter: '.chapter-list--item:has(.chapter-list--item-vip)',
chapterTitle: '.title_txtbox',
content: '.content',
elementRemove: '',
},
{ // http://huayu.zongheng.com/
siteName: '纵横女生网',
url: /huayu.zongheng.com\/showchapter\/\d+.html/,
chapterUrl: /(read|book)\.zongheng\.com\/chapter\/\d+\/\d+\.html/,
infoPage: '[class$="crumb"]>a:nth-child(3)',
title: '.book-name',
writer: '.au-name',
intro: '.book-dec>p',
cover: '.book-img>img',
chapter: '.chapter-list a',
vipChapter: '.chapter-list .vip>a',
volume: () => $('.volume').toArray().map((i) => i.childNodes[6]),
chapterTitle: '.title_txtbox',
content: '.content',
elementRemove: '',
},
{ // http://naodong.zongheng.com/
siteName: '纵横脑洞',
url: /naodong\.zongheng\.com\/detail\/\d+/,
chapterUrl: /(read|book)\.zongheng\.com\/chapter\/\d+\/\d+\.html/,
title: '.bookname',
writer: '.au-name',
intro: '.intro-tip-p',
cover: '.book_img>img',
chapter: '.cata-item a',
vipChapter: '.cata-item:has(.cata-item-vip) a',
chapterTitle: '.title_txtbox',
content: '.content',
elementRemove: '',
},
{ // https://www.17k.com/
siteName: '17K',
url: /www.17k.com\/list\/\d+.html/,
chapterUrl: /www.17k.com\/chapter\/\d+\/\d+.html/,
infoPage: '.infoPath a:nth-child(4)',
title: '.Info>h1',
writer: '.AuthorInfo .name',
intro: '.intro>a',
cover: '.cover img',
chapter: 'dl.Volume>dd>a',
vipChapter: 'dl.Volume>dd>a:has(.vip)',
volume: '.Volume>dt>.tit',
chapterTitle: 'h1',
content: '.p',
elementRemove: '.copy,.qrcode',
},
{ // https://www.8kana.com/
siteName: '不可能的世界',
url: /www.8kana.com\/book\/\d+(.html)?/,
chapterUrl: /www.8kana.com\/read\/\d+.html/,
title: 'h2.left',
writer: '.authorName',
intro: '.bookIntroduction',
cover: '.bookContainImgBox img',
chapter: '#informList li.nolooking>a',
vipChapter: '#informList li.nolooking>a:has(.chapter_con_VIP)',
volume: '[flag="volumes"] span',
chapterTitle: 'h2',
content: '.myContent',
elementRemove: '[id="-2"]',
},
{ // https://www.heiyan.com https://www.ruochu.com
siteName: '黑岩',
url: /www.(heiyan|ruochu).com\/chapter\//,
chapterUrl: /www.(heiyan|ruochu).com\/book\/\d+\/\d+/,
infoPage: '.pic [href*="/book/"],.breadcrumb>a:nth-child(5)',
title: 'h1[style]',
writer: '.name>strong',
intro: '.summary>.note',
cover: '.book-cover',
chapter: 'div.bd>ul>li>a',
vipChapter: 'div.bd>ul>li>a.isvip',
volume: '.chapter-list>.hd>h2',
deal: async (chapter) => {
const content = await new Promise((resolve, reject) => {
xhr.add({
chapter,
url: `http://${window.location.host.replace('www.', 'a.')}/ajax/chapter/content/${chapter.url.replace(/.*\//, '')}`,
onload(res, request) {
try {
const json = JSON.parse(res.responseText);
const { title } = json.chapter;
const content = json.chapter.htmlContent;
resolve({ title, content });
} catch (error) {
console.error(error);
resolve('');
}
},
}, null, 0, true);
});
return content;
},
},
{ // https://b.faloo.com
siteName: '飞卢',
url: /b.faloo.com\/\d+.html/,
chapterUrl: /b.faloo.com\/\d+_\d+.html/,
title: '#novelName',
writer: '#novelName+a',
intro: '.T-L-T-C-Box1',
cover: '.imgcss',
chapter: '#mulu .DivTable .DivTd>a',
vipChapter: '#mulu .DivVip~.DivTable .DivTd>a',
volume: '.C-Fo-Z-ML-TitleBox>h3',
chapterTitle: '.c_l_title',
content: '.noveContent',
elementRemove: 'p:has(a,b,font)',
vip: {
content: (doc, res, request) => {
const doc1 = new window.DOMParser().parseFromString(res.responseText, 'text/html');
const func = $('script:contains("image_do3")', doc1).text();
/* eslint-disable camelcase */
if (!unsafeWindow.image_do3) {
unsafeWindow.image_do3 = function (num, o, id, n, en, t, k, u, time, fontsize, fontcolor, chaptertype, font_family_type) {
const type = 1;
let domain = '//read.faloo.com/';
if (chaptertype === 0) { domain = '//read6.faloo.com/'; }
if (type === 2) { domain = '//read2.faloo.com/'; }
if (typeof (font_family_type) === 'undefined' || font_family_type == null) {
font_family_type = 0;
}
let url = `${domain}Page4VipImage.aspx?num=${num}&o=${o}&id=${id}&n=${n}&ct=${chaptertype}&en=${en}&t=${t}&font_size=${fontsize}&font_color=${fontcolor}&FontFamilyType=${font_family_type}&u=${u}&time=${time}&k=${k}`;
url = encodeURI(url);
return url;
};
}
/* eslint-enable camelcase */
const image = window.eval(`window.${func}`); // eslint-disable-line no-eval
const elem = $('.noveContent', doc1);
elem.find('.con_img').replaceWith(`<img src="${image}">`);
return elem.html();
},
},
},
{ // https://www.jjwxc.net // TODO vip自定义字体
siteName: '晋江文学城',
filter: () => {
if (window.location.href.match(/www.jjwxc.net\/onebook.php\?novelid=\d+$/)) {
$('[id^="vip_"]').toArray().forEach((i) => {
i.href = i.rel;
i.target = '_blank';
});
return 1;
} if (window.location.href.match(/www.jjwxc.net\/onebook.php\?novelid=\d+&chapterid=\d+/)) {
return 2;
}
return 0;
},
title: '[itemprop="name"]',
writer: '[itemprop="author"]',
intro: '[itemprop="description"]',
cover: '[itemprop="image"]',
chapter: '[itemprop="url"][href]',
vipChapter: '#oneboolt>tbody>tr>td>span>div>a[id^="vip_"]',
volume: '.volumnfont',
chapterTitle: 'h2',
content: '.noveltext',
elementRemove: 'div',
// vip
// http://static.jjwxc.net/tmp/fonts/jjwxcfont_00147.ttf
// http://static.jjwxc.net/tmp/fonts/jjwxcfont_000bl.ttf
// http://static.jjwxc.net/tmp/fonts/jjwxcfont_00bmn.ttf
},
{ // https://www.xxsy.net
siteName: '潇湘书院',
url: /www.xxsy.net\/info\/\d+.html/,
chapterUrl: /www.xxsy.net\/chapter\/\d+.html/,
title: '.title h1',
writer: '.title a[href^="/authorcenter/"]',
intro: '.introcontent',
cover: '.bookprofile>dt>img',
chapter: '.catalog-list>li>a',
vipChapter: '.catalog-list>li.vip>a',
volume: () => $('.catalog-main>dt').toArray().map((i) => i.childNodes[2]),
chapterTitle: '.chapter-title',
content: '.chapter-main',
},
{ // http://www.zhulang.com http://www.xxs8.com/
siteName: '逐浪',
url: /book.(zhulang|xxs8).com\/\d+\/$/,
chapterUrl: /book.(zhulang|xxs8).com\/\d+\/\d+.html/,
infoPage: 'strong>a,.textinfo>a',
title: '.crumbs>strong',
writer: '.cover-tit>h2>span>a',
intro: '#book-summary',
cover: '.cover-box-left>img',
chapter: '.chapter-list>ul>li>a',
vipChapter: '.chapter-list>ul>li>a:has(span)',
volume: '.catalog-tit>h2',
chapterTitle: 'h2>span',
content: '#read-content',
elementRemove: 'h2,div,style,p:has(cite)',
},
{ // https://www.kanshu.com
siteName: '看书网',
url: /www.kanshu.com\/artinfo\/\d+.html/,
chapterUrl: /www.kanshu.com\/files\/article\/html\/\d+\/\d+.html/,
title: '.author',
intro: '.detailInfo',
cover: '.bookImg',
chapter: '.list>a',
vipChapter: '.list>a.isvip',
chapterTitle: '.contentBox .title',
content: '.contentBox .tempcontentBox',
},
{ // http://vip.book.sina.com.cn
siteName: '微博读书-书城',
url: /vip.book.sina.com.cn\/weibobook\/book\/\d+.html/,
chapterUrl: /vip.book.sina.com.cn\/weibobook\/vipc.php\?bid=\d+&cid=\d+/,
title: 'h1.book_name',
writer: '.authorName',
intro: '.info_txt',
cover: '.book_img>img',
chapter: '.chapter>span>a',
vipChapter: '.chapter>span:has(i)>a',
chapterTitle: '.sr-play-box-scroll-t-path>span',
content: (doc, res, request) => window.eval(res.responseText.match(/var chapterContent = (".*")/)[1]), // eslint-disable-line no-eval
},
{ // http://www.lcread.com
siteName: '连城读书',
url: /www.lcread.com\/bookpage\/\d+\/index.html/,
chapterUrl: /www.lcread.com\/bookpage\/\d+\/\d+rc.html/,
title: '.bri>table>tbody>tr>td>h1',
writer: '[href^="http://my.lc1001.com/book/q?u="]',
intro: '.bri2',
cover: '.brc>img',
chapter: '#abl4>table>tbody>tr>td>a',
vipChapter: '#abl4>table>tbody>tr>td>a[href^="http://my.lc1001.com/vipchapters"]',
volume: '#cul>.dsh',
chapterTitle: 'h2',
content: '#ccon',
},
{ // https://www.motie.com
siteName: '磨铁中文网',
url: /www.motie.com\/book\/\d+/,
chapterUrl: /www.motie.com\/chapter\/\d+\/\d+/,
title: '.title>.name',
writer: '.title>.name+a',
intro: '.brief_text',
cover: '.pic>span>img',
chapter: '.catebg a',
vipChapter: '.catebg a:has([alt="vip"])',
volume: '.cate-tit>h2',
deal: async (chapter) => {
const content = await new Promise((resolve, reject) => {
xhr.add({
chapter,
url: `https://app2.motie.com/pc/chapter/${chapter.url.split('/')[5]}`,
headers: {
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
Referer: chapter.url,
'X-Requested-With': 'XMLHttpRequest',
},
onload(res, request) {
try {
const json = JSON.parse(res.responseText);
const title = json.data.name;
const { content } = json.data;
resolve({ title, content });
} catch (error) {
console.error(error);
resolve('');
}