Google chrome had no id attribute at score images. Fixed by checking src attribute.

This commit is contained in:
Nikosar 2020-02-27 14:52:43 +03:00
parent afce6d6039
commit f0dd054481
1 changed files with 3 additions and 3 deletions

View File

@ -15,7 +15,7 @@ const generatePDF = async (imgURLs: string[], imgType: "svg" | "png", name?: str
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 worker = new PDFWorkerHelper()
@ -31,13 +31,13 @@ const getPagesNumber = (scorePlayerData: ScorePlayerData) => {
try {
return scorePlayerData.json.metadata.pages
} catch (_) {
return document.querySelectorAll("img[id^=score_]").length
return document.querySelectorAll("img[src*=score_]").length
}
}
const getImgType = (): "svg" | "png" => {
try {
const imgE: HTMLImageElement = document.querySelector("img[id^=score_]")
const imgE: HTMLImageElement = document.querySelector("img[src*=score_]")
const { pathname } = new URL(imgE.src)
const imgtype = pathname.match(/\.(\w+)$/)[1]
return imgtype as "svg" | "png"