From 4eade0ad46e8f17f766c484cf0bfa3e3de8adf8e Mon Sep 17 00:00:00 2001 From: Xmader Date: Thu, 19 Nov 2020 18:53:46 -0500 Subject: [PATCH] fix: download disabled on some scores --- src/btn.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/btn.ts b/src/btn.ts index d7db70e..e9afaef 100644 --- a/src/btn.ts +++ b/src/btn.ts @@ -9,10 +9,13 @@ type BtnElement = HTMLButtonElement const getBtnContainer = (): HTMLDivElement => { const container = document.querySelectorAll('aside>section>section')[0] - return [...container.children].find((div) => { + const btnParent = [...container.children].find((div) => { const b = div.querySelector('button, .button') - return b && b.outerHTML.replace(/\s/g, '').includes('Download') - }) as HTMLDivElement + const text = b ? b.outerHTML.replace(/\s/g, '') : '' + return text.includes('Download') || text.includes('Print') + }) as HTMLDivElement | null + if (!btnParent) throw new Error('btn parent not found') + return btnParent } const buildDownloadBtn = () => {