Package Exports
- puppeteer-extra-plugin-notbody-block-resources
- puppeteer-extra-plugin-notbody-block-resources/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (puppeteer-extra-plugin-notbody-block-resources) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
puppeteer-extra-plugin-block-resources
A plugin for puppeteer-extra.
Install
yarn add puppeteer-extra-plugin-block-resourcesAPI
Table of Contents
Plugin
Extends: PuppeteerExtraPlugin
Block resources (images, media, css, etc.) in puppeteer.
Supports all resource types, blocking can be toggled dynamically.
Type: function (opts)
optsObject Options (optional, default{})
Example:
const { DEFAULT_INTERCEPT_RESOLUTION_PRIORITY } = require('puppeteer')
puppeteer.use(require('puppeteer-extra-plugin-block-resources')({
blockedTypes: new Set(['image', 'stylesheet']),
// Optionally enable Cooperative Mode for several request interceptors
interceptResolutionPriority: DEFAULT_INTERCEPT_RESOLUTION_PRIORITY
}))
//
// and/or dynamically:
//
const blockResourcesPlugin = require('puppeteer-extra-plugin-block-resources')()
puppeteer.use(blockResourcesPlugin)
const browser = await puppeteer.launch({ headless: false })
const page = await browser.newPage()
blockResourcesPlugin.blockedTypes.add('image')
await page.goto('http://www.msn.com/', {waitUntil: 'domcontentloaded'})
blockResourcesPlugin.blockedTypes.add('stylesheet')
blockResourcesPlugin.blockedTypes.add('other') // e.g. favicon
await page.goto('http://news.ycombinator.com', {waitUntil: 'domcontentloaded'})
blockResourcesPlugin.blockedTypes.delete('stylesheet')
blockResourcesPlugin.blockedTypes.delete('other')
blockResourcesPlugin.blockedTypes.add('media')
blockResourcesPlugin.blockedTypes.add('script')
await page.goto('http://www.youtube.com', {waitUntil: 'domcontentloaded'})availableTypes
Get all available resource types.
Resource type will be one of the following: document, stylesheet, image, media, font, script, texttrack, xhr, fetch, eventsource, websocket, manifest, other.
blockedTypes
Get all blocked resource types.
Blocked resource types can be configured either through opts or by modifying this property.