diff --git a/src/web/mjs/connectors/PixivComics.mjs b/src/web/mjs/connectors/PixivComics.mjs index d9ffe21a3d..b0a62ab229 100644 --- a/src/web/mjs/connectors/PixivComics.mjs +++ b/src/web/mjs/connectors/PixivComics.mjs @@ -15,12 +15,13 @@ export default class PixivComics extends Connector { this.apiURL = 'https://comic.pixiv.net/api/app/'; this.requestOptions.headers.set('x-referer', this.url); this.requestOptions.headers.set('x-requested-with', 'pixivcomic'); - this.salt = 'M7w5HORvvX-VP4tRj2CFQOQFPocBqLvHTIbhTU36UCo'; + this.nextBuild = 'qLzb8dhGOIox-xYNKI0tH'; } async _initializeConnector() { - const request = new Request(new URL('viewer/stories/0', this.url), this.requestOptions); - this.salt = await Engine.Request.fetchUI(request, `JSON.parse(document.querySelector('#__NEXT_DATA__').text).props.pageProps.salt`); + const request = new Request(new URL(this.url), this.requestOptions); + const build = await Engine.Request.fetchUI(request, `__NEXT_DATA__.buildId`); + this.nextBuild = build ? build : this.nextBuild; //linter doesnt support ?? syntax } async _getMangaFromURI(uri) { @@ -81,8 +82,11 @@ export default class PixivComics extends Connector { } async _getPages(chapter) { + + const { pageProps: { salt } } = await this.fetchJSON(new Request(new URL(`/_next/data/${this.nextBuild}/viewer/stories/${chapter.id}.json?id=${chapter.id}`, this.url))); + const timestamp = new Date().toISOString().replace(/\.\d+Z$/, 'Z'); - const hash = CryptoJS.SHA256(timestamp + this.salt).toString(CryptoJS.enc.Hex); + const hash = CryptoJS.SHA256(timestamp + salt).toString(CryptoJS.enc.Hex); const uri = new URL(`episodes/${chapter.id}/read_v4`, this.apiURL); const request = new Request(uri, this.requestOptions); request.headers.set('x-requested-with', 'pixivcomic');