Skip to content

Commit

Permalink
feat: add option onBeforeClosingPage
Browse files Browse the repository at this point in the history
  • Loading branch information
egoist committed Jul 31, 2020
1 parent e710e28 commit 9130cf1
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export type TakiOptions = {
onBeforeRequest?: (url: string) => void
onAfterRequest?: (url: string) => void
onCreatedPage?: (page: Page) => void | Promise<void>
onBeforeClosingPage?: (page: Page) => void | Promise<void>
minify?: boolean
resourceFilter?: (ctx: ResourceFilterCtx) => boolean
blockCrossOrigin?: boolean
Expand Down Expand Up @@ -83,6 +84,7 @@ async function getHTML(browser: Browser, options: TakiOptions) {
await page.waitForSelector(options.wait)
}
content = result ? result.content : await page.content()
options.onBeforeClosingPage && (await options.onBeforeClosingPage(page))
await page.close()
options.onAfterRequest && options.onAfterRequest(options.url)
const minifyOptions =
Expand Down

0 comments on commit 9130cf1

Please sign in to comment.