From eda8342a3df055bd3eff4c9c38ac9caf5faebfda Mon Sep 17 00:00:00 2001 From: Xmader Date: Wed, 27 Jan 2021 11:31:09 -0500 Subject: [PATCH] fix: PDF download when the piano keyboard is open --- src/scoreinfo.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/scoreinfo.ts b/src/scoreinfo.ts index 4056800..ff441bc 100644 --- a/src/scoreinfo.ts +++ b/src/scoreinfo.ts @@ -105,9 +105,12 @@ export abstract class SheetInfo { export class SheetInfoInPage extends SheetInfo { constructor (private document: Document) { super() } + private get sheet0Img (): HTMLImageElement | null { + return this.document.querySelector('img[src*=score_]') + } + get pageCount (): number { - const sheet0Img = this.document.querySelector('img[src*=score_]') - const sheet0Div = sheet0Img?.parentElement + const sheet0Div = this.sheet0Img?.parentElement if (!sheet0Div) { throw new Error('no sheet images found') } @@ -116,8 +119,8 @@ export class SheetInfoInPage extends SheetInfo { get thumbnailUrl (): string { // url to the image of the first page - const el = this.document.querySelector('link[as=image]') as HTMLLinkElement - const url = el.href + const el = this.document.querySelector('link[as=image]') + const url = (el?.href || this.sheet0Img?.src) as string return url.split('@')[0] } }