How to use
- Import these two:
import { injectOptions, utilHooks } from 'apify-eventlisteners'
- Configure your crawler with them:
const crawler = new Apify.PlaywrightCrawler({
...injectOptions,
requestList,
preNavigationHooks: [...utilHooks],
handlePageFunction: async ({ page }) => {
...
},
});
- Use the custom methods:
page.eventListenerList(selector: string)
(selector: string) => Promise<ElementListeners[]>
Returns all found event listeners for all elements matching the specified selector. Ex:
[
[
{
type: 'click'
},
{
type: 'mouseover'
}
],
[
{
type: 'click'
}
]
]
(selectors: string[]) => Promise<void>
Removes event listeners from all elements on the page except for on the ones specified in the array.
Note: Ensure that the event listener has been added to the an prior to trying to remove it with this.
(selector: string) => Promise<void>
Remove all event listeners from a single element.