@@ -14,6 +14,9 @@ import { getAdPageByContent } from 'userscript/detectAd';
1414
1515import { getNhentaiData , toImgList } from '../userscript/nhentaiApi' ;
1616
17+ /** 等待水合完成,确保之后的 dom 操作不会被水合覆盖 */
18+ const waitHydrated = ( ) => waitDom ( '#svelte-announcer' , 1000 * 5 ) ;
19+
1720universalSPA ( 'nhentai' , {
1821 options : {
1922 /** 无限滚动 */
@@ -51,6 +54,7 @@ universalSPA('nhentai', {
5154 } ,
5255 } ) ;
5356
57+ await waitHydrated ( ) ;
5458 const comicReadModeDom = (
5559 < a
5660 href = "javascript:;"
@@ -109,8 +113,7 @@ universalSPA('nhentai', {
109113 if ( options . block_totally )
110114 useStyle ( '.blacklisted.gallery { display: none; }' ) ;
111115
112- /** 等待水合完成,确保之后的 dom 操作不会被水合覆盖 */
113- await waitDom ( '#svelte-announcer' , 1000 * 5 ) ;
116+ await waitHydrated ( ) ;
114117
115118 if ( options . open_link_new_page )
116119 for ( const e of querySelectorAll ( 'a:not([href^="javascript:"])' ) )
@@ -127,9 +130,9 @@ universalSPA('nhentai', {
127130 hr:not(:last-child) { display: none; }
128131 @keyframes load { 0% { width: 100%; } 100% { width: 0; } }
129132 ` ) ;
130- const getContentDom = ( ) => document . getElementById ( 'content' ) ! ;
133+ const contentDom = document . getElementById ( 'content' ) ! ;
131134 const getObserveDom = ( ) =>
132- getContentDom ( ) . querySelector (
135+ contentDom . querySelector (
133136 ':is(.index-container, #favcontainer):last-of-type' ,
134137 ) ! ;
135138
@@ -150,13 +153,13 @@ universalSPA('nhentai', {
150153 nextUrl =
151154 pagination . querySelector < HTMLAnchorElement > ( 'a.next' ) ?. href ;
152155
153- getContentDom ( ) . append (
156+ contentDom . append (
154157 html . querySelector ( '.index-container, #favcontainer' ) ! ,
155158 pagination ,
156159 ) ;
157160
158161 const hr = document . createElement ( 'hr' ) ;
159- getContentDom ( ) . append ( hr ) ;
162+ contentDom . append ( hr ) ;
160163 observer . disconnect ( ) ;
161164 observer . observe ( getObserveDom ( ) ) ;
162165 if ( ! nextUrl ) hr . style . animationPlayState = 'paused' ;
@@ -171,7 +174,7 @@ universalSPA('nhentai', {
171174 observer . observe ( getObserveDom ( ) ) ;
172175
173176 if ( querySelector ( 'section.pagination' ) )
174- getContentDom ( ) . append ( document . createElement ( 'hr' ) ) ;
177+ contentDom . append ( document . createElement ( 'hr' ) ) ;
175178
176179 return ( ) => observer . disconnect ( ) ;
177180 }
0 commit comments