@@ -15,12 +15,13 @@ export default class PixivComics extends Connector {
1515 this . apiURL = 'https://comic.pixiv.net/api/app/' ;
1616 this . requestOptions . headers . set ( 'x-referer' , this . url ) ;
1717 this . requestOptions . headers . set ( 'x-requested-with' , 'pixivcomic' ) ;
18- this . salt = 'M7w5HORvvX-VP4tRj2CFQOQFPocBqLvHTIbhTU36UCo ' ;
18+ this . nextBuild = 'qLzb8dhGOIox-xYNKI0tH ' ;
1919 }
2020
2121 async _initializeConnector ( ) {
22- const request = new Request ( new URL ( 'viewer/stories/0' , this . url ) , this . requestOptions ) ;
23- this . salt = await Engine . Request . fetchUI ( request , `JSON.parse(document.querySelector('#__NEXT_DATA__').text).props.pageProps.salt` ) ;
22+ const request = new Request ( new URL ( this . url ) , this . requestOptions ) ;
23+ const build = await Engine . Request . fetchUI ( request , `__NEXT_DATA__.buildId` ) ;
24+ this . nextBuild = build ? build : this . nextBuild ; //linter doesnt support ?? syntax
2425 }
2526
2627 async _getMangaFromURI ( uri ) {
@@ -81,8 +82,11 @@ export default class PixivComics extends Connector {
8182 }
8283
8384 async _getPages ( chapter ) {
85+
86+ const { pageProps : { salt } } = await this . fetchJSON ( new Request ( new URL ( `/_next/data/${ this . nextBuild } /viewer/stories/${ chapter . id } .json?id=${ chapter . id } ` , this . url ) ) ) ;
87+
8488 const timestamp = new Date ( ) . toISOString ( ) . replace ( / \. \d + Z $ / , 'Z' ) ;
85- const hash = CryptoJS . SHA256 ( timestamp + this . salt ) . toString ( CryptoJS . enc . Hex ) ;
89+ const hash = CryptoJS . SHA256 ( timestamp + salt ) . toString ( CryptoJS . enc . Hex ) ;
8690 const uri = new URL ( `episodes/${ chapter . id } /read_v4` , this . apiURL ) ;
8791 const request = new Request ( uri , this . requestOptions ) ;
8892 request . headers . set ( 'x-requested-with' , 'pixivcomic' ) ;
0 commit comments