fix: no id attribute at score images (#7)
Google chrome had no id attribute at score images. Fixed by checking the src attribute.
This commit is contained in:
commit
0baf661c13
|
@ -15,7 +15,7 @@ const generatePDF = async (imgURLs: string[], imgType: "svg" | "png", name?: str
|
||||||
return saveAs(pdfBlob, `${name}.pdf`)
|
return saveAs(pdfBlob, `${name}.pdf`)
|
||||||
}
|
}
|
||||||
|
|
||||||
const cachedImg = document.querySelector("img[id^=score_]") as HTMLImageElement
|
const cachedImg = document.querySelector("img[src*=score_]") as HTMLImageElement
|
||||||
const { naturalWidth: width, naturalHeight: height } = cachedImg
|
const { naturalWidth: width, naturalHeight: height } = cachedImg
|
||||||
|
|
||||||
const worker = new PDFWorkerHelper()
|
const worker = new PDFWorkerHelper()
|
||||||
|
@ -31,13 +31,13 @@ const getPagesNumber = (scorePlayerData: ScorePlayerData) => {
|
||||||
try {
|
try {
|
||||||
return scorePlayerData.json.metadata.pages
|
return scorePlayerData.json.metadata.pages
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
return document.querySelectorAll("img[id^=score_]").length
|
return document.querySelectorAll("img[src*=score_]").length
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const getImgType = (): "svg" | "png" => {
|
const getImgType = (): "svg" | "png" => {
|
||||||
try {
|
try {
|
||||||
const imgE: HTMLImageElement = document.querySelector("img[id^=score_]")
|
const imgE: HTMLImageElement = document.querySelector("img[src*=score_]")
|
||||||
const { pathname } = new URL(imgE.src)
|
const { pathname } = new URL(imgE.src)
|
||||||
const imgtype = pathname.match(/\.(\w+)$/)[1]
|
const imgtype = pathname.match(/\.(\w+)$/)[1]
|
||||||
return imgtype as "svg" | "png"
|
return imgtype as "svg" | "png"
|
||||||
|
|
Loading…
Reference in New Issue