33// @name :zh-CN 自动无缝翻页
44// @name :zh-TW 自動無縫翻頁
55// @name :en AutoPager
6- // @version 6.0.18
6+ // @version 6.1.0
77// @author X.I.U
88// @description ⭐无缝加载 下一页内容 至网页底部(类似瀑布流)⭐,目前支持:【所有「Discuz!、Flarum、phpBB、Xiuno、XenForo、NexusPHP...」论坛】【百度、谷歌(Google)、必应(Bing)、搜狗、微信、360、Yahoo、Yandex 等搜索引擎...】、贴吧、豆瓣、知乎、B 站(bilibili)、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...) 等網站~
123123 for ( let i = 0 ; i < menuAll . length ; i ++ ) { // 如果读取到的值为 null 就写入默认值
124124 if ( GM_getValue ( menuAll [ i ] [ 0 ] ) == null ) { GM_setValue ( menuAll [ i ] [ 0 ] , menuAll [ i ] [ 3 ] ) } ;
125125 }
126-
126+ console . log ( '1111111111111111111111111111111111111111111111' )
127127 getRulesUrl ( ) ;
128128 registerMenuCommand ( ) ;
129129 if ( menuId . length < 4 ) { return }
182182 end:
183183 for ( let now in DBSite ) { // 遍历 对象
184184 if ( ! DBSite [ now ] . host ) continue ; // 如果不存在则继续下一个循环
185- //console.log(DBSite[now].host)
186185 // 如果是 数组
186+
187187 if ( Array . isArray ( DBSite [ now ] . host ) ) {
188188
189189 for ( let i of DBSite [ now ] . host ) { // 遍历 数组
190+
190191 // 针对自定义翻页规则中的正则
191192 if ( typeof i === 'string' && i . slice ( 0 , 1 ) === '/' ) i = new RegExp ( i . slice ( 1 , i . length - 1 ) )
192193 if ( ( i instanceof RegExp && i . test ( location . hostname ) ) || ( typeof i === 'string' && i === location . hostname ) ) {
193194
194- if ( self != top ) { if ( ! DBSite [ now ] . iframe ) break end; } // 如果当前位于 iframe 框架下,就需要判断是否需要继续执行
195+ if ( self != top ) { if ( ! DBSite [ now ] . iframe ) continue end; } // 如果当前位于 iframe 框架下,就需要判断是否需要继续执行
195196 if ( DBSite [ now ] . url ) {
196197 if ( typeof DBSite [ now ] . url == 'function' ) {
197198 DBSite [ now ] . url ( ) ;
219220 if ( typeof DBSite [ now ] . host === 'string' && DBSite [ now ] . host . slice ( 0 , 1 ) === '/' ) DBSite [ now ] . host = new RegExp ( DBSite [ now ] . host . slice ( 1 , DBSite [ now ] . host . length - 1 ) )
220221 if ( ( DBSite [ now ] . host instanceof RegExp && DBSite [ now ] . host . test ( location . hostname ) ) || ( typeof DBSite [ now ] . host === 'string' && DBSite [ now ] . host === location . hostname ) ) {
221222
222- if ( self != top ) { if ( ! DBSite [ now ] . iframe ) break ; } // 如果当前位于 iframe 框架下,就需要判断是否需要继续执行
223+ if ( self != top ) { if ( ! DBSite [ now ] . iframe ) continue ; } // 如果当前位于 iframe 框架下,就需要判断是否需要继续执行
223224 if ( DBSite [ now ] . url ) {
224225 if ( typeof DBSite [ now ] . url == 'function' ) {
225226 DBSite [ now ] . url ( ) ;
@@ -1927,14 +1928,11 @@ function: {
19271928
19281929 // 创建 iframe
19291930 let iframe = document . createElement ( 'iframe' ) ;
1930- if ( location . hostname == 'www.cocomanga.com' ) {
1931- iframe . style = 'position: absolute; width: 100%; height: 100%; border: none;' ;
1932- } else {
1933- iframe . style = 'position: absolute !important; width: 100% !important; height: 100% !important; border: none !important;' ;
1934- }
19351931 iframe . id = 'Autopage_iframe' ;
19361932 iframe . src = src . replace ( / # .+ $ / , '' ) ;
19371933
1934+ document . documentElement . appendChild ( document . createElement ( 'style' ) ) . textContent = 'iframe#Autopage_iframe {position: absolute !important; width: 100% !important; height: 100% !important; border: none !important;}' ;
1935+
19381936 var beforeScrollTop = document . documentElement . scrollTop || document . body . scrollTop
19391937 // 当滚动条到底部时(即完全显示 iframe 框架),隐藏当前页面的滚动条
19401938 window . addEventListener ( 'scroll' , function ( ) {
@@ -1954,27 +1952,31 @@ function: {
19541952 document . documentElement . appendChild ( newStyle ) ;
19551953
19561954 // 恢复 iframe 的滚动条
1957- if ( iframe . contentWindow . document . querySelector ( '#Autopage_iframe-scroll-hidden' ) ) iframe . contentWindow . document . querySelector ( '#Autopage_iframe-scroll-hidden' ) . remove ( ) ;
1955+ if ( iframe . contentWindow . document . querySelectorAll ( '#Autopage_iframe-scroll-hidden' ) ) iframe . contentWindow . document . querySelectorAll ( '#Autopage_iframe-scroll-hidden' ) . forEach ( ( o ) => { o . remove ( ) ; } ) ;
19581956
19591957 // 给予 iframe 焦点
19601958 iframe . focus ( ) ;
19611959 if ( iframe . contentWindow . document . body ) { iframe . contentWindow . document . body . focus ( ) ; iframe . contentWindow . document . body . click ( ) ; }
19621960 } else if ( delta < 0 && scrollTop + clientHeight + 10 <= scrollHeight && getCSS ( '#Autopage_iframe-scroll' ) ) {
19631961 getCSS ( '#Autopage_iframe-scroll' ) . remove ( ) ;
1964-
19651962 // 再次禁用 iframe 的滚动条
1966- let newStyle = document . createElement ( 'style' ) ; newStyle . id = 'Autopage_iframe-scroll-hidden' ;
1967- newStyle . textContent = 'html, body {overflow: hidden !important;}' ;
1968- iframe . contentWindow . document . documentElement . appendChild ( newStyle ) ;
1963+ if ( ! iframe . contentWindow . document . getElementById ( 'Autopage_iframe-scroll-hidden' ) ) {
1964+ let newStyle = document . createElement ( 'style' ) ; newStyle . id = 'Autopage_iframe-scroll-hidden' ;
1965+ newStyle . textContent = 'html, body {overflow: hidden !important;}' ;
1966+ iframe . contentWindow . document . documentElement . appendChild ( newStyle ) ;
1967+ }
19691968 }
19701969 } , false ) ;
19711970
19721971 // 加载完成后才继续
19731972 iframe . onload = function ( ) {
19741973 // 暂时禁用 iframe 的滚动条
1975- let newStyle = document . createElement ( 'style' ) ; newStyle . id = 'Autopage_iframe-scroll-hidden' ;
1976- newStyle . textContent = 'html, body {overflow: hidden !important;}' ;
1977- iframe . contentWindow . document . documentElement . appendChild ( newStyle ) ;
1974+ if ( ! getCSS ( '#Autopage_iframe-scroll' ) && ! iframe . contentWindow . document . getElementById ( 'Autopage_iframe-scroll-hidden' ) ) {
1975+
1976+ let newStyle = document . createElement ( 'style' ) ; newStyle . id = 'Autopage_iframe-scroll-hidden' ;
1977+ newStyle . textContent = 'html, body {overflow: hidden !important;}' ;
1978+ iframe . contentWindow . document . documentElement . appendChild ( newStyle ) ;
1979+ }
19781980
19791981 // 添加历史记录
19801982 if ( curSite . history === undefined ) {
@@ -2007,10 +2009,11 @@ function: {
20072009 let iframe = document . getElementById ( 'Autopage_iframe' ) ;
20082010 if ( ! iframe ) {
20092011 iframe = document . createElement ( 'iframe' ) ;
2010- iframe . style = 'position: absolute !important; top: -9999px !important; left: -9999px !important; width: 100% !important; height: 100% !important; border: none !important; z-index: -999 !important;' ;
20112012 //iframe.sandbox = 'allow-same-origin allow-scripts allow-popups allow-forms';
20122013 iframe . id = 'Autopage_iframe' ;
20132014 iframe . src = src . replace ( / # .+ $ / , '' ) ;
2015+
2016+ document . documentElement . appendChild ( document . createElement ( 'style' ) ) . textContent = 'iframe#Autopage_iframe {position: absolute !important; top: -9999px !important; left: -9999px !important; width: 100% !important; height: 100% !important; border: none !important; z-index: -999 !important;}' ;
20142017 }
20152018
20162019 // 加载完成后才继续
0 commit comments