mirror of
https://github.com/geekgeekrun/geekgeekrun.git
synced 2026-09-04 23:17:39 +08:00
change package name from launch-browser-with-preload-extension to launch-bosszhipin-login-page-with-preload-extension
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
export async function blockNavigation(page, predictor = (url) => true) {
|
||||
console.log(`block navigation for puppeteer page from url ${page.url()}`)
|
||||
await page.setRequestInterception(true)
|
||||
|
||||
const handler = (req) => {
|
||||
if (req.isNavigationRequest() && req.frame() === page.mainFrame() && predictor(req)) {
|
||||
req.abort('aborted')
|
||||
} else {
|
||||
try {
|
||||
req.continue()
|
||||
} catch {
|
||||
//
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
page.on('request', handler)
|
||||
|
||||
return {
|
||||
dispose: async () => {
|
||||
page.off('request', handler)
|
||||
await page.setRequestInterception(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user