refactor: replace base url with thumbnail url

This commit is contained in:
Xmader 2020-11-24 02:10:56 -05:00
parent ddfe2039b1
commit c334d8d124
No known key found for this signature in database
GPG Key ID: A20B97FB9EB730E4
2 changed files with 5 additions and 7 deletions

View File

@ -29,7 +29,7 @@ export const downloadPDF = async (): Promise<void> => {
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)
}

View File

@ -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' {