diff --git a/src/pdf.ts b/src/pdf.ts index 0ff0984..ffa7830 100644 --- a/src/pdf.ts +++ b/src/pdf.ts @@ -29,7 +29,7 @@ export const downloadPDF = async (): Promise => { const rs = Array.from({ length: pageCount }).map((_, i) => { if (i === 0) { // The url to the first page is static. We don't need to use API to obtain it. - return scoreinfo.baseUrl + `score_${i}.${imgType}` + return scoreinfo.thumbnailUrl } else { // obtain image urls using the API return getFileUrl('img', i) } diff --git a/src/scoreinfo.ts b/src/scoreinfo.ts index c1b6304..a5eedfc 100644 --- a/src/scoreinfo.ts +++ b/src/scoreinfo.ts @@ -20,13 +20,11 @@ export const scoreinfo = { return document.querySelectorAll('.gXB83').length }, - get baseUrl (this: typeof scoreinfo): string { + get thumbnailUrl (this: typeof scoreinfo): string { + // url to the image of the first page const el = document.querySelector("meta[property='og:image']") as HTMLMetaElement - const thumbnailUrl = el.content - - const { origin, pathname } = new URL(thumbnailUrl) - // remove the last part - return origin + pathname.split('/').slice(0, -1).join('/') + '/' + const url = el.content + return url.split('@')[0] }, get sheetImgType (): 'svg' | 'png' {