diff --git a/src/btn.ts b/src/btn.ts index 63edfc5..204238e 100644 --- a/src/btn.ts +++ b/src/btn.ts @@ -9,11 +9,13 @@ import btnListCss from './btn.css' type BtnElement = HTMLButtonElement const getBtnContainer = (): HTMLDivElement => { - const container = document.querySelectorAll('section>section>section>section')[0] - const btnParent = [...container.children].find((div) => { - const b = div.querySelector('button, .button') - const text = b ? b.outerHTML.replace(/\s/g, '') : '' - return text.includes('Download') || text.includes('Print') + const containers = [...document.querySelectorAll('section>div div')] + const btnParent = containers.find(c => { + return [...c.children].find((div) => { + const b = div.querySelector('button, .button') + 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