import { Page } from 'puppeteer' ; const wait = ( millis ) => new Promise ( ( resolve ) => setTimeout ( resolve , millis ) ) ; const randomItem = ( array ) => array [ Math . floor ( Math . random ( ) * array . length ) ] ; function injectFindElement ( page ) { return page . evaluate ( ( ) => { ; ( < any > window ) . findElement = ( tag , text ) => { const els = < any > document . querySelectorAll ( '*' ) ; for ( let el of els ) { if ( el . innerHTML && el . innerHTML . toLowerCase ( ) === text ) { return el . tagName . toLowerCase ( ) === tag ? el : el . closest ( tag ) ; } } } ; } ) ; } export { wait , randomItem , injectFindElement } ;