Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

puppeteer-extra-plugin-block-resources

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

puppeteer-extra-plugin-block-resources

Block resources (images, media, etc.) in puppeteer.

  • 2.2.6
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.4K
increased by6.12%
Maintainers
1
Weekly downloads
 
Created
Source

puppeteer-extra-plugin-block-resources

A plugin for puppeteer-extra.

Install

yarn add puppeteer-extra-plugin-block-resources

API

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)

  • opts Object Options (optional, default {})
    • opts.blockedTypes Set<string>? Specify which resourceTypes to block (by default none)

Example:

puppeteer.use(require('puppeteer-extra-plugin-block-resources')({
  blockedTypes: new Set(['image', 'stylesheet'])
}))

//
// 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.

Type: Set<string>


blockedTypes

Get all blocked resource types.

Blocked resource types can be configured either through opts or by modifying this property.

Type: Set<string>


Keywords

FAQs

Package last updated on 09 Jul 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc