forked from ywzhaiqi/userChromeJS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nextpage.uc.xul
1642 lines (1490 loc) · 75.4 KB
/
nextpage.uc.xul
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
<?xml version="1.0" encoding="UTF-8"?>
<overlay xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<!--
// ==UserScript==
// @name NextPage.uc.xul
// @namespace nextpage@slimx.com
// @description 翻页脚本
// @include main
// @author slimx
// @version 1.0.6.23
// @updateURL https://j.mozest.com/ucscript/script/5.meta.js
// ==/UserScript==
-->
<script type="application/javascript;version=1.8"><![CDATA[
var nextPage = new function() {
var config = {
//快进,快退访问已浏览过的页面,操作太快的话,有些页面(尤其是discuz)的翻页可能会出现异常,可以改为false.
//目前,启用预读的话,usehistory会自动禁用
useHistory:true
//是否搜索图片,有些问题,似乎无法正常工作
,searchImg:false
//------------------------------------------------------------------------------
//是否启用快捷键
,key_use:true
//快捷键的冻结时间,即两次翻页的间隔,单位是毫秒
,key_freeze:1000
//上一页的按键
,key_prev:"VK_LEFT"
//下一页的按键
,key_next:"VK_RIGHT"
//辅助键,默认是ctrl(accel),不使用的话,改成false即可,也可以是alt,shift
,key_modifiers:"accel"
//------------------------------------------------------------------------------
//预读模式:
// 0,完全禁用预读
//2,模式2,使用iframe置换的方式,效果最好,在模式2下,可以针对站点进行排除,被排除的站点会预读但不会置换
,prefetchMode:0
//是否在状态栏显示预读开关
,prefetchSwitcher:false
//开关的初始状态
,perfetchSwitcherInit:true
//状态栏开关的标题
,prefetchSwitcherLabel:"Prefetch"
//false是在domcontentloaded加载,true是在load加载,false预读的比较快,true比较不会影响当前页面的加载
,prefetchAfterLoad:false
//最大的同时预读的页面,0的话,只对当前页面预读
//目前,只允许值为0
,prefetchMax:0
//启动预读的延迟时间,单位是秒,当prefetchAfterLoad是true的情况下,参数无效
,prefetchDelay:3
//连续预读,不会因为切换页面而停止
,prefetchContinue:true
//预读的内容开关
,prefetch_images : true//图片
,prefetch_javascript : true//脚本
,prefetch_redirect : true//重定向之后的文档
,prefetch_plugins: false//插件,比如flash
,prefetch_subframes: true//子窗口,frame,iframe
,prefetch_auth:false//安全验证
//以下的设定在配置文件中修改
//如果使用左,右方向键做翻页的快捷键的话(无论是否使用辅助键ctrl,alt等),需要将这个值改为true,否则discuz论坛会不正常
,isFix4Discuz:false
//禁止在控制台输出
,isDisableLog:true
//如果用firegestures遇到某些翻页无效的情况,可以将值修改为true
,isFix4FG:false
};
//---------------------------------------------------------------------------------
var rule = {};
//强制使用模拟点击方式的页面,比如淘宝的成交列表,使用正则的方式来判断
rule.forceClick = [
/item\.taobao\.com/i,
/news\.163\.com\/photoview\//i,
/360buy\.com\/product/i,
/music\.baidu.com/i,
/blog\.sina\.com\.cn/i
];
//完全禁止使用iframe方式预读,会转而使用xhr方式,兼容性比较好
rule.disableIframe = [
/^https?:\/\/\w{3,10}\.google(?:\.\w{1,4}){1,2}\/search/i,
/image\.youdao\.com/i
];
//通用规则的站点,比如discuz和phpwind的论坛
rule.specialCommon = [
{siteName:'Discuz论坛帖子列表页面',
url:/^https?:\/\/.+\/(?:(?:forum)|(?:showforum)|(?:viewforum))/i,
preLink:'//div[@class="pages" or @class="pg"]/descendant::a[@class="prev"][@href]',
nextLink:'//div[@class="pages" or @class="pg"]/descendant::a[@class="next" or @class="nxt"][@href]'
},
{siteName:'Discuz论坛帖子内容页面',
url:/^https?:\/\/.+\/(?:(?:thread)|(?:viewthread)|(?:showtopic)|(?:viewtopic))/i,
preLink:'//div[@class="pages" or @class="pg"]/descendant::a[@class="prev"][@href]',
nextLink:'//div[@class="pages" or @class="pg"]/descendant::a[@class="next" or @class="nxt"][@href]'
}
,
{siteName:'phpWind论坛帖子列表页面',
url:/^https?:\/\/.+\/(?:bbs\/)?thread/i,
preLink:'//div[starts-with(@class,"pages")]/b[1]/preceding-sibling::a[1][not(@class)][@href] | //div[starts-with(@class,"pages")]/ul[1]/li[b]/preceding-sibling::li/a[1][not(@class)][@href]',
nextLink:'//div[starts-with(@class,"pages")]/b[1]/following-sibling::a[1][not(@class)][@href] | //div[starts-with(@class,"pages")]/ul[1]/li[b]/following-sibling::li/a[1][not(@class)][@href]'
},
{siteName:'phpWind论坛帖子内容页面',
url:/^https?:\/\/.+\/(?:bbs\/)?read/i,
preLink:'//div[starts-with(@class,"pages")]/b[1]/preceding-sibling::a[1][not(@class)][@href] | //div[starts-with(@class,"pages")]/ul[1]/li[b]/preceding-sibling::li/a[1][not(@class)][@href]',
nextLink:'//div[starts-with(@class,"pages")]/b[1]/following-sibling::a[1][not(@class)][@href] | //div[starts-with(@class,"pages")]/ul[1]/li[b]/following-sibling::li/a[1][not(@class)][@href]'
}
];
//专用规则的站点
rule.specialSite = [
{
siteName: "特殊google搜索",
url: /^https?:\/\/www\.google\.com\/cse\?cx=/i,
siteExample: 'https://www.google.com/cse?cx=008745974804865311006%3Achikzhnrhzs&ie=UTF-8&q=mactype&sa=%E6%90%9C%E5%B0%8B#gsc.tab=0&gsc.q=mactype&gsc.page=2',
nextLink: '//div[contains(@class, "gsc-cursor-current-page")]/following-sibling::div[1]'
},
{siteName:'google搜索', //站点名字...(可选)
url:/^https?:\/\/\w{3,10}\.google(?:\.\w{1,4}){1,2}\/search/i, //站点正则...(~~必须~~)
siteExample:'http://www.google.com', //站点实例...(可选)
enable:true, //启用.(总开关)(可选)
useiframe:false, //是否用iframe预读...(可选)
preLink:'//table[@id="nav"]/descendant::a[1][parent::td[@class="b"]]', //上一页链接 xpath 或者 CSS选择器 或者 函数返回值 (prelink 和 nextlink最少填一个)
nextLink:'//table[@id="nav"]/descendant::a[last()][parent::td[@class="b"]]' //下一页链接 xpath 或者 CSS选择器 或者 函数返回值 (prelink 和 nextlink最少填一个)
},
{siteName:'google图片',
url:/^https?:\/\/\w{3,7}\.google(?:\.\w{1,4}){1,2}\/images/i,
siteExample:'http://images.google.com',
nextLink:'//table[@id="nav"]/descendant::a[last()][parent::td[@class="b"]]'
},
{siteName:'百度搜索',
url:/^https?:\/\/www\.baidu\.com\/(?:s|baidu)\?/i,
siteExample:'http://www.baidu.com',
enable:false,
nextLink:'//p[@id="page"]/a[text()="下一页"][@href]'
//nextLink:'div.p>a:last-of-type',
},
{siteName:'百度mp3',
url:/^http:\/\/mp3\.baidu\.com\/.+/i,
siteExample:'http://mp3.baidu.com/m?tn=baidump3&ct=134217728&lm=0&f=1&word=%CB%C0%C9%F1',
nextLink:'//div[@class="pg"]/a[(font/text()="下一页")]'
},
{siteName:'百度贴吧帖子列表页面',
url:/^http:\/\/tieba\.baidu\.com\/f\?.*kw=/i,
siteExample:'http://tieba.baidu.com/f?kw=opera&fr=tb0_search&ie=utf-8',
nextLink:'//div[@id="pagebar"]/div[@class="pagination"]/a[text()="下一页"]'
},
{siteName:'百度贴吧俱乐部帖子列表内容页面',
url:/^http:\/\/tieba\.baidu\.com\/club\/.+\/p\/.+/i,
siteExample:'http://tieba.baidu.com/club/6883547/p/4047809',
nextLink:'//div[@class="pagination"]/a[text()="下一页"]'
},
{siteName:'百度贴吧俱乐部帖子列表页面',
url:/^http:\/\/tieba\.baidu\.com\/club\/.+(?!\/p\/)/i,
siteExample:'http://tieba.baidu.com/club/6883547',
nextLink:'//div[@class="pagination"]/a[text()="下一页"]'
},
{siteName:'百度贴吧帖子内容页面',
url:/^http:\/\/tieba\.baidu\.com\/f\?kz=\d+/i,
siteExample:'http://tieba.baidu.com/f?kz=620671135',
nextLink:'//li[@class="pagination"]/a[text()="下一页"]'
},
{siteName:'万卷书库小说阅读页',
url:/^http:\/\/www\.wanjuan\.net\/article\/.+html/i,
useiframe:true,
nextLink:'//div[@id="gotopage"]/descendant::a[text()="下一页"]'
},
{siteName:'万卷书屋小说阅读页',
url:/^http:\/\/www\.wjxsw\.com\/html\/.+html/i,
useiframe:true,
nextLink:'//div[@id="LinkMenu"]/descendant::a[last()]'
},
{siteName:'起点小说阅读页',
url:/^http:\/\/www\.qidian\.com\/BookReader\/\d+,\d+/i,
siteExample:'http://www.qidian.com/BookReader/1545376,27301383.aspx',
useiframe:true,
nextLink:'//a[@id="NextLink"]'
},
{siteName:'冰地小说阅读页',
url:/^http:\/\/www\.bingdi\.com\/html\/book\/.+/i,
siteExample:'http://www.bingdi.com/html/book/130/153935/4201826.shtm',
useiframe:true,
nextLink:'//div[@id="LinkMenu"]/descendant::a[last()][text()="翻下页"]'
},
{siteName:'opera官方网站帖子列表页面',
url:/^http:\/\/bbs\.operachina\.com\/viewforum/i,
siteExample:'http://bbs.operachina.com/viewforum.php?f=41',
nextLink:'//div[starts-with(@class,"pagination")]/descendant::a[text()="下一页"]'
},
{siteName:'opera官方网站帖子内容页面',
url:/^http:\/\/bbs\.operachina\.com\/viewtopic/i,
siteExample:'http://bbs.operachina.com/viewtopic',
nextLink:'//div[starts-with(@class,"pagination")]/descendant::a[text()="下一页"]'
},
{siteName:'opera官方网站查看新帖帖子列表页面',
url:/^http:\/\/bbs\.operachina\.com\/search/i,
siteExample:'http://bbs.operachina.com/search.php?search_id=newposts',
nextLink:'//li[contains(@class,"pagination")]/descendant::a[text()="下一页"]'
},
{siteName:'深度论坛帖子内容页面',
url:/http:\/\/bbs\.deepin\.org\/thread/i,
siteExample:'http://bbs.deepin.org/thread',
nextLink:'//div[@class="pages"]/descendant::a[@class="next"]'
},
{siteName:'卡饭论坛帖子内容页面',
url:/http:\/\/bbs\.kafan\.cn\/thread/i,
siteExample:'http://bbs.kafan.cn/thread',
nextLink:'//div[@class="pg"]/descendant::a[@class="nxt"]'
},
{siteName:'卡饭论坛帖子列表页面',
url:/http:\/\/bbs\.kafan\.cn\/forum/i,
siteExample:'http://bbs.kafan.cn/forum-74-1.html',
nextLink:'//div[@class="pg"]/descendant::a[@class="nxt"]'
},
{siteName:'远景论坛帖子内容页面',
url:/http:\/\/bbs\.pcbeta\.com\/thread/i,
siteExample:'http://bbs.pcbeta.com/thread',
nextLink:'//div[@class="pages"]/descendant::a[@class="next"]'
},
{siteName:'思源论坛帖子内容页面',
url:/http:\/\/www\.missyuan\.com\/(?:view)?thread/i,
siteExample:'http://www.missyuan.com/thread-431242-1-1.html',
nextLink:'//div[@class="pages"]/descendant::a[@class="next"]'
},
{siteName:'思源论坛帖子列表页面',
url:/http:\/\/www\.missyuan\.com\/forum/i,
siteExample:'http://www.missyuan.com/forum-98-1.html',
nextLink:'//div[@class="pages"]/descendant::a[@class="next"]'
},
{siteName:'极点五笔帖子内容页面',
url:/www\.wbfans\.com\/bbs\/viewthread\.php/i,
siteExample:'http://www.wbfans.com/bbs/viewthread.php?tid=49308&extra=page%3D1',
nextLink:'//div[@class="pages"]/descendant::a[@class="next"]'
},
{siteName:'天极动漫频道新闻',
url:/http:\/\/comic\.yesky\.com\/\d+\/.+\.shtml/i,
siteExample:'http://comic.yesky.com/249/11335749_5.shtml',
nextLink:'//div[@id="numpage"]/descendant::a[contains(text(),"下一页")]'
},
{siteName:'赢政天下论坛帖子内容页面',
url:/http:\/\/bbs\.winzheng\.com\/viewthread/i,
siteExample:'http://bbs.winzheng.com/viewthread.php?tid=',
nextLink:'//div[@class="forumcontrol"]/descendant::a[@class="next"]'
},
{siteName:'soso网页搜索',
url:/http:\/\/www\.soso\.com\/q/i,
siteExample:'http://www.soso.com/q',
nextLink:'//div[@id="page"]/descendant::a[last()][@class="next"]'
},
{siteName:'bing网页搜索',
url:/bing\.com\/search\?q=/i,
siteExample:'bing.com/search?q=',
nextLink:'//div[@id="results_container"]/descendant::a[last()][@class="sb_pagN"]'
},
{siteName:'有道网页搜索',
url:/http:\/\/www\.youdao\.com\/search\?/i,
siteExample:'http://www.youdao.com/search?',
useiframe:true,
nextLink:'//div[@id="pagination"]/descendant::a[last()][@class="next-page"]'
},
{siteName:'煎蛋首页',
url:/http:\/\/jandan\.net\/(?:page)?/i,
siteExample:'http://jandan.net/',
useiframe:true,
nextLink:'//div[@class="wp-pagenavi"]/child::a[text()=">>"]'
},
{siteName:'中国教程网论坛帖子内容页面',
url:/http:\/\/bbs\.jcwcn\.com\/thread/i,
siteExample:'http://bbs.jcwcn.com/thread',
nextLink:'//div[@class="pages"]/descendant::a[@class="next"]'
},
{siteName:'kuku动漫',
url:/http:\/\/comic\.kukudm\.com\/comiclist\/\d+\/\d+.*\.htm/i,
siteExample:'http://comic.kukudm.com/comiclist/4/17099/3.htm',
useiframe:true,
nextLink:'//a[img[contains(@src,"images/d.gif")]]'
},
{siteName:'EZ游戏社区帖子内容页面',
url:/http:\/\/bbs\.emu-zone\.org\/newbbs\/thread/i,
siteExample:'http://bbs.emu-zone.org/newbbs/thread',
nextLink:'//div[@class="p_bar"]/a[contains(text(),"??")]'
},
{siteName:'mozest社区帖子内容页面',
url:/^https:\/\/g\.mozest\.com\/thread/i,
siteExample:'https://board.mozest.com/thread-34726-1-1',
nextLink:'//div[@class="pages"]/a[@class="next"]'
},
{siteName:'mozest社区帖子列表页面',
url:/^https:\/\/g\.mozest\.com\/forum/i,
siteExample:'https://board.mozest.com/forum-50-1',
nextLink:'//div[@class="pages"]/a[@class="next"]'
},
{siteName:'海贼王中文网漫画页',
url:/http:\/\/op\.52pk\.com\/manhua\/\d+\/\d+/i,
siteExample:'http://op.52pk.com/manhua/2010/921364.html',
nextLink:'//li[@id="page__next"]/a[1]'
},
{siteName:'死神中文网漫画页',
url:/http:\/\/sishen\.52pk\.com\/manhua\/\d+\/\d+/i,
siteExample:'http://sishen.52pk.com/manhua/2010/927406.html',
nextLink:'//li[@id="page__next"]/a[1]'
},
{siteName:'火影中文网漫画页',
url:/http:\/\/narutocn\.52pk\.com\/manhua\/\d+\/\d+/i,
siteExample:'http://narutocn.52pk.com/manhua/2010/921439.html',
nextLink:'li#page__next>a:first-child'
//nextLink:'//li[@id="page__next"]/a[1]',
},
{siteName:'塞班智能手机论坛帖子列表页面',
url:/http:\/\/bbs\.dospy\.com\/forum/i,
siteExample:'http://bbs.dospy.com/forum-354-1.html',
nextLink:'//div[@class="p_bar"]/a[@class="p_curpage"]/following-sibling::a[@class="p_num"]'
},
{siteName:'塞班智能手机论坛帖子内容页面',
url:/http:\/\/bbs\.dospy\.com\/thread/i,
siteExample:'http://bbs.dospy.com/thread-672836-1-52-1.html',
nextLink:'//div[@class="p_bar"]/a[@class="p_curpage"]/following-sibling::a[@class="p_num"]'
},
{siteName:'新华网新闻页面',
url:/http:\/\/news\.xinhuanet\.com\/.+\/\d+-/i,
siteExample:'http://news.xinhuanet.com/politics/2010-07/19/c_12347755.htm',
nextLink:'//div[@id="div_currpage"]/a[text()="下一页"]'
},
{siteName:'中关村在线新闻页面',
url:/http:\/\/(?:[^\.]+\.)?zol.com.cn\/\d+\/\d+/i,
siteExample:'http://lcd.zol.com.cn/187/1875145.html',
nextLink:'//a[text()="下一页>"][@href]'
},
{siteName:'天涯论坛帖子内容页面',
url:/http:\/\/www\.tianya\.cn\/.+\/content\/.+/i,
siteExample:'http://www.tianya.cn/publicforum/content/2010expo/4eddfdeea800b3957fd4781ff6004bc3/1/0/1.shtml',
nextLink:'//*[@id="pageDivTop" or @class="pages"]/descendant::a[text()="下一页"][@href]'
},
{siteName:'色影无忌帖子内容页面',
url:/http:\/\/forum\.xitek\.com\/showthread/i,
siteExample:'http://forum.xitek.com/showthread.php?threadid=571986',
nextLink:'//font[@size="2"]/font[@class="thtcolor"]/following-sibling::a[@href]'
},
{siteName:'梦想文学',
url:/^http:\/\/www\.mx99\.com\/html\/book\/.+html/i,
useiframe:true,
nextLink:'//div[@id="thumb"]/a[4]'
},
{siteName:'招聘区,杭州19楼,帖子内容',
url:/^http:\/\/www\.19lou\.com\/forum.*thread/i,
siteExample:'http://www.19lou.com/forum-1502-thread-29762777-1-1.html',
nextLink:'//div[@class="pages"]/descendant::a[text()="下一页"][@href]',
useiframe:true
},
{siteName:'招聘区,杭州19楼,帖子列表',
url:/^http:\/\/www\.19lou\.com\/forum/i,
siteExample:'http://www.19lou.com/forum-1500-1.html',
nextLink:'//div[@class="pages"]/descendant::a[text()="下一页"][@href]'
},
{siteName:'汽车之家论坛帖子内容',
url:/^http:\/\/club\.autohome\.com\.cn\/bbs\/thread/i,
siteExample:'http://club.autohome.com.cn/bbs/thread-a-100019-7383135-1.html',
nextLink:'//div[@class="pages"]/a[@title="下1页"][@href]'
},
{siteName:'爱卡汽车论坛帖子内容',
url:/^http:\/\/www\.xcar\.com\.cn\/bbs\/viewthread/i,
siteExample:'http://www.xcar.com.cn/bbs/viewthread.php?tid=12474760',
nextLink:'//a[text()="下一页>"][@href]'
},
{siteName:'猫扑大杂烩帖子内容',
url:/http:\/\/dzh\.mop\.com\/topic\/readSub/i,
nextLink:'//a[contains(text(),"下一页")][@href]'
},
{siteName:'水木社区帖子内容页面',
url:/http:\/\/www\.newsmth\.net\/bbstcon/i,
nextLink:'//a[text()="下一页"][@href]',
useiframe:true
},
{siteName:'VeryCD搜索页面',
url:/http:\/\/www\.verycd\.com\/search\/folders.+/i,
siteExample:'http://www.verycd.com/search/folders/opera',
nextLink:'//div[@class="pages-nav"]/a[contains(text(),"下一页")][@href]'
},
{siteName:'照片处理网',
url:/http:\/\/www\.photops\.com\/Article\/.+/i,
siteExample:'http://www.photops.com/Article/xsjc/20100728172116.html',
nextLink:'//a[text()="下一页"][@href]'
},
{siteName:'178在线漫画',
url:/http:\/\/manhua\.178\.com\/.+\/.+\/.+/i,
siteExample:'http://manhua.178.com/h/haizeiwang/10062.shtml',
loaded:true,
nextLink:'//div[@class="pages"]/a[text()="下一页"][@href]'
},
{siteName:'sosg论坛帖子内容',
url:/http:\/\/www\.sosg\.net\/read/i,
siteExample:'http://www.sosg.net/read.php?tid=424833',
nextLink:'//td[@align="left"]/b/following-sibling::a[@href]'
},
{siteName:'flickr搜索',
url:/http:\/\/www\.flickr\.com\/search\/\?q=/i,
siteExample:'http://www.flickr.com/search/?q=opera',
nextLink:'//div[@class="Paginator"]/a[@class="Next"][@href]'
},
{siteName:'搜狗浏览器论坛帖子页面',
url:/http:\/\/ie\.sogou\.com\/bbs\/forumdisplay\.php/i,
siteExample:'http://ie.sogou.com/bbs/forumdisplay.php?fid=2',
nextLink:'//div[@class="pages"]/a[@class="next"][@href]'
},
{siteName:'搜狗浏览器论坛帖子内容页面',
url:/http:\/\/ie\.sogou\.com\/bbs\/viewthread\.php/i,
siteExample:'http://ie.sogou.com/bbs/viewthread.php?tid=203223&extra=page%3D1',
nextLink:'//div[@class="pages"]/a[@class="next"][@href]'
},
{siteName:'小说梦阅读页',
url:/http:\/\/www\.xiaoshuomeng\.com\/book\/.+\/zhangjie\/.+/i,
siteExample:'http://www.xiaoshuomeng.com/book/3967/zhangjie/1/',
nextLink:'//a[text()="下一章"][@href]'
}
,
{
siteName:'和讯博客',
url:/blog\.hexun\.com/i,
nextLink:'//a[text()="下一页"]',
preLink:'//a[text()="上一页"]'
},
{
siteName:'百书库',
url:/baishuku\.com/i,
nextLink:'//a[text()="下一页(快捷键:→)"]',
preLink:'//a[text()="(快捷键:←)上一页"]'
},
{
siteName:'海报网',
url:/haibao\.cn/i,
nextLink:'//a[@class="right tright"]',
preLink:'//a[@class="left tleft"]'
},
{
siteName:"凤凰网",
url:/ifeng\.com.*\/(bigpicture|hdsociety)\/detail_/i,
nextLink:function() {
content.location.href = content.wrappedJSObject.nextLink;
},
preLink:function() {
content.location.href = content.wrappedJSObject.preLink;
}
},
{
siteName:"凤凰网",
url:/ifeng\.com.*\/detail_/i,
nextLink:"//a[@id='nextLink']",
preLink:"//a[@id='preLink']"
},
{
siteName:"瘾科技",
url:/cn\.engadget\.com/i,
nextLink:"//a[text()='Next 20 Comments']",
preLink:"//a[text()='Previous 20 Comments']"
},
{
siteName:"xda",
url:/forum\.xda-developers\.com\/showthread\.php\?/i,
nextLink:"//a[@rel='next']",
preLink:"//a[@class='pagination-prev']"
},
{
siteName:"android market",
url:/play\.google\.com/i,
nextLink:"//div[contains(@class,'num-pagination-next')]",
preLink:"//div[contains(@class,'num-pagination-previous')]"
},
{
siteName:"163 图片新闻",
url:/news\.163\.com\/photoview\//i,
nextLink:"//a[@id='photoNext']",
preLink:"//a[@id='photoPrev']"
},
{
siteName:"126/163/yeah 邮箱",
url:/webmail\.mail\.(126\.com|163\.com|yeah\.net)/i,
nextLink:"//div[@id='dvContainer']/div[last()]//div[@title='下一页']",
preLink:"//div[@id='dvContainer']/div[last()]//div[@title='上一页']"
}
];
// 下一页链接里的文字
var next = {};
var previous = {};
var first = {};
var last = {};
//链接中的文字
next.texts = [
'next',
'next page',
'old',
'older',
'earlier',
'下页',
'下頁',
'下一頁',
'后一页',
'后一頁',
'翻下页',
'翻下頁',
'后页',
'后頁',
'下翻',
'下一个',
'下一张',
'下一幅',
'下一节',
'下一章',
'下一篇',
'后一章',
'后一篇',
'往后',
"Next photo",
'下一页',
'下1页',
'下1頁',
'newer entries',
''
];
previous.texts = [
'previous',
'prev',
'previous page',
'new',
'newer',
'later',
'上页',
'上頁',
'上一页',
'上一頁',
'前一页',
'前一頁',
'翻上页',
'翻上頁',
'前页',
'前頁',
'上翻',
'上一个',
'上一张',
'上一幅',
'上一节',
'上一章',
'上一篇',
'前一章',
'前一篇',
'往前',
'Previous photo',
'上1页',
'上1頁',
'older entries',
''
];
//首页和尾页的链接文字
first.texts = ["首页","第一页","第1页","<<","«"];
last.texts = ["最后","末尾","末页","尾页",">>","»"];
//可能会误判的词
next.continueTexts = ["next",">>","»"];
previous.continueTexts = ["previous","<<","«"];
first.continueTexts = ["首页"];
last.continueTexts = [];
//链接或其他标签的属性,比如id,class,title之类使用的
next.attrValue = /^(next(link)?|linknext|pgdown)$/i;
previous.attrValue = /^(prev(ious)?(link)?|linkprev(ious)?|pgup)$/i;
// 翻页文字的前面和后面可能包含的字符,
next.startRegexp = /(?:^\s*(?:[\(\[『「[【]?)\s*)/;
next.endRegexp = /(?:\s*([>>›»]*)|(?:[\)\]』」]】→]?)\s*$)/;
previous.startRegexp = /(?:^\s*([<<‹«]*)|(?:[\(\[『「[【←]?)\s*)/;
previous.endRegexp = /(?:\s*(?:[\)\]』」]】]?)\s*$)/;
last.startRegexp = /(?:^\s*(?:[\(\[『「[【]?)\s*)/;
last.endRegexp = /(?:\s*([>>›»]*)|(?:[\)\]』」]】→]?)\s*$)/;
first.startRegexp = /(?:^\s*([<<‹«]*)|(?:[\(\[『「[【←]?)\s*)/;
first.endRegexp = /(?:\s*(?:[\)\]』」]】]?)\s*$)/;
//---------------------------------------------------------------------------------
var current = null;
const discuzRegexp = /\/forumdisplay\.php\?fid=\d+/i;
const emptyRegexp = /^\s$/;
//---------------------------------------------------------------------------------
//控制台输出
function log(str) {
if (config.isDisableLog)return;
Components.classes["@mozilla.org/consoleservice;1"]
.getService(Components.interfaces.nsIConsoleService).logStringMessage(str);
}
//检查字符串是否为空
function isEmpty(str) {
if (!str)return true;
if (emptyRegexp.test(str))return true;
return false;
}
//有些操作,比如事件等,必须用沙箱方式才行
function getUnsafeWindow(win) {
win = win || content;
let sandbox = Components.utils.Sandbox(win);
sandbox.unsafeWindow = win.wrappedJSObject;
return sandbox.unsafeWindow;
}
//检查站点的地址是否和列表匹配
function isMatch(e, index, array) {
return e.test(getCurrentHref(this))
}
/**
* 当前页面/给定窗口的链接
*/
function getCurrentHref(win) {
win = win || content;
return win.document.location.href;
}
/**
*清理临时存储的变量
*/
function cleanVariable() {
try {
current = null;
next.link = next.found = next.digital = next.win = next.dir = next.searchFrom = null;
previous.link = previous.found = previous.win = previous.dir = previous.searchFrom = null;
first.link = first.found = first.win = first.dir = first.searchFrom = null;
last.link = last.found = last.win = last.dir = last.searchFrom = null;
} catch(e) {
}
}
//更新变量
function updateCurrent(item, window, notFound) {
current.link = item;
current.found = !notFound;
current.win = window;
}
function getVersion() {
var info = Components.classes["@mozilla.org/xre/app-info;1"]
.getService(Components.interfaces.nsIXULAppInfo);
return parseInt(info.version.substr(0, 3) * 10, 10) / 10;
}
//-----------------------------------------------------------------------------------
/**
* 检查特殊链接
*/
function checkDefinedNext(win, searchSub) {
win = win || content;
let doc = win.document;
//明确的地址
let search = function(array) {
for (let i = 0; i < array.length; i++) {
if (doc.location.href.match(array[i].url)) {
//alert(array[i].siteName)
let xpath = array[i][current.dir];
//字符串且是翻页
if (typeof(xpath) == "function" && searchSub) {
cleanVariable();
xpath();
return -1;
}
else {
//如果不存在规则,返回
if (!xpath || emptyRegexp.test(xpath)) return 0;
let link;
link = doc.evaluate(xpath, doc, null, 9, null).singleNodeValue;
//没有匹配的结果,继续检查
if (!link) continue;
current.link = link;
current.found = true;
current.win = win;
return 1;
}
}
}
};
if (search(rule.specialSite) || search(rule.specialCommon)) return 1;
//对子窗口应用特殊规则
if (searchSub) {
let f = win.frames;
for (let i = 0; i < f.length; i++) {
let c = checkDefinedNext(f[i]);
if (c == 1 || c == -1)return c;
}
}
}
function checkNext(window) {
window = window || content;
//检查连接
checkLinks(window);
if (current.found) return;
//检查按钮
checkTags(window, "INPUT")
//检查图片
if (current.found) return;
if (config.searchImg)
checkTags(window, "IMG")
}
/**
* 检查图片元素,和其他的元素
* @param window
* @param tag
*
*/
function checkTags(window, tag) {
let items = window.document.getElementsByTagName(tag);
let item,text;
for (let i = 0; i < items.length; i++) {
item = items[i];
if (!isEffective(item)) continue;
if (tag == "INPUT") {
//按钮的话,检查value属性
text = item.value;
}
else if (tag == "IMG")
//图片的话,就检查alt和title属性
text = item.alt || item.title;
else
//其他标签,就检查内容
text = item.innerHTML;
if (current.fullRegExp.test(text)) {
if(RegExp.$1=="" && RegExp.$2=="")continue;
//alert(RegExp.$2.toLowerCase())
if (current.continueTexts.indexOf(RegExp.$2.toLowerCase()) == -1 && current.continueTexts.indexOf(RegExp.$1.toLowerCase()) == -1) {
updateCurrent(item, window);
return;
}
else if (!isTempFound) {
isTempFound = true;
updateCurrent(item, window, true);
}
}
}
}
/**
*
*/
function checkLinks(window) {
let items = window.document.getElementsByTagName('A');
let item,text,value;
let isTempFound = 0;
for (let i = 0; i < items.length; i++) {
item = items[i];
if (!isEffective(item,window)) continue;
//textContent 加了title会不会有问题?
text = item.textContent || item.title;
//inner img
if (isEmpty(text)) {
let imgs = item.children;
for (let i = 0; i < imgs.length; i++) {
if (imgs[i].nodeName != "IMG")continue;
text = imgs[i].title || imgs[i].alt;
if (!isEmpty(text))break;
}
}
if (isEmpty(text))continue;
if (num.isDigital(text) && (isTempFound == 0) && (current.dir == "nextLink" || current.dir == "preLink")) {
//可能会误判,所以继续检测
let linkNumber = parseInt(RegExp.$1);
let type = (current.dir == "nextLink") ? -1 : 1;
let node = num.getPageNode(item, linkNumber, type, window.document);
if (node) {
isTempFound = 1;
//检测出来结果之后,并不结束,继续检查其他的连接,如果在没有其他的结果,才使用现在的这个
updateCurrent(item, window, true);
}
}
else {
if (current.fullRegExp.test(text)) {
if(RegExp.$1=="" && RegExp.$2=="")continue;
//可能的误判问题,$1可以得到实际匹配的结果
log("regexp is:" + RegExp.$1);
if (current.continueTexts.indexOf(RegExp.$2.toLowerCase()) == -1 && current.continueTexts.indexOf(RegExp.$1.toLowerCase()) == -1) {
updateCurrent(item, window);
return;
}
else if (isTempFound < 2) {
isTempFound = 2;
updateCurrent(item, window, true);
}
//这里似乎还是有问题啊,只能保存一次,不过获取到两次以上可能出错结果的情况应该不会太多吧
}
}
}
//将之前记录的通过翻页计算的结果作为最终的结果
if (!current.found && isTempFound) {
current.found = true;
return;
}
}
/**
* 判断元素是否是有效的,比如隐藏的,就被认为是无效的
* @param e
*/
function isEffective(e,win) {
//localname在3.5和之后的版本中是不一致的,为了避免这个问题,使用nodeName
if (e.nodeName == "A") {
//如果不是当前域,跳过
if(/^https?:/i.test(e.href)&&e.hostname!=win.location.hostname)
return false;
//有这个必要吗
if (e.href && !/^\s*$|^https?:|^javascript:|^file:/i.test(e.href))
return false;
// 跳过不起作用的链接
if (!e.offsetParent || e.offsetWidth == 0 || e.offsetHeight == 0 || (!e.hasAttribute("href") && !e.hasAttribute("onclick")))
return false;
// 跳过日历
if (/(?:^|\s)(?:monthlink|weekday|day|day[\-_]\S+)(?:\s|$)/i.test(e.className))
return false;
return true;
}
else if (e.nodeName == "IMG") {
//todo 对图像的初步的排查
return true;
}
else if (e.nodeName == "INPUT") {
if (e.disabled)return false;
if (e.type != "button" && e.type != "submit")return false;
return true;
//有的事件是通过addeventlistner添加的,所以这个应该取消掉
//if(!e.onclick)return false;
}
else {
//暂时没有用到
try {
return e.style.display != "none";
} catch(e) {
return false;
}
}
}
function checkNextInIframe(frame) {
if (frame) {
log("check special frame")
checkNext(frame);
}
else {
log("check all frames")
let f = content.frames;
for (let i = 0; i < f.length; i++) {
checkNext(f[i])
if (current.found) {
return;
}
}
}
}
var num = new function() {
// 取得相邻的纯数字节点,type: 1 下一个;-1 上一个
function getSiblingNode(node, type) {
if (!node) return null;
node = getSibling(node, type);
while (node && (node.nodeName == "#coment" ||
(/^\s*[\]]】]?[,\|]?\s*[\[[【]?\s*$/.test(node.textContent))))
node = getSibling(node, type);
return node;
}
function getSibling(aNode, type) {
if (!aNode) return null;
if (isOnlyNode(aNode)) {
try {
aNode = (type == 1 ? aNode.parentNode.nextSibling : aNode.parentNode.previousSibling);
if (skipNode(aNode))
aNode = (type == 1 ? aNode.nextSibling : aNode.previousSibling);
aNode = aNode.childNodes[0];
if (skipNode(aNode))
aNode = aNode.nextSibling;
}
catch (e) {
return null;
}
}
else {
aNode = (type == 1 ? aNode.nextSibling : aNode.previousSibling);
}
return aNode;
}
function isOnlyNode(n) {
return !n.nextSibling && !n.previousSibling ||
!n.nextSibling && skipNode(n.previousSibling) && !n.previousSibling.previousSibling ||
!n.previousSibling && skipNode(n.nextSibling) && !n.nextSibling.nextSibling ||
skipNode(n.previousSibling) && !n.previousSibling.previousSibling &&
skipNode(n.nextSibling) && !n.nextSibling.nextSibling;
}
function skipNode(sNode) {
return sNode && /*sNode.nodeName == "#text" &&*/ (/^\s*$/.test(sNode.textContent));
}
// 检测是否有下一页的纯数字链接,number:页数
function getNextLink(node, number, aSet) {
var tNode = getSiblingNode(node, 1);
if (tNode && tNode.nodeName == "A" && this.isDigital(tNode.textContent)) {
if (RegExp.$1 == number) {
// 找到纯数字链接
if (aSet) {
next.link = tNode;
next.found = true;
}
return tNode;
}
}
return null;
}
this.isDigital = function(str, t) {
str = str.replace(/^\s+|\s+$/g, "");
if (t == -1)
str = str.split(/\s+/).pop();
else if (t == 1)
str = str.split(/\s+/)[0];