fix: getBtnContainer

This commit is contained in:
Xmader 2020-11-28 23:51:47 -05:00
parent 8c9c92ecc5
commit a5c0dc77de
No known key found for this signature in database
GPG Key ID: A20B97FB9EB730E4
1 changed files with 7 additions and 5 deletions

View File

@ -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