@@ -638,14 +638,9 @@ try {
638638 // #国外R18[hdoujin](https://hdoujin.org)
639639 // test: https://hdoujin.org/g/95756/2d1aa56c3325
640640 case 'hdoujin.org' : {
641- if ( ! location . pathname . startsWith ( '/g/' ) ) break ;
642-
643641 // https://github.com/dyphire/hentai-assistant/blob/hdoujin/src/providers/hdoujin_api.py
644-
645642 const clearance = localStorage . getItem ( 'clearance' ) ;
646- const reRes = location . pathname . match ( / \/ g \/ ( \d + ) \/ ( .+ ) / ) ;
647- if ( ! reRes || ! clearance ) throw new Error ( t ( 'site.changed_load_failed' ) ) ;
648- const [ , id , key ] = reRes ;
643+ if ( ! clearance ) throw new Error ( t ( 'site.changed_load_failed' ) ) ;
649644
650645 const api = async < T > ( url : string , details ?: RequestDetails < T > ) => {
651646 const res = await request < T > (
@@ -658,15 +653,26 @@ try {
658653 options = {
659654 name : 'hdoujin' ,
660655 getImgList : async ( { dynamicLazyLoad } ) => {
656+ const reRes = location . pathname . match ( / \/ g \/ ( \d + ) \/ ( .+ ) / ) ;
657+ if ( ! reRes ) throw new Error ( t ( 'site.changed_load_failed' ) ) ;
658+ const [ , id , key ] = reRes ;
659+
661660 type ExtraData = { id : string ; key : string ; size : string } ;
662661 const { data } = await api < { data : Record < string , ExtraData > } > (
663662 `/books/detail/${ id } /${ key } ` ,
664663 { method : 'POST' } ,
665664 ) ;
666665
667- // 使用原图分辨率
668- const size = '1280' ;
666+ // 选择最高分辨率
667+ const [ [ size ] ] = Object . entries ( data )
668+ . filter ( ( [ , data ] ) => data . id && data . key )
669+ . toSorted ( ( [ a ] , [ b ] ) => {
670+ if ( a === '0' ) return - 1 ;
671+ if ( b === '0' ) return 1 ;
672+ return Number ( b ) - Number ( a ) ;
673+ } ) ;
669674 const { id : dataId , key : dataKey } = data [ size ] ;
675+
670676 const { base, entries } = await api < {
671677 base : string ;
672678 entries : { path : string } [ ] ;
@@ -693,6 +699,9 @@ try {
693699 } ,
694700 } ) ;
695701 } ,
702+ SPA : {
703+ isMangaPage : ( ) => location . pathname . startsWith ( '/g/' ) ,
704+ } ,
696705 } ;
697706 break ;
698707 }
0 commit comments