From f0dd0544815512bc111610f23d71fde5f00fd7d0 Mon Sep 17 00:00:00 2001 From: Nikosar <35628353+Nikosar@users.noreply.github.com> Date: Thu, 27 Feb 2020 14:52:43 +0300 Subject: [PATCH] Google chrome had no id attribute at score images. Fixed by checking src attribute. --- src/main.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main.ts b/src/main.ts index c872dff..623ac36 100644 --- a/src/main.ts +++ b/src/main.ts @@ -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"