I recently tried to intercept all image requests following the example in their documentation:
await page.route('**/*.{png,jpg,jpeg}', route => route.abort());
// Abort based on the request type
await page.route('**/*', route => {
return route.request().resourceType() === 'image' ?
route.abort() : route.continue();
});
But it was not working at all.
How can I make it work?
There is a missing string in the types (or they are outdated in v1.15.1):
When logging
route.request().resourceType()into console, I noticed there is a"images"resource type. So you can easily intercept any images including"images"to your check.For instance you could do like this: