musescore-downloader

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 0baf661c13d39964928d418f2fd52a0c15a5836a
parent afce6d6039ebadd3584505908dbe5ea6d6bd7b07
Author: Xmader <xmader@outlook.com>
Date:   Thu, 27 Feb 2020 12:11:47 -0500

fix: no id attribute at score images (#7)

Google chrome had no id attribute at score images. Fixed by checking the src attribute.
Diffstat:
Msrc/main.ts | 6+++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git 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"