8
8
} from '../helpers/batchDownload' ;
9
9
import { config , type ConfigData } from '@/lib/config' ;
10
10
import { getSelfId } from '@/sites/pixiv/helpers/getSelfId' ;
11
+ import { logger } from '@/lib/logger' ;
11
12
12
13
export type FilterOption = Pick <
13
14
ConfigData ,
@@ -247,11 +248,21 @@ export function createFollowLatestDownloadBar() {
247
248
return ;
248
249
}
249
250
250
- const nav = document . querySelector ( 'nav' ) ;
251
- if ( ! nav || nav . parentElement ! . childElementCount === 1 ) return ;
251
+ const navBar = document . querySelector < HTMLDivElement > ( 'section > div:nth-child(3)' ) ;
252
+ if ( ! navBar || navBar . childElementCount !== 2 ) {
253
+ logger . warn ( 'Can not find container for download bar.' ) ;
254
+ return ;
255
+ }
256
+
257
+ const baseClassesEl = document . querySelector < HTMLAnchorElement > (
258
+ 'section > div:first-child a:not([aria-current])'
259
+ ) ;
260
+ if ( ! baseClassesEl ) {
261
+ logger . warn ( 'Can not find styled element for download bar.' ) ;
262
+ return ;
263
+ }
252
264
253
- const navBar = nav . parentElement as HTMLDivElement ;
254
- const modeSwitch = nav . nextElementSibling as HTMLDivElement ;
265
+ const modeSwitch = navBar . children [ 1 ] as HTMLDivElement ;
255
266
const filter = createFilter ( ) ;
256
267
navBar . parentElement ! . insertBefore ( filter , navBar ) ;
257
268
@@ -264,7 +275,7 @@ export function createFollowLatestDownloadBar() {
264
275
dlBarRef . statusBar = dlBar . appendChild ( statusBar ) ;
265
276
266
277
//下载按钮
267
- const baseClasses = nav . querySelector < HTMLAnchorElement > ( 'a:not([aria-current])' ) ! . classList ;
278
+ const baseClasses = baseClassesEl . classList ;
268
279
269
280
dlBarRef . abortBtn = dlBar . appendChild (
270
281
createPdlBtn ( {
0 commit comments