fix: getBtnContainer
This commit is contained in:
parent
8c9c92ecc5
commit
a5c0dc77de
12
src/btn.ts
12
src/btn.ts
|
@ -9,11 +9,13 @@ import btnListCss from './btn.css'
|
||||||
type BtnElement = HTMLButtonElement
|
type BtnElement = HTMLButtonElement
|
||||||
|
|
||||||
const getBtnContainer = (): HTMLDivElement => {
|
const getBtnContainer = (): HTMLDivElement => {
|
||||||
const container = document.querySelectorAll('section>section>section>section')[0]
|
const containers = [...document.querySelectorAll('section>div div')]
|
||||||
const btnParent = [...container.children].find((div) => {
|
const btnParent = containers.find(c => {
|
||||||
const b = div.querySelector('button, .button')
|
return [...c.children].find((div) => {
|
||||||
const text = b ? b.outerHTML.replace(/\s/g, '') : ''
|
const b = div.querySelector('button, .button')
|
||||||
return text.includes('Download') || text.includes('Print')
|
const text = b ? b.outerHTML.replace(/\s/g, '') : ''
|
||||||
|
return text.includes('Download') || text.includes('Print')
|
||||||
|
})
|
||||||
}) as HTMLDivElement | null
|
}) as HTMLDivElement | null
|
||||||
if (!btnParent) throw new Error('btn parent not found')
|
if (!btnParent) throw new Error('btn parent not found')
|
||||||
return btnParent
|
return btnParent
|
||||||
|
|
Loading…
Reference in New Issue