fix: getBtnContainer
This commit is contained in:
		
							parent
							
								
									8c9c92ecc5
								
							
						
					
					
						commit
						a5c0dc77de
					
				
					 1 changed files with 7 additions and 5 deletions
				
			
		
							
								
								
									
										12
									
								
								src/btn.ts
									
										
									
									
									
								
							
							
						
						
									
										12
									
								
								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 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue