11// ==UserScript==
22// @name 自动无缝翻页
3- // @version 3.7.6
3+ // @version 3.7.7
44// @author X.I.U
55// @description 无缝拼接下一页内容(瀑布流),目前支持:[所有「Discuz!、Flarum、phpBB、Xiuno、XenForo、DUX/XIU/D8/Begin(WP主题)」网站]、百度、谷歌、必应、搜狗、头条搜索、360 搜索、微信搜索、贴吧、豆瓣、知乎、微博、NGA、V2EX、B 站(Bilibili)、Pixiv、蓝奏云、煎蛋网、糗事百科、龙的天空、起点小说、IT之家、千图网、Pixabay、3DM、游侠网、游民星空、NexusMods、Steam 创意工坊、CS.RIN.RU、片库、茶杯狐、NO视频、低端影视、奈菲影视、音范丝、BT之家、萌番组、动漫花园、樱花动漫、爱恋动漫、AGE 动漫、Nyaa、SrkBT、RARBG、SubHD、423Down、不死鸟、扩展迷、极简插件、小众软件、动漫狂、漫画猫、漫画 DB、动漫之家、拷贝漫画、包子漫画、古风漫画网、Mangabz、PubMed、GreasyFork、Github、StackOverflow(以上仅一小部分,更多的写不下了...
66// @match *://*/*
@@ -128,9 +128,8 @@ pager: {
128128 scriptT: 单独插入 <script> 标签
129129 0 = 下一页的所有 <script> 标签
130130 1 = 下一页的所有 <script> 标签(不包括 src 链接)
131- 2 = 下一页 pageE 主体元素同级 <script> 标签
132- 3 = 下一页 pageE 主体元素同级 <script> 标签(src 远程文件)
133- 4 = 下一页 pageE 主体元素子元素 <script> 标签
131+ 2 = 下一页主体元素 (pageE) 的同级 <script> 标签
132+ 3 = 下一页主体元素 (pageE) 的子元素 <script> 标签
134133
135134 interval: 翻页后间隔时间(单位 ms)
136135 forceHTTPS: 下一页链接强制 HTTPS
@@ -140,7 +139,7 @@ function: {
140139 aF = 插入后执行函数
141140 pF = 参数
142141}
143- */ //<<< 自动翻页规则 >>>
142+ */ //<<< 规则简单说明 >>>
144143 DBSite = {
145144 discuz_forum : {
146145 pager : {
@@ -453,7 +452,7 @@ function: {
453452 pageE : 'css;.results > *' ,
454453 insertP : [ 'css;.results' , 3 ] ,
455454 replaceE : 'css;#pagebar_container' ,
456- scriptT : 4 ,
455+ scriptT : 3 ,
457456 scrollD : 1200
458457 }
459458 } , // 搜狗 搜索
@@ -945,7 +944,7 @@ function: {
945944 pageE : 'css;ol.commentlist > li[id^="comment-"], script[src^="//cdn.jandan.net/static/min/"]' ,
946945 insertP : [ 'css;ol.commentlist' , 3 ] ,
947946 replaceE : 'css;.cp-pagenavi' ,
948- scriptT : 3 ,
947+ scriptT : 2 ,
949948 scrollD : 1500
950949 }
951950 } , // 煎蛋网
@@ -1075,7 +1074,7 @@ function: {
10751074 pager : {
10761075 type : 1 ,
10771076 nextL : 'css;li.pagination-item.is-active+li > a' ,
1078- pageE : 'css;.data-wrapper > section.community-card' ,
1077+ pageE : 'css;.data-wrapper > section.community-card, style ' ,
10791078 insertP : [ 'css;.data-wrapper' , 3 ] ,
10801079 replaceE : '//ul[./li[contains(@class, "pagination-item")]]' ,
10811080 scrollD : 2000
@@ -1115,7 +1114,7 @@ function: {
11151114 pageE : 'css;#reply_list_panel > *, script[src*="ui/js/kds.js"]' ,
11161115 insertP : [ 'css;#reply_list_panel' , 3 ] ,
11171116 replaceE : 'css;.pages' ,
1118- scriptT : 3 ,
1117+ scriptT : 2 ,
11191118 scrollD : 1000
11201119 }
11211120 } , // 宽带山论坛 - 帖子内
@@ -1378,7 +1377,7 @@ function: {
13781377 pageE : 'css;.h-threads-list > *, script[src$="/h.desktop.js"]' ,
13791378 insertP : [ 'css;.h-threads-list' , 3 ] ,
13801379 replaceE : '//ul[contains(@class, "pagination")]' ,
1381- scriptT : 3 ,
1380+ scriptT : 2 ,
13821381 scrollD : 2000
13831382 }
13841383 } , // A 岛
@@ -1389,7 +1388,7 @@ function: {
13891388 pageE : 'css;.h-threads-list > .h-threads-item > .h-threads-item-replys, script[src$="/h.desktop.js"]' ,
13901389 insertP : [ 'css;.h-threads-list > .h-threads-item' , 3 ] ,
13911390 replaceE : '//ul[contains(@class, "pagination")]' ,
1392- scriptT : 3 ,
1391+ scriptT : 2 ,
13931392 scrollD : 2000
13941393 }
13951394 } , // A 岛 - 帖子内
@@ -1400,7 +1399,7 @@ function: {
14001399 pageE : 'css;.h-middle > div[id^="threads_"], .h-middle > hr.h-middle > div[id^="threads_"], .h-middle > hr:nth-of-type(n+2), script[src$="/h.mobile.js"]' ,
14011400 insertP : [ 'css;#h-threads-pagination' , 1 ] ,
14021401 replaceE : 'css;#h-threads-pagination' ,
1403- scriptT : 3 ,
1402+ scriptT : 2 ,
14041403 scrollD : 2000
14051404 }
14061405 } , // A 岛 - 帖子列表(手机版)
@@ -1411,7 +1410,7 @@ function: {
14111410 pageE : 'css;.h-threads-replylist > div, script[src$="/h.mobile.js"]' ,
14121411 insertP : [ 'css;.h-threads-replylist' , 3 ] ,
14131412 replaceE : 'css;#h-threads-pagination' ,
1414- scriptT : 3 ,
1413+ scriptT : 2 ,
14151414 scrollD : 2000
14161415 }
14171416 } , // A 岛 - 帖子内(手机版)
@@ -1773,7 +1772,7 @@ function: {
17731772 insertP : [ 'css;.news_warp_center' , 3 ] ,
17741773 replaceE : 'css;.pagewrap' ,
17751774 scrollE : 'css;.pagewrap' ,
1776- scriptT : 3 ,
1775+ scriptT : 2 ,
17771776 scrollD : 1000
17781777 }
17791778 } , // 3DM
@@ -3607,7 +3606,7 @@ function: {
36073606 pageE : 'css;#index > article, #archive > article' ,
36083607 insertP : [ 'css;ol.page-navigator' , 1 ] ,
36093608 replaceE : 'css;ol.page-navigator' ,
3610- scriptT : 4 ,
3609+ scriptT : 3 ,
36113610 scrollD : 1000
36123611 }
36133612 } , // 不死鸟
@@ -4622,7 +4621,7 @@ function: {
46224621 pageE : 'css;#cat_all > .cat_grid > div' ,
46234622 insertP : [ 'css;#cat_all > .cat_grid' , 3 ] ,
46244623 replaceE : 'css;#large_pagination' ,
4625- scriptT : 4 ,
4624+ scriptT : 3 ,
46264625 scrollD : 2000
46274626 }
46284627 } , // 指南
@@ -5706,7 +5705,7 @@ function: {
57065705 // hook imgDate 代码
57075706 SMH . imgData = function ( n ) { window [ 'imgDate' ] = n ; return { preInit :function ( ) { } } }
57085707 // 重新执行本页的 imgDate 代码
5709- insScriptAll ( curSite . pager . pageE ) ;
5708+ insScript ( curSite . pager . pageE ) ;
57105709 let _img = '' , imgPath = `${ location . protocol } //i.hamreus.com${ window [ 'imgDate' ] . path } ` ;
57115710 //console.log(imgPath, window['imgDate'])
57125711 if ( ! ( window [ 'imgDate' ] ) || ! ( imgPath ) ) return
@@ -5728,7 +5727,7 @@ function: {
57285727 function manhuagui_insertE ( pageElems , type ) {
57295728 if ( ! pageElems ) return
57305729 // 重新执行本页的 imgDate 代码
5731- insScriptAll ( curSite . pager . pageE , document . body , pageElems ) ;
5730+ insScript ( curSite . pager . pageE , document . body , pageElems ) ;
57325731 let _img = '' , imgPath = `${ location . protocol } //i.hamreus.com${ window [ 'imgDate' ] . path } ` ;
57335732 //console.log(imgPath, window['imgDate'])
57345733 if ( ! ( window [ 'imgDate' ] ) || ! ( imgPath ) ) return
@@ -5834,7 +5833,7 @@ function: {
58345833 function dmzj_insertE ( pageElems , type ) {
58355834 if ( ! pageElems ) return
58365835 // 插入并运行 <script>
5837- insScriptAll ( 'css;head > script[type]:not([src])' , document . body , pageElems ) ;
5836+ insScript ( 'css;head > script[type]:not([src])' , document . body , pageElems ) ;
58385837
58395838 // 插入图片
58405839 let _img = '' , _img_arr ;
@@ -5856,7 +5855,7 @@ function: {
58565855 function dmzj_manhua_insertE ( pageElems , type ) {
58575856 if ( ! pageElems ) return
58585857 // 插入并运行 <script>
5859- insScriptAll ( 'css;head > script[type]:not([src])' , document . body , pageElems ) ;
5858+ insScript ( 'css;head > script[type]:not([src])' , document . body , pageElems ) ;
58605859
58615860 // 插入图片
58625861 let _img = '' ;
@@ -5875,7 +5874,7 @@ function: {
58755874 function mhxqiu_insertE ( pageElems , type ) {
58765875 if ( ! pageElems ) return
58775876 // 插入并运行 <script>
5878- insScriptAll ( '//script[contains(text(), "eval") and contains(text(), "newImgs")]' , document . body , pageElems ) ;
5877+ insScript ( '//script[contains(text(), "eval") and contains(text(), "newImgs")]' , document . body , pageElems ) ;
58795878
58805879 // 插入图片
58815880 let _img = '' ;
@@ -5897,7 +5896,6 @@ function: {
58975896 let scriptElems = getXpath ( 'id("main")/script[contains(text(), "mhpicurl")][1]' , pageElems , pageElems ) ;
58985897 if ( scriptElems ) {
58995898 document . body . appendChild ( document . createElement ( 'script' ) ) . textContent = scriptElems . textContent . replace ( / d o c u m e n t \. w r i t e .+ / , '' ) ;
5900- //insScriptAll('id("main")/script[contains(text(), "mhpicurl")][1]', document.body, pageElems);
59015899
59025900 // 插入图片
59035901 setTimeout ( function ( ) {
@@ -5927,7 +5925,7 @@ function: {
59275925 function leyuman_insertE ( pageElems , type ) {
59285926 if ( ! pageElems ) return
59295927 // 插入并运行 <script>
5930- insScriptAll ( '//body//script[not(@src)][contains(text(), "z_img=")]' , document . body , pageElems ) ;
5928+ insScript ( '//body//script[not(@src)][contains(text(), "z_img=")]' , document . body , pageElems ) ;
59315929
59325930 // 插入图片
59335931 let _img = '' ;
@@ -5966,7 +5964,7 @@ function: {
59665964 function _77mh_insertE ( pageElems , type ) {
59675965 if ( ! pageElems ) return
59685966 // 插入并运行 <script>
5969- insScriptAll ( '//script[not(@src)][contains(text(), "eval(")]' , document . body , pageElems ) ;
5967+ insScript ( '//script[not(@src)][contains(text(), "eval(")]' , document . body , pageElems ) ;
59705968
59715969 // 插入图片
59725970 let _img = '' ;
@@ -6070,7 +6068,7 @@ function: {
60706068 }
60716069 } else { // 下一话
60726070 // 插入 <script> 标签
6073- insScriptAll ( 'css;html:not([dir]) > head > script:not([src])' , document . body , pageElems ) ;
6071+ insScript ( 'css;html:not([dir]) > head > script:not([src])' , document . body , pageElems ) ;
60746072 addHistory ( pageElems ) ;
60756073 pageNum . now = pageNum . _now + 1
60766074 replaceElems ( pageElems )
@@ -6109,7 +6107,7 @@ function: {
61096107 }
61106108 } else { // 下一话
61116109 // 插入 <script> 标签
6112- insScriptAll ( 'css;html:not([dir]) > head > script:not([src])' , document . body , pageElems ) ;
6110+ insScript ( 'css;html:not([dir]) > head > script:not([src])' , document . body , pageElems ) ;
61136111 addHistory ( pageElems ) ;
61146112 pageNum . now = pageNum . _now + 1
61156113 replaceElems ( pageElems )
@@ -6139,7 +6137,7 @@ function: {
61396137 function cocomanga_insertE ( pageElems , type ) {
61406138 if ( pageElems ) {
61416139 // 插入 <script> 标签
6142- insScriptAll ( 'css;head > script:not([src]), script[src*="custom.js"], script[src*="dynamicjs.js"]' , document . body , pageElems ) ;
6140+ insScript ( 'css;head > script:not([src]), script[src*="custom.js"], script[src*="dynamicjs.js"]' , document . body , pageElems ) ;
61436141
61446142 // 插入新图片元素
61456143 setTimeout ( function ( ) {
@@ -6497,23 +6495,16 @@ function: {
64976495 pageNum . now = pageNum . _now + 1
64986496
64996497 // 插入 <script> 标签
6500- if ( curSite . pager . scriptT ) {
6501- let scriptText = '' ;
6502- if ( curSite . pager . scriptT === 0 ) { // 下一页的所有 <script> 标签
6503- insScriptAll ( '//script' , toElement , response ) ;
6504- } else if ( curSite . pager . scriptT === 1 ) { // 下一页的所有 <script> 标签(不包括 src 链接)
6505- insScriptAll ( '//script[not(@src)]' , toElement , response ) ;
6506- } else if ( curSite . pager . scriptT === 2 ) { // 下一页主体元素同级 <script> 标签
6507- pageElems . forEach ( function ( one ) { if ( one . tagName === 'SCRIPT' ) { scriptText += ';' + one . textContent ; } } ) ;
6508- if ( scriptText ) toElement . appendChild ( document . createElement ( 'script' ) ) . textContent = scriptText ;
6509- } else if ( curSite . pager . scriptT === 3 ) { // 下一页主体元素同级 <script> 标签(src 远程文件)
6510- pageElems . forEach ( function ( one ) { if ( one . tagName === 'SCRIPT' && one . src ) { toElement . appendChild ( document . createElement ( 'script' ) ) . src = one . src ; } } ) ;
6511- } else if ( curSite . pager . scriptT === 4 ) { // 下一页主体元素子元素 <script> 标签
6512- pageElems . forEach ( function ( one ) {
6513- const scriptElems = one . querySelectorAll ( 'script' ) ;
6514- scriptElems . forEach ( function ( script ) { scriptText += ';' + script . textContent ; } ) ;
6515- } ) ;
6516- if ( scriptText ) toElement . appendChild ( document . createElement ( 'script' ) ) . textContent = scriptText ;
6498+ if ( curSite . pager . scriptT || curSite . pager . scriptT == 0 ) {
6499+ switch ( curSite . pager . scriptT ) {
6500+ case 0 : // 下一页的所有 <script> 标签
6501+ insScript ( 'css;script' , toElement , response ) ; break ;
6502+ case 1 : // 下一页的所有 <script> 标签(不包括 src 链接)
6503+ insScript ( 'css;script:not([src])' , toElement , response ) ; break ;
6504+ case 2 : // 下一页主体元素 (pageE) 的同级 <script> 标签
6505+ insScript ( null , toElement , pageElems ) ; break ;
6506+ case 3 : // 下一页主体元素 (pageE) 的子元素 <script> 标签
6507+ insScript ( 'css;script:not([src])' , toElement , pageElems ) ; break ;
65176508 }
65186509 }
65196510
@@ -6626,19 +6617,27 @@ function: {
66266617 window . top . document . xiu_nowUrl = curSite . pageUrl ;
66276618 window . top . history . pushState ( 'xiu_history' , title , url ) ;
66286619 }
6629- // 插入 Script
6630- function insScriptAll ( selector = '//script' , toElement = document . body , contextNode = document ) {
6631- let scriptElems = getAll ( selector , contextNode , contextNode ) , scriptText = '' ;
6632- scriptElems . forEach ( function ( one ) {
6633- if ( one . src ) {
6634- toElement . appendChild ( document . createElement ( 'script' ) ) . src = one . src ;
6620+ // 插入 < Script>
6621+ function insScript ( selector , toElement = document . body , contextNode = document ) {
6622+ let scriptElems = contextNode ;
6623+ if ( selector ) {
6624+ if ( contextNode instanceof Array ) {
6625+ scriptElems = [ ] ; contextNode . forEach ( function ( one ) { scriptElems = scriptElems . concat ( getAll ( selector , one , one ) ) ; } )
66356626 } else {
6636- scriptText += one . textContent + ';' ;
6627+ scriptElems = getAll ( selector , contextNode , contextNode ) ;
6628+ }
6629+ }
6630+ scriptElems . forEach ( function ( one ) {
6631+ if ( one . tagName === 'SCRIPT' ) {
6632+ if ( one . src ) {
6633+ toElement . appendChild ( document . createElement ( 'script' ) ) . src = one . src ;
6634+ } else {
6635+ toElement . appendChild ( document . createElement ( 'script' ) ) . textContent = one . textContent ;
6636+ }
66376637 }
66386638 } ) ;
6639- if ( scriptText ) toElement . appendChild ( document . createElement ( 'script' ) ) . textContent = scriptText ;
66406639 }
6641- // 插入 Style
6640+ // 插入 < Style>
66426641 function insStyle ( style ) {
66436642 document . lastElementChild . appendChild ( document . createElement ( 'style' ) ) . textContent = style ;
66446643 }
0 commit comments