refactor: replace base url with thumbnail url
This commit is contained in:
parent
ddfe2039b1
commit
c334d8d124
2 changed files with 5 additions and 7 deletions
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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' {
|
||||
|
|
Loading…
Reference in a new issue