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

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