forked from XIU2/UserScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAutopage.user.js
More file actions
1219 lines (1169 loc) · 52.4 KB
/
Copy pathAutopage.user.js
File metadata and controls
1219 lines (1169 loc) · 52.4 KB
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
// ==UserScript==
// @name 自动无缝翻页
// @version 1.4.8
// @author X.I.U
// @description 自动无缝翻页,目前支持:所有「Discuz!、Flarum」论坛、百度、豆瓣、微博、千图网、3DM、游侠网、游民星空、Steam 创意工坊、423Down、APPHOT、不死鸟、亿破姐、小众软件、微当下载、落尘之木、异次元软件、老殁殁漂遥、异星软件空间、古风漫画网、RARBG、PubMed、AfreecaTV、GreasyFork、AlphaCoders、FitGirl Repacks...
// @match *://*/*
// @connect www.gamersky.com
// @icon https://i.loli.net/2021/03/07/rdijeYm83pznxWq.png
// @grant GM_xmlhttpRequest
// @grant GM_registerMenuCommand
// @grant GM_openInTab
// @grant GM_getValue
// @grant GM_setValue
// @license GPL-3.0 License
// @run-at document-end
// @namespace https://github.com/XIU2/UserScript
// @supportURL https://github.com/XIU2/UserScript
// @homepageURL https://github.com/XIU2/UserScript
// ==/UserScript==
(function() {
'use strict';
var webType, curSite = {SiteTypeID: 0};
// 目前支持的网站
const websiteList = ['www.baidu.com', 'movie.douban.com', 'weibo.com', 'www.58pic.com',
'www.3dmgame.com', 'www.ali213.net', 'gl.ali213.net', 'www.gamersky.com', 'steamcommunity.com',
'www.423down.com', 'apphot.cc', 'iao.su', 'www.ypojie.com', 'www.appinn.com', 'www.weidown.com', 'www.luochenzhimu.com', 'www.iplaysoft.com', 'www.mpyit.com', 'www.yxssp.com',
'www.gufengmh8.com',
'rarbgprx.org', 'pubmed.ncbi.nlm.nih.gov', 'www.afreecatv.com', 'greasyfork.org',
'art.alphacoders.com', 'wall.alphacoders.com', 'avatars.alphacoders.com', 'mobile.alphacoders.com',
'fitgirl-repacks.site'];
if (GM_getValue('menu_disable') == null){GM_setValue('menu_disable', [])};
if (GM_getValue('menu_discuz_thread_page') == null){GM_setValue('menu_discuz_thread_page', true)};
// 注册脚本菜单
if (menu_disable('check')) { // 当前网站是否已存在禁用列表中
GM_registerMenuCommand('❎ 已禁用 (点击对当前网站启用)', function(){menu_disable('del')});
return
} else {
if (websiteList.indexOf(location.host) > -1) {
webType = 1 // 其他网站
} else if (document.querySelector('meta[name="author"][content*="Discuz!"], meta[name="generator"][content*="Discuz!"]') || document.getElementById('ft') && document.getElementById('ft').textContent.indexOf('Discuz!') > -1) {
webType = 2 // 所有 Discuz! 论坛
} else if (document.getElementById('flarum-loading')) {
webType = 3 // 所有 Flarum 论坛
} else {
GM_registerMenuCommand('❌ 当前网站暂不支持 [点击申请支持]', function () {window.GM_openInTab('https://github.com/XIU2/UserScript#xiu2userscript', {active: true,insert: true,setParent: true});window.GM_openInTab('https://greasyfork.org/zh-CN/scripts/419215/feedback', {active: true,insert: true,setParent: true});});
return
}
GM_registerMenuCommand('✅ 已启用 (点击对当前网站禁用)', function(){menu_disable('add')});
if (webType === 2) {
GM_registerMenuCommand(`${GM_getValue('menu_discuz_thread_page')?'✅':'❎'} 帖子内自动翻页 (仅 Discuz! 论坛)`, function(){menu_switch(GM_getValue('menu_discuz_thread_page'), 'menu_discuz_thread_page', 'Discuz! 论坛帖子内翻页')});
}
}
GM_registerMenuCommand('💬 反馈 & 欢迎申请支持', function () {window.GM_openInTab('https://github.com/XIU2/UserScript#xiu2userscript', {active: true,insert: true,setParent: true});window.GM_openInTab('https://greasyfork.org/zh-CN/scripts/419215/feedback', {active: true,insert: true,setParent: true});});
/*
自动翻页规则
type:
1 = 脚本实现自动无缝翻页
2 = 网站自带了自动无缝翻页功能,只需要点击下一页按钮即可
nextText: 按钮文本,只有按钮文本为该文本时才会点击按钮加载下一页,避免一瞬间加载太多次下一页
intervals: 点击间隔时间,对于没有按钮文字变化的按钮,可以手动指定间隔时间,单位:ms
3 = 依靠元素距离可视区域底部的距离来触发翻页
4 = 针对部分简单动态加载的网站
HT_insert:
1 = 插入该元素本身的前面;
2 = 插入该元素当中,第一个子元素前面;
3 = 插入该元素当中,最后一个子元素后面;
4 = 插入该元素本身的后面;
scrollDelta:数值越大,滚动条触发点越靠上(越早开始翻页),一般是访问网页速度越慢,该值就需要越大(如果 Type = 3,则相反)
function:
before = 插入前执行函数;
after = 插入后执行函数;
parameter = 参数
*/
let DBSite = {
discuz_forum: {
SiteTypeID: 0,
pager: {
type: 2,
nextLink: '#autopbn',
nextText: '下一页 »',
scrollDelta: 1000
}
},
discuz_thread: {
SiteTypeID: 0,
pager: {
type: 1,
nextLink: '//a[@class="nxt"][@href]',
pageElement: 'css;div#postlist > div[id^="post_"]',
HT_insert: ['css;div#postlist', 3],
replaceE: 'css;div.pg',
scrollDelta: 1000
}
},
discuz_search: {
SiteTypeID: 0,
pager: {
type: 1,
nextLink: '//a[@class="nxt"][@href]',
pageElement: 'css;div#threadlist > ul',
HT_insert: ['css;div#threadlist', 3],
replaceE: 'css;div.pg',
scrollDelta: 1000
}
},
discuz_guide: {
SiteTypeID: 0,
pager: {
type: 1,
nextLink: '//a[@class="nxt"][@href]',
pageElement: 'css;div#threadlist div.bm_c table > tbody',
HT_insert: ['css;div#threadlist div.bm_c table', 3],
replaceE: 'css;div.pg',
scrollDelta: 1000
}
},
discuz_youspace: {
SiteTypeID: 0,
pager: {
type: 1,
nextLink: '//a[@class="nxt"][@href]',
pageElement: 'css;tbody > tr:not(.th)',
HT_insert: ['css;tbody', 3],
replaceE: 'css;div.pg',
scrollDelta: 1000
}
},
discuz_collection: {
SiteTypeID: 0,
pager: {
type: 1,
nextLink: '//a[@class="nxt"][@href]',
pageElement: 'css;div#ct div.bm_c table > tbody',
HT_insert: ['css;div#ct div.bm_c table', 3],
replaceE: 'css;div.pg',
scrollDelta: 1000
}
},
flarum: {
SiteTypeID: 0,
pager: {
type: 2,
nextLink: '.DiscussionList-loadMore > button[title]',
scrollDelta: 1000
}
},
dux: {
SiteTypeID: 0,
pager: {
type: 1,
nextLink: '//li[@class="next-page"]/a[@href]',
pageElement: 'css;.content > article',
HT_insert: ['css;.content > .pagination', 1],
replaceE: 'css;.content > .pagination',
scrollDelta: 1000
},
function: {
before: dux_beforeFunction
}
},
baidu: {
SiteTypeID: 0,
pager: {
type: 1,
nextLink: '//div[@id="page"]//a[contains(text(),"下一页")][@href]',
pageElement: 'css;#content_left > *',
HT_insert: ['css;#content_left', 3],
replaceE: 'css;#page',
scrollDelta: 1200
}
},
douban_subject_comments: {
SiteTypeID: 0,
pager: {
type: 1,
nextLink: '//a[@class="next"][@href]',
pageElement: 'css;#comments > .comment-item',
HT_insert: ['css;#paginator', 1],
replaceE: 'css;#paginator',
scrollDelta: 1000
}
},
douban_subject_reviews: {
SiteTypeID: 0,
pager: {
type: 1,
nextLink: '//link[@rel="next"][@href]',
pageElement: 'css;.review-list > div',
HT_insert: ['css;.review-list', 3],
replaceE: 'css;.paginator',
scrollDelta: 1000
}
},
douban_subject_episode: {
SiteTypeID: 0,
pager: {
type: 1,
nextLink: '//link[@rel="next"][@href]',
pageElement: 'css;#comments > div',
HT_insert: ['css;#comments', 3],
replaceE: 'css;.paginator',
scrollDelta: 1000
}
},
weibo_comment: {
SiteTypeID: 0,
pager: {
type: 2,
nextLink: 'a[action-type="click_more_comment"]',
nextText: '查看更多c',
scrollDelta: 1000
}
},
_58pic: {
SiteTypeID: 0,
pager: {
type: 1,
nextLink: '//div[contains(@class,"page-box")]//a[text()="下一页"][@href]',
pageElement: 'css;.pic-box > .qtw-card',
HT_insert: ['css;.pic-box', 3],
replaceE: 'css;.page-box',
scrollDelta: 2000
},
function: {
before: _58pic_beforeFunction
}
},
_58pic_c: {
SiteTypeID: 0,
pager: {
type: 1,
nextLink: '//div[contains(@class,"page-box")]//a[text()="下一页"][@href]',
pageElement: 'css;.list-box > .qtw-card',
HT_insert: ['css;.list-box', 3],
replaceE: 'css;.page-box',
scrollDelta: 4000
},
function: {
before: _58pic_beforeFunction
}
},
_3dmgame: {
SiteTypeID: 0,
pager: {
type: 3,
nextLink: '//li[@class="next"]/a[@href]',
pageElement: 'css;.news_warp_center > *',
HT_insert: ['css;.news_warp_center', 3],
replaceE: 'css;.pagewrap',
scrollElement: '.pagewrap',
scrollDelta: 400
}
},
ali213_www: {
SiteTypeID: 0,
pager: {
type: 3,
nextLink: '//a[@id="after_this_page"][@href]',
pageElement: 'css;#Content >*:not(.news_ding):not(.page_fenye)',
HT_insert: ['css;.page_fenye', 1],
replaceE: 'css;.page_fenye',
scrollElement: '.page_fenye',
scrollDelta: 400
}
},
ali213_gl: {
SiteTypeID: 0,
pager: {
type: 3,
nextLink: '//a[@class="next n"][@href]',
pageElement: 'css;.c-detail >*',
HT_insert: ['css;.c-detail', 3],
replaceE: 'css;.page_fenye',
scrollElement: '.page_fenye',
scrollDelta: 400
}
},
gamersky_ent: {
SiteTypeID: 0,
pager: {
type: 3,
nextLink: '//div[@class="page_css"]/a[text()="下一页"][@href]',
pageElement: 'css;.Mid2L_con > *:not(.gs_nc_editor):not(.pagecss):not(.page_css):not(.gs_ccs_solve):not(.post_ding)',
HT_insert: ['css;.page_css', 1],
replaceE: 'css;.page_css',
scrollElement: '.page_css',
scrollDelta: 100
}
},
gamersky_gl: {
SiteTypeID: 0,
pager: {
type: 3,
nextLink: '//div[@class="page_css"]/a[text()="下一页"][@href]',
pageElement: 'css;.Mid2L_con > *:not(.gs_nc_editor):not(.pagecss):not(.gs_ccs_solve):not(.post_ding)',
HT_insert: ['css;.gs_nc_editor', 1],
replaceE: 'css;.page_css',
scrollElement: '.pagecss',
scrollDelta: -1000
},
function: {
before: gamersky_gl_beforeFunction
}
},
steamcommunity: {
SiteTypeID: 0,
pager: {
type: 1,
nextLink: '//a[@class="pagebtn"][last()][@href]',
pageElement: 'css;.workshopBrowseItems > *',
HT_insert: ['css;.workshopBrowseItems', 3],
replaceE: 'css;.workshopBrowsePaging',
scrollDelta: 1500
}
},
_423down: {
SiteTypeID: 0,
pager: {
type: 1,
nextLink: '//div[@class="paging"]//a[contains(text(),"下一页")][@href]',
pageElement: 'css;div.content-wrap ul.excerpt > li',
HT_insert: ['css;div.content-wrap ul.excerpt', 3],
replaceE: 'css;div.paging',
scrollDelta: 1500
}
},
iao_su: {
SiteTypeID: 0,
pager: {
type: 1,
nextLink: '//li[@class="btn btn-primary next"]//a[@href]',
pageElement: 'css;#index > article, #archive > article',
HT_insert: ['css;ol.page-navigator', 1],
replaceE: 'css;ol.page-navigator',
scrollDelta: 800
},
function: {
before: iao_su_beforeFunction
}
},
appinn: {
SiteTypeID: 0,
pager: {
type: 1,
nextLink: '//a[@class="next page-numbers"][@href]',
pageElement: 'css;section#latest-posts > article',
HT_insert: ['css;nav.navigation.pagination', 1],
replaceE: 'css;div.nav-links',
scrollDelta: 1500
}
},
weidown: {
SiteTypeID: 0,
pager: {
type: 1,
nextLink: '//a[@class="nextpage"][@href]',
pageElement: 'css;.articleWrapper > .itemArticle, .articleWrapper > .richTextItem.search',
HT_insert: ['css;.articleWrapper', 3],
replaceE: 'css;#pageGroup',
scrollDelta: 1500
}
},
weidown_search: {
SiteTypeID: 0,
pager: {
type: 1,
nextLink: '//a[@class="nextpage"][@href]',
pageElement: 'css;.articleListWrapper > .richTextItem.search',
HT_insert: ['css;#pageGroup', 1],
replaceE: 'css;#pageGroup',
scrollDelta: 700
}
},
weidown_special: {
SiteTypeID: 0,
pager: {
type: 1,
nextLink: '//a[@class="nextpage"][@href]',
pageElement: 'css;.special > .item',
HT_insert: ['css;.special', 3],
replaceE: 'css;#pageGroup',
scrollDelta: 700
}
},
iplaysoft_postslist: {
SiteTypeID: 0,
pager: {
type: 1,
nextLink: '//div[@class="pagenavi"]//a[@title="下一页"][@href]',
pageElement: 'css;#postlist > div.entry',
HT_insert: ['css;#postlist > .pagenavi-button', 1],
replaceE: 'css;.pagenavi-button, .pagenavi',
scrollDelta: 1200
},
function: {
before: iplaysoft_postslist_beforeFunction
}
},
iplaysoft_postcomments: {
SiteTypeID: 0,
pager: {
type: 2,
nextLink: '#loadHistoryComments',
nextText: '展开后面',
scrollDelta: 1200
}
},
mpyit: {
SiteTypeID: 0,
pager: {
type: 1,
nextLink: '//a[@class="page-numbers"][@title="下一页"][@href]',
pageElement: 'css;#post > div[id^="post-"]',
HT_insert: ['css;#post > #pagenavi', 1],
replaceE: 'css;#post > #pagenavi',
scrollDelta: 1700
}
},
mpyit_category: {
SiteTypeID: 0,
pager: {
type: 1,
nextLink: '//a[@class="page-numbers"][@title="下一页"][@href]',
pageElement: 'css;#content > div[class^="entry_box"]',
HT_insert: ['css;#content > #pagenavi', 1],
replaceE: 'css;#content > #pagenavi',
scrollDelta: 1700
}
},
yxssp: {
SiteTypeID: 0,
pager: {
type: 1,
nextLink: '//div[@class="page-nav td-pb-padding-side"]/a[last()][@href]',
pageElement: 'css;.td-modules-container.td-module-number4 > div',
HT_insert: ['css;.td-modules-container.td-module-number4', 3],
replaceE: 'css;.page-nav.td-pb-padding-side',
scrollDelta: 1000
}
},
gufengmh8: {
SiteTypeID: 0,
pager: {
type: 4,
pageElement: 'css;body > script:first-child',
HT_insert: ['css;#images', 3],
intervals: 5000,
functionNext: gufengmh8_functionNext,
functionAdd: gufengmh8_functionAdd,
scrollDelta: 2333
}
},
rarbgprx: {
SiteTypeID: 0,
pager: {
type: 1,
nextLink: '(//a[@title="next page"])[1][@href]',
pageElement: 'css;table.lista2t tr.lista2',
HT_insert: ['css;table.lista2t > tbody', 3],
replaceE: 'css;#pager_links',
scrollDelta: 900
}
},
pubmed_postslist: {
SiteTypeID: 0,
pager: {
type: 2,
nextLink: 'button.load-button.next-page',
nextText: 'Show more',
scrollDelta: 1500
}
},
afreecatv: {
SiteTypeID: 0,
pager: {
type: 2,
nextLink: '.btn-more > button',
intervals: 2000,
scrollDelta: 1000
}
},
greasyfork: {
SiteTypeID: 0,
pager: {
type: 1,
nextLink: '//a[@class="next_page"][@href]',
pageElement: 'css;ol#browse-script-list > li',
HT_insert: ['css;ol#browse-script-list', 3],
replaceE: 'css;.pagination',
scrollDelta: 1000
}
},
greasyfork_feedback: {
SiteTypeID: 0,
pager: {
type: 1,
nextLink: '//a[@class="next_page"][@href]',
pageElement: 'css;.script-discussion-list > div',
HT_insert: ['css;.script-discussion-list', 3],
replaceE: 'css;.pagination',
scrollDelta: 1500
}
},
greasyfork_discussions: {
SiteTypeID: 0,
pager: {
type: 1,
nextLink: '//a[@class="next_page"][@href]',
pageElement: 'css;.discussion-list > div',
HT_insert: ['css;.discussion-list', 3],
replaceE: 'css;.pagination',
scrollDelta: 1000
}
},
alphacoders_art: {
SiteTypeID: 0,
pager: {
type: 1,
nextLink: '//a[@id="next_page"][@href]',
pageElement: 'css;.container-masonry > div',
HT_insert: ['css;.container-masonry', 3],
replaceE: '//div[@class="hidden-xs hidden-sm"]/..',
scrollDelta: 1000
},
function: {
before: alphacoders_art_beforeFunction
}
},
alphacoders_wall: {
SiteTypeID: 0,
pager: {
type: 1,
nextLink: '//a[@id="next_page"][@href]',
pageElement: 'css;.thumb-container-big, .avatar-thumb, .thumb-element',
HT_insert: ['css;.thumb-container-big:nth-last-child(1), .avatar-thumb:nth-last-child(1), .thumb-element:nth-last-child(1)', 4],
replaceE: '//div[@class="hidden-xs hidden-sm"]/..',
scrollDelta: 1000
}
},
fitgirl: {
SiteTypeID: 0,
pager: {
type: 1,
nextLink: '//a[@class="next page-numbers"][@href]',
pageElement: 'css;article[id^="post-"]',
HT_insert: ['css;nav.navigation.paging-navigation', 1],
replaceE: 'css;nav.navigation.paging-navigation',
scrollDelta: 2000
}
}
};
// 生成 SiteTypeID
generateID();
// 用于脚本判断(针对部分特殊的网站)
const SiteType = {
GAMERSKY_GL: DBSite.gamersky_gl.SiteTypeID,
STEAMCOMMUNITY: DBSite.steamcommunity.SiteTypeID
};
// < 其他网站 >
if (webType === 1) {
switch (location.host) {
case 'apphot.cc': // < APPHOT >
case 'www.ypojie.com': // < 亿破姐 >
case 'www.luochenzhimu.com': // < 落尘之木 >
if (location.pathname.indexOf('.html') === -1) curSite = DBSite.dux;
if (location.host === 'apphot.cc') curSite.pager.scrollDelta = 1600; // 对于速度慢的网站,需要增加翻页敏感度
break;
// 以上几个都是 WordPress 的 DUX 主题
case 'www.baidu.com': // < 百度搜索 >
if (location.pathname === '/s') curSite = DBSite.baidu;
break;
case 'movie.douban.com': // < 豆瓣评论 >
if (location.pathname.indexOf('/subject') > -1 && location.pathname.indexOf('/comments') > -1) { // 短评列表
curSite = DBSite.douban_subject_comments;
} else if (location.pathname.indexOf('/subject') > -1 && location.pathname.indexOf('/reviews') > -1) { // 影评列表
curSite = DBSite.douban_subject_reviews;
} else if(location.pathname.indexOf('/subject') > -1 && location.pathname.indexOf('/episode') > -1) { // 电视剧每集评论
curSite = DBSite.douban_subject_episode;
}
break;
case 'weibo.com': // < 微博评论 >
curSite = DBSite.weibo_comment;
break;
case 'www.58pic.com': // < 千图网 >
if (location.pathname.indexOf('/tupian/') > -1) {
curSite = DBSite._58pic;
} else if (location.pathname.indexOf('/c/') > -1) {
curSite = DBSite._58pic_c;
}
break;
case 'www.3dmgame.com': // < 3DM >
curSite = DBSite._3dmgame;
break;
case 'www.ali213.net': // < 游侠网 >
curSite = DBSite.ali213_www;
break;
case 'gl.ali213.net': // < 游侠网 - 攻略页 >
curSite = DBSite.ali213_gl;
document.lastElementChild.appendChild(document.createElement('style')).textContent = `.n_show_b {display: none !important;}` // 隐藏部分碍事元素
break;
case 'www.gamersky.com': // < 游民星空 >
if (location.pathname.indexOf('/ent/') > -1) {
curSite = DBSite.gamersky_ent;
} else {
curSite = DBSite.gamersky_gl;
}
break;
case 'steamcommunity.com': // < Steam 创意工坊 >
curSite = DBSite.steamcommunity;
break;
case 'www.423down.com': // < 423down >
if (location.pathname.indexOf('.html') === -1) curSite = DBSite._423down;
break;
case 'iao.su': // < 不死鸟 >
curSite = DBSite.iao_su;
break;
case 'www.appinn.com': // < 小众软件 >
curSite = DBSite.appinn;
break;
case 'www.weidown.com': // < 微当下载 >
if (location.pathname.indexOf('/search/') > -1) {
curSite = DBSite.weidown_search;
} else if (location.pathname.indexOf('/special/') > -1) {
curSite = DBSite.weidown_special;
} else {
curSite = DBSite.weidown;
}
break;
case 'www.iplaysoft.com': // < 异次元软件 >
if (location.pathname.indexOf('.html') > -1 || location.pathname.indexOf('/p/') > -1) { // 文章内
curSite = DBSite.iplaysoft_postcomments;
} else { // 其他页面
curSite = DBSite.iplaysoft_postslist;
}
break;
case 'www.mpyit.com': // < 老殁殁漂遥 >
if (location.pathname === '/' && !location.search) {
curSite = DBSite.mpyit;
} else if (location.pathname.indexOf('/category/') > -1 || location.search.indexOf('?s=') > -1) {
curSite = DBSite.mpyit_category;
}
break;
case 'www.yxssp.com': // < 异星软件空间 >
curSite = DBSite.yxssp;
break;
case 'www.gufengmh8.com': // < 古风漫画网 >
curSite = DBSite.gufengmh8;
break;
case 'rarbgprx.org': // < RARBG >
curSite = DBSite.rarbgprx;
break;
case 'pubmed.ncbi.nlm.nih.gov': // < 国外学术网站 >
curSite = DBSite.pubmed_postslist;
break;
case 'www.afreecatv.com': // < 直播网站 >
curSite = DBSite.afreecatv;
break;
case 'greasyfork.org': // < GreasyFork >
if (location.pathname.indexOf('/scripts') + 8 === location.pathname.length) {
curSite = DBSite.greasyfork;
} else if (location.pathname.lastIndexOf('/feedback') + 9 === location.pathname.length) {
curSite = DBSite.greasyfork_feedback;
} else if (location.pathname.lastIndexOf('/discussions') + 12 === location.pathname.length) {
curSite = DBSite.greasyfork_discussions;
}
break;
case 'art.alphacoders.com': // < 壁纸网站 >
curSite = DBSite.alphacoders_art;
setTimeout(alphacoders_art_beforeFunction_0, 1000);
break;
case 'wall.alphacoders.com':
case 'avatars.alphacoders.com':
case 'mobile.alphacoders.com':
curSite = DBSite.alphacoders_wall;
break;
case 'fitgirl-repacks.site': // < 游戏下载网站 >
curSite = DBSite.fitgirl;
break;
}
// < 所有 Discuz!论坛 >
} else if (webType === 2) {
if (location.pathname.indexOf('.html') > -1) { // 判断是不是静态网页(.html 结尾)
if (location.pathname.indexOf('forum') > -1) { // 各版块帖子列表
if (document.getElementById('autopbn')) { // 判断是否有 [下一页] 按钮
curSite = DBSite.discuz_forum;
} else {
curSite = DBSite.discuz_guide;
}
} else if (location.pathname.indexOf('thread') > -1) { // 帖子内
if (GM_getValue('menu_discuz_thread_page')) {
curSite = DBSite.discuz_thread;
hidePgbtn(); // 隐藏帖子内的 [下一页] 按钮
}
} else if(location.pathname.indexOf('search') > -1) { // 搜索结果
curSite = DBSite.discuz_search;
}
} else {
if (location.search.indexOf('mod=forumdisplay') > -1) { // 各版块帖子列表
if (document.getElementById('autopbn')) { // 判断是否有 [下一页] 按钮
curSite = DBSite.discuz_forum;
} else {
curSite = DBSite.discuz_guide;
}
} else if (location.search.indexOf('mod=viewthread') > -1) { // 帖子内
if (GM_getValue('menu_discuz_thread_page')) {
curSite = DBSite.discuz_thread;
hidePgbtn(); // 隐藏帖子内的 [下一页] 按钮
}
} else if (location.search.indexOf('mod=guide') > -1) { // 导读帖子列表
curSite = DBSite.discuz_guide;
} else if(location.search.indexOf('mod=space') > -1 && location.search.indexOf('&view=me') > -1) { // 别人的主题/回复
curSite = DBSite.discuz_youspace;
} else if (location.search.indexOf('mod=collection') > -1) { // 淘贴列表
curSite = DBSite.discuz_collection;
} else if (location.pathname.indexOf('search') > -1) { // 搜索结果
curSite = DBSite.discuz_search;
} else { // 考虑到部分论坛的部分板块帖子列表 URL 是自定义的
curSite = DBSite.discuz_forum;
}
}
// < 所有 Flarum 论坛 >
} else if (webType === 3) {
curSite = DBSite.flarum;
}
curSite.pageUrl = ''; // 下一页URL
pageLoading(); // 自动无缝翻页
// 隐藏帖子内的 [下一页] 按钮(Discuz! 论坛)
function hidePgbtn() {
document.lastChild.appendChild(document.createElement('style')).textContent = '.pgbtn {display: none;}';
}
// dux 的插入前函数(加载图片)
function dux_beforeFunction(pageElems) {
pageElems.forEach(function (one) {
let now = one.querySelector('img.thumb[data-src]')
if (now) {
now.setAttribute('src', now.dataset.src)
}
});
return pageElems
}
// 58pic 的插入前函数(加载图片)
function _58pic_beforeFunction(pageElems) {
let is_one = document.querySelector('.qtw-card.place-box.is-one');
if (is_one && is_one.style.display != 'none') {
is_one.setAttribute('style', 'display: none;')
}
pageElems.forEach(function (one) {
let now = one.querySelector('img.lazy')
if (now && now.getAttribute('src') != now.dataset.original) {
now.setAttribute('src', now.dataset.original)
now.setAttribute('style', 'display: block;')
}
});
return pageElems
}
// 游民星空攻略 的插入前函数(移除下一页底部的 "更多相关内容请关注:xxx" 文字)
function gamersky_gl_beforeFunction(pageElems) {
pageElems.forEach(function (one) {
if (one.tagName === 'P' && one.textContent.indexOf('更多相关内容请关注') > -1) {
one.style.display = 'none';
}
});
return pageElems
}
// iao.su 的插入前函数(加载图片)
function iao_su_beforeFunction(pageElems) {
pageElems.forEach(function (one) {
let now = one.getElementsByClassName('post-card')[0]
if (now) {
now.getElementsByClassName('blog-background')[0].style.backgroundImage = 'url("' + now.getElementsByTagName('script')[0].textContent.split("'")[1] + '")';
//now.getElementsByClassName('blog-background')[0].style.backgroundImage = 'url("' + RegExp("(?<=loadBannerDirect\\(').*(?=', '',)").exec(now.getElementsByTagName('script')[0].textContent)[0]; + '")';
}
});
return pageElems
}
// iplaysoft 的插入前函数(加载图片)
function iplaysoft_postslist_beforeFunction(pageElems) {
pageElems.forEach(function (one) {
let now = one.querySelector('img.lazyload')
if (now && !now.src) {
now.setAttribute('src', now.dataset.src)
now.setAttribute('srcset', now.dataset.src)
now.setAttribute('class', 'lazyloaded')
}
});
return pageElems
}
// alphacoders_art 的插入前函数(图片结构调整)
function alphacoders_art_beforeFunction(pageElems) {
pageElems.forEach(function (one) {
one.setAttribute('style','float: left');
});
return pageElems
}
// alphacoders_art(图片结构调整)
function alphacoders_art_beforeFunction_0() {
let pageElems1 = document.querySelectorAll('.container-masonry > div')
document.querySelector('.container-masonry').style.height = 'auto'
pageElems1.forEach(function (one) {
one.setAttribute('style','float: left');
});
}
// gufengmh8
function gufengmh8_functionNext() {
if (curSite.pageUrl) { // 如果已经有下一页的 URL 则直接获取
getPageElems(curSite.pageUrl)
} else {
let pageElems = document.querySelector(curSite.pager.pageElement.replace('css;', '')); // 寻找数据所在元素
if (pageElems) {
let comicUrl, nextId;
pageElems.textContent.split(';').forEach(function (one){ // 分号 ; 分割为数组并遍历
//console.log(one)
if (one.indexOf('comicUrl') > -1) { // 下一页 URL 前半部分
comicUrl = one.split('"')[1];
} else if (one.indexOf('nextChapterData') > -1) { // 下一页 URL 的后半部分 ID
nextId = one.split('"id":')[1].split(',')[0];
}
})
if (comicUrl && nextId && nextId != 'null') { // 组合到一起就是下一页 URL
curSite.pageUrl = comicUrl + nextId + '.html'
//console.log(curSite.pageUrl)
getPageElems(curSite.pageUrl); // 访问下一页 URL 获取
}
}
}
}
// gufengmh8
function gufengmh8_functionAdd(pageElems) {
if (pageElems) {
curSite.pageUrl = ''; // 留空后,下一页 URL 依然交给 gufengmh8_function 函数获取(方便点)
pageElems = pageElems[0];
//console.log(pageElems)
let chapterImages, chapterPath;
//console.log(pageElems.textContent)
document.querySelector(curSite.pager.pageElement.replace('css;', '')).innerText = pageElems.textContent; // 将当前网页内的数据所在元素内容改为刚刚获取的下一页数据内容,以便循环获取下一页 URL(gufengmh8_function 函数)
pageElems.textContent.split(';').forEach(function (one){ // 分号 ; 分割为数组并遍历
//console.log(one)
if (one.indexOf('chapterImages') > -1) { // 图片文件名数组
chapterImages = one.replace(/^.+\[/, '').replace(']', '').replaceAll('"', '').split(',')
} else if (one.indexOf('chapterPath') > -1) { // 图片文件路径
chapterPath = one.split('"')[1];
} else if (one.indexOf('pageTitle') > -1) { // 网页标题
window.document.title = one.split('"')[1]; // 修改当前网页标题为下一页的标题
}
})
if (chapterImages && chapterPath) {
let _img = '';
chapterImages.forEach(function (one2){ // 遍历图片文件名数组,组合为 img 标签
_img += '<img src="https://res.xiaoqinre.com/' + chapterPath + one2 + '" data-index="0" style="display: inline-block;">'
//console.log('https://res.xiaoqinre.com/' + chapterPath + one2)
})
document.querySelector(curSite.pager.HT_insert[0].replace('css;', '')).insertAdjacentHTML(addTo(curSite.pager.HT_insert[1]), _img); // 将 img 标签插入到网页中
}
}
}
// 自动无缝翻页
function pageLoading() {
if (curSite.SiteTypeID > 0) {
windowScroll(function (direction, e) {
if (direction === 'down') { // 下滑才准备翻页
let scrollTop = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop,
scrollHeight = window.innerHeight || document.documentElement.clientHeight,
scrollDelta = curSite.pager.scrollDelta;
if (curSite.pager.type === 3) { // 翻页类型 3
let scrollElement = document.querySelector(curSite.pager.scrollElement);
//console.log(scrollElement.offsetTop - (scrollTop + scrollHeight), scrollDelta, curSite.SiteTypeID)
if (scrollElement.offsetTop - (scrollTop + scrollHeight) <= scrollDelta) {
if (curSite.SiteTypeID === SiteType.GAMERSKY_GL) curSite.pager.scrollDelta -= 800 // 游民星空 gl 的比较奇葩,需要特殊处理下
ShowPager.loadMorePage();
}
} else {
if (document.documentElement.scrollHeight <= scrollHeight + scrollTop + scrollDelta) {
if (curSite.pager.type === 2) { // 翻页类型 2
if (curSite.SiteTypeID > 0) { // 如果指定了间隔时间,那么就依靠这个判断时间到了没有~
let autopbn = document.querySelector(curSite.pager.nextLink);
if (autopbn) { // 寻找下一页链接
if (!curSite.pager.nextText) { // 如果没有指定 nextText 就直接点击
autopbn.click();
} else if (autopbn.textContent.indexOf(curSite.pager.nextText) > -1){ // 如果指定了 nextText 就需要判断后再点击(避免已经在加载了,还重复点击)
autopbn.click();
}
// 对于没有按钮文字变化的按钮,可以手动指定间隔时间
if (curSite.pager.intervals) {
let _SiteTypeID = curSite.SiteTypeID;
curSite.SiteTypeID = 0;
setTimeout(function(){curSite.SiteTypeID = _SiteTypeID;}, curSite.pager.intervals)
}
}
}
} else if (curSite.pager.type === 1) { // 翻页类型 1
ShowPager.loadMorePage();
} else if (curSite.pager.type === 4) { // 翻页类型 4
if (curSite.SiteTypeID > 0) {
curSite.pager.functionNext();
if (curSite.pager.intervals) {
let _SiteTypeID = curSite.SiteTypeID;
curSite.SiteTypeID = 0;
setTimeout(function(){curSite.SiteTypeID = _SiteTypeID;}, curSite.pager.intervals)
}
}
}
}
}
}
});
}
}
/*function getElementToPageTop(el) {
if(el.parentElement) {
return getElementToPageTop(el.parentElement) + el.offsetTop
}
return el.offsetTop
}*/
// 启用/禁用 (当前网站)
function menu_disable(type) {
switch(type) {
case 'check':
if(check()) return true
return false
break;
case 'add':
add();
break;
case 'del':
del();
break;
}
function check() { // 存在返回真,不存在返回假
let list = GM_getValue('menu_disable'); // 读取网站列表
if (list.indexOf(location.host) === -1) return false // 不存在返回假
return true
}
function add() {
if (check()) return
let list = GM_getValue('menu_disable'); // 读取网站列表
list.push(location.host); // 追加网站域名
GM_setValue('menu_disable', list); // 写入配置
location.reload(); // 刷新网页
}
function del() {
if (!check()) return
let list = GM_getValue('menu_disable'), // 读取网站列表
index = list.indexOf(location.host);
list.splice(index, 1); // 删除网站域名
GM_setValue('menu_disable', list); // 写入配置
location.reload(); // 刷新网页
}
}
// 菜单开关
function menu_switch(menu_status, Name, Tips) {
if (menu_status === true){
GM_setValue(`${Name}`, false);
}else{
GM_setValue(`${Name}`, true);
}
location.reload();
};
// 生成 ID
function generateID() {
let num = 0
for (let val in DBSite) {
DBSite[val].SiteTypeID = num = num + 1;