33// @name :zh-CN 自动无缝翻页
44// @name :zh-TW 自動無縫翻頁
55// @name :en AutoPager
6- // @version 5.4.6
6+ // @version 5.4.8
77// @author X.I.U
88// @description ⭐无缝衔接下一页内容到网页底部(类似瀑布流)⭐,目前支持:【所有「Discuz!、Flarum、phpBB、Xiuno、XenForo、NexusPHP...」论坛】【百度、谷歌(Google)、必应(Bing)、搜狗、微信、360、Yahoo、Yandex 等搜索引擎...】、贴吧、豆瓣、知乎、微博、NGA、V2EX、煎蛋网、龙的天空、起点中文、千图网、千库网、Pixabay、Pixiv、3DM、游侠网、游民星空、NexusMods、Steam 创意工坊、CS.RIN.RU、RuTracker、BT之家、萌番组、动漫花园、樱花动漫、爱恋动漫、AGE 动漫、Nyaa、SrkBT、RARBG、SubHD、423Down、不死鸟、扩展迷、小众软件、【动漫狂、漫画猫、漫画屋、漫画 DB、动漫之家、拷贝漫画、HiComic、Mangabz、Xmanhua 等漫画网站...】、PubMed、Z-Library、GreasyFork、Github、StackOverflow(以上仅一小部分,更多的写不下了...
99// @description :zh-TW ⭐無縫銜接下一頁內容到網頁底部(類似瀑布流)⭐,支持各論壇、社交、遊戲、漫畫、小說、學術、搜索引擎(Google、Bing、Yahoo...) 等網站~
8080 [ 'menu_rules' , '更新外置翻页规则 (每天自动)' , '更新外置翻页规则 (每天自动)' , { } ] ,
8181 [ 'menu_customRules' , '自定义翻页规则' , '自定义翻页规则' , { } ]
8282 ] , menuId = [ ] , webType = 0 , curSite = { SiteTypeID : 0 } , DBSite , SiteType , pausePage = true , pageNum = { now : 1 , _now : 1 } , urlC = false , nowLocation = '' , lp = location . pathname ;
83- window . autoPage = { lp : ( ) => location . pathname , indexOF : indexOF , isMobile : isMobile , isUrlC : isUrlC , forceTarget : forceTarget , getAll : getAll , getOne : getOne , getAllXpath : getAllXpath , getXpath : getXpath , getAllCSS : getAllCSS , getCSS : getCSS , getNextE : getNextE , getNextEP : getNextEP , getNextEPN : getNextEPN , getNextUPN : getNextUPN , getNextUP : getNextUP , getNextF : getNextF , getCookie : getCookie , insStyle : insStyle , insScript : insScript , src_bF : src_bF , xs_bF : xs_bF }
83+ window . autoPage = { lp : ( ) => location . pathname , indexOF : indexOF , isMobile : isMobile , isUrlC : isUrlC , blank : forceTarget , getAll : getAll , getOne : getOne , getAllXpath : getAllXpath , getXpath : getXpath , getAllCSS : getAllCSS , getCSS : getCSS , getNextE : getNextE , getNextEP : getNextEP , getNextEPN : getNextEPN , getNextUPN : getNextUPN , getNextUP : getNextUP , getNextF : getNextF , getCookie : getCookie , insStyle : insStyle , insScript : insScript , src_bF : src_bF , xs_bF : xs_bF }
8484
8585 for ( let i = 0 ; i < menuAll . length ; i ++ ) { // 如果读取到的值为 null 就写入默认值
8686 if ( GM_getValue ( menuAll [ i ] [ 0 ] ) == null ) { GM_setValue ( menuAll [ i ] [ 0 ] , menuAll [ i ] [ 3 ] ) } ;
235235 } else if ( getCSS ( 'link[href*="themes/begin" i], script[src*="themes/begin" i], img[src*="themes/begin" i]' ) ) {
236236 console . info ( `[自动无缝翻页] - 使用 WordPress <Begin> 主题的网站` ) ; return 103 ;
237237 } else if ( getCSS ( 'link[href*="/wp-content/" i], script[src*="/wp-content/" i]' ) ) {
238- if ( getAllCSS ( 'article[class]' ) . length > 2 && getCSS ( '#nav-below, nav.navigation, nav.pagination, ul .pagination, nav.paging-navigation , .wp-pagenavi, .pagenavi' ) ) {
238+ if ( getAllCSS ( 'article[class]' ) . length > 2 && getCSS ( '#nav-below, nav.navigation, nav.paging-navigation, .pagination, .wp-pagenavi, .pagenavi' ) ) {
239239 if ( getCSS ( 'a.next' ) ) {
240240 console . info ( `[自动无缝翻页] - 部分使用 WordPress 的网站 (a.next)` ) ; return 104 ;
241241 } else if ( getCSS ( 'a[rel="next" i], a[aria-label="Next Page" i], a[aria-label="下一页"]' ) ) {
244244 console . info ( `[自动无缝翻页] - 部分使用 WordPress 的网站 (li.next-page > a)` ) ; return 106 ;
245245 } else if ( getCSS ( '.nav-previous a' ) ) {
246246 console . info ( `[自动无缝翻页] - 部分使用 WordPress 的网站 (旧文章)` ) ; return 107 ;
247- } else if ( getXpath ( '//a[contains(text(), "下一页") or contains(text(), ">") or contains(text(), "next") or contains(text(), "Next") or contains(text(), "NEXT")]' , getCSS ( '#nav-below, nav.navigation, nav.pagination, ul .pagination, nav.paging-navigation , .wp-pagenavi, .pagenavi' ) ) ) {
247+ } else if ( getXpath ( '//a[contains(text(), "下一页") or contains(text(), ">") or contains(text(), "next") or contains(text(), "Next") or contains(text(), "NEXT")]' , getCSS ( '#nav-below, nav.navigation, nav.paging-navigation, .pagination, .wp-pagenavi, .pagenavi' ) ) ) {
248248 console . info ( `[自动无缝翻页] - 部分使用 WordPress 的网站 (下一页)` ) ; return 108 ;
249249 }
250250 }
290290 case 107 : // < 部分使用 WordPress 的网站 (旧文章) >
291291 DBSite . wp_article . url ( '.nav-previous a' ) ; break ;
292292 case 108 : // < 部分使用 WordPress 的网站 (下一页) >
293- DBSite . wp_article . url ( '//nav[@id="nav-below" or contains(@class, "navigation") or contains(@class, "pagination")]//a[contains(text(), "下一页") or contains(text(), ">") or contains(text(), "next") or contains(text(), "Next") or contains(text(), "NEXT")] | //ul[contains(@class, "pagination")]//a[contains(text(), "下一页") or contains(text(), ">") or contains(text(), "next") or contains(text(), "Next") or contains(text(), "NEXT")] | //div[ contains(@class, "pagenavi")]//a[contains(text(), "下一页") or contains(text(), ">") or contains(text(), "next") or contains(text(), "Next") or contains(text(), "NEXT")]' ) ; break ;
293+ DBSite . wp_article . url ( '//*[self::ul or self:: nav or self::div] [@id="nav-below" or contains(@class, "navigation") or contains(@class, "pagination") or contains(@class, "pagenavi")]//a[contains(text(), "下一页") or contains(text(), ">") or contains(text(), "next") or contains(text(), "Next") or contains(text(), "NEXT")]' ) ; break ;
294294 case 200 : // < 所有使用 笔趣阁 模板的小说网站 >
295295 DBSite . biquge . url ( ) ; break ;
296296 }
302302 url: 匹配到该域名后要执行的函数/正则(一般用于根据 URL 分配相应翻页规则)
303303 urlC: 对于使用 pjax 技术的网站,需要监听 URL 变化来重新判断翻页规则(需要放在 url: 中,自定义规则的话需要使用 fun.isUrlC())
304304
305- forceTarget: 强制新标签页打开链接
306305 noReferer: 获取下一页内容时,不携带 Referer(部分网站携带与不携带可能不一样)
307306 hiddenPN: 不显示脚本左下角的页码
308307 history: 添加历史记录 并 修改当前 URL(默认开启,对于不支持的网站要设置为 false)
309308 thread: 对于社区类网站,要在 帖子内 的规则中加入这个,用于脚本的 [帖子内自动翻页] 功能(即用户可以选择开启/关闭所有社区类网站帖子内的自动翻页)
310309 style: 要插入网页的 CSS Style 样式
311310 retry: 允许获取失败后重试
311+ blank: 强制新标签页打开链接(1 = base 方式,2 = 点击委托事件方式)
312312
313313pager: {
314314 type: 翻页模式
@@ -598,7 +598,7 @@ function: {
598598 url : function ( nextL ) { if ( ! indexOF ( '/post/' ) && ! getCSS ( '#comments, .comments-area, #disqus_thread' ) ) { curSite = DBSite . wp_article ; curSite . pager . nextL = nextL ; if ( getCSS ( 'img[data-src]' ) ) { curSite . function = { bF : "return fun.src_bF(pageE, [0, 'img[data-src]', 'data-src'])" } ; } else if ( getCSS ( 'img[data-original]' ) ) { curSite . function = { bF : "return fun.src_bF(pageE, [0, 'img[data-original]', 'data-original'])" } ; } } } ,
599599 pager : {
600600 pageE : 'article[class]' ,
601- replaceE : '#nav-below, nav.navigation, nav.pagination, ul .pagination, nav.paging-navigation , .wp-pagenavi, .pagenavi' ,
601+ replaceE : '#nav-below, nav.navigation, nav.paging-navigation, .pagination, .wp-pagenavi, .pagenavi' ,
602602 scrollD : 2000
603603 }
604604 } , // Wordpress 的 nav.navigation 规则
@@ -643,7 +643,7 @@ function: {
643643 }
644644 } , // 百度贴吧 - 帖子列表
645645 baidu_tieba_post : {
646- forceTarget : true ,
646+ blank : true ,
647647 thread : true ,
648648 style : '.d_sign_split, img.j_user_sign, .d_author .d_pb_icons, .save_face_bg, .save_face_bg_2, li.d_name a.icon_tbworld, .lzl_cnt a.icon_tbworld, .topic_list_box.topic-fixed {display: none !important;} a.p_author_face.j_frame_guide {background: none repeat scroll 0 0 #FFF !important;border: 1px solid #CCC !important;padding: inherit !important;} .red_text, .red-text, .vip_red, .vip-red, .vip_red:hover, .vip-red:hover, .vip_red:visited, .vip-red:visited {color: #2d64b3 !important;}' , // 签名、印记、头像边框、VIP 元素
649649 pager : {
@@ -1467,9 +1467,11 @@ function: {
14671467 }
14681468 } ,
14691469 onerror : function ( response ) {
1470+ console . log ( response )
14701471 GM_notification ( { text : '❌ 错误!更新失败,请联系作者解决...' , timeout : 5000 } ) ;
14711472 } ,
14721473 ontimeout : function ( response ) {
1474+ console . log ( response )
14731475 GM_notification ( { text : '❌ 超时!更新失败,请联系作者解决...' , timeout : 5000 } ) ;
14741476 }
14751477 } )
@@ -1493,8 +1495,8 @@ function: {
14931495 if ( GM_getValue ( 'menu_page_number' ) ) { pageNumber ( 'add' ) ; } else { pageNumber ( 'set' ) ; }
14941496 // 左键双击网页空白处暂停翻页
14951497 pausePageEvent ( ) ;
1496- // 强制新标签页打开链接(翻页模式 5/6)
1497- if ( curSite . forceTarget ) forceTarget ( ) ;
1498+ // 强制新标签页打开链接
1499+ if ( curSite . blank != undefined || curSite . forceTarget != undefined ) forceTarget ( ) ;
14981500
14991501 // 对于使用 pjax 技术的网站,需要监听 URL 变化来重新判断翻页规则
15001502 if ( urlC ) {
@@ -2612,6 +2614,14 @@ function: {
26122614 } catch ( e ) {
26132615 console . error ( '[自动无缝翻页] - 处理获取到的下一页内容时出现问题,请检查!' , e ) ;
26142616 }
2617+ } ,
2618+ onerror : function ( response ) {
2619+ console . log ( response )
2620+ GM_notification ( { text : '❌ 获取下一页失败...' , timeout : 5000 } ) ;
2621+ } ,
2622+ ontimeout : function ( response ) {
2623+ console . log ( response )
2624+ GM_notification ( { text : '❌ 获取下一页超时...' , timeout : 5000 } ) ;
26152625 }
26162626 } ) ;
26172627 }
@@ -2655,6 +2665,14 @@ function: {
26552665 } catch ( e ) {
26562666 console . log ( e ) ;
26572667 }
2668+ } ,
2669+ onerror : function ( response ) {
2670+ console . log ( response )
2671+ GM_notification ( { text : '❌ 获取下一页失败...' , timeout : 5000 } ) ;
2672+ } ,
2673+ ontimeout : function ( response ) {
2674+ console . log ( response )
2675+ GM_notification ( { text : '❌ 获取下一页超时...' , timeout : 5000 } ) ;
26582676 }
26592677 } ) ;
26602678 }
@@ -3173,32 +3191,38 @@ function: {
31733191 }
31743192
31753193
3176- // 强制新标签页打开链接(翻页模式 5/6)
3194+ // 强制新标签页打开链接
31773195 function forceTarget ( ) {
3178- document . body . addEventListener ( 'click' , function ( e ) {
3179- if ( e . target . tagName === 'A' ) {
3180- forceTarget_ ( e . target , e ) ;
3181- } else {
3182- let path = e . path || e . composedPath ( ) ;
3183- for ( let i = 1 ; i < path . length - 3 ; i ++ ) {
3184- //console.log(path[i])
3185- if ( path [ i ] . tagName === 'A' ) {
3186- forceTarget_ ( path [ i ] , e ) ;
3187- break ;
3196+ // 过渡
3197+ if ( curSite . forceTarget != undefined && curSite . blank == undefined ) curSite . blank = curSite . forceTarget
3198+ if ( curSite . blank === 1 ) {
3199+ document . head . appendChild ( document . createElement ( 'base' ) ) . target = '_blank' ;
3200+ } else if ( curSite . blank === 2 || curSite . blank === true ) {
3201+ document . body . addEventListener ( 'click' , function ( e ) {
3202+ if ( e . target . tagName === 'A' ) {
3203+ forceTarget_ ( e . target , e ) ;
3204+ } else {
3205+ let path = e . path || e . composedPath ( ) ;
3206+ for ( let i = 1 ; i < path . length - 3 ; i ++ ) {
3207+ //console.log(path[i])
3208+ if ( path [ i ] . tagName === 'A' ) {
3209+ forceTarget_ ( path [ i ] , e ) ;
3210+ break ;
3211+ }
31883212 }
31893213 }
3190- }
3191- } ) ;
3214+ } ) ;
31923215
3193- function forceTarget_ ( target , e ) {
3194- if ( target . href && target . target != '_blank' && ! ( target . getAttribute ( 'onclick' ) ) && target . href . slice ( 0 , 4 ) == 'http' && target . getAttribute ( 'href' ) . slice ( 0 , 1 ) != '#' ) {
3195- e . preventDefault ( ) ; // 阻止默认打开链接事件
3196- //console.log(target.href);
3197- //window.top.location.href = target.href;
3198- window . GM_openInTab ( target . href , { active : true , insert : true , setParent : true } ) ;
3216+ function forceTarget_ ( target , e ) {
3217+ if ( target . href && target . target != '_blank' && ! ( target . getAttribute ( 'onclick' ) ) && target . href . slice ( 0 , 4 ) == 'http' && target . getAttribute ( 'href' ) . slice ( 0 , 1 ) != '#' ) {
3218+ e . preventDefault ( ) ; // 阻止默认打开链接事件
3219+ //console.log(target.href);
3220+ //window.top.location.href = target.href;
3221+ window . GM_openInTab ( target . href , { active : true , insert : true , setParent : true } ) ;
3222+ }
31993223 }
3224+ //document.head.appendChild(document.createElement('base')).target = '_top';
32003225 }
3201- //document.head.appendChild(document.createElement('base')).target = '_top';
32023226 }
32033227 // 判断元素是否隐藏(隐藏返回 true)
32043228 function isHidden ( el ) {
@@ -3320,7 +3344,7 @@ function: {
33203344 "host": ["bbb1.com", "bbb2.com"],
33213345 "url": "/^\\/s$/",
33223346 "style": ".aaaa {display: none !important;}",
3323- "forceTarget ": true ,
3347+ "blank ": 1 ,
33243348 "hiddenPN": true,
33253349 "history": false,
33263350 "thread": true,
0 commit comments