Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
capture-all
Advanced tools
Readme
Flexible utility to get screenshots from Web pages
$ npm i capture-all
# or
$ yarn add capture-all
const { captureAll } = require('capture-all')
const fs = require('fs')
captureAll([
{
// Web page URL which will be captured
url: 'https://www.google.com/',
// Selector for capturing element
target: 'body',
// Selectors to hide from capture (add `visibility: hidden;` to the elements)
hidden: ['#gb'],
// Selectors to remove from capture (add `display: none;` to the elements)
remove: ['#fbar'],
// Delay (milliseconds) before taking screenshot
delay: 3000,
// Viewport size of a browser
viewport: {
width: 1024,
height: 800
}
}
]).then(results => {
results.forEach((result, i) => {
fs.writeFileSync(`result-${i}.png`, result.image)
})
})
You can define detailed behavior of the capturing processing with capture
option. The capture
option is an function receving Puppeteer's Page
instance as the 1st argument and a capturing function as the 2nd argument. You have to call the 2nd argument function by your hand when you specify capture
option.
const { captureAll } = require('capture-all')
const fs = require('fs')
captureAll([
{
url: 'https://www.google.com/',
target: 'body',
viewport: {
width: 1024,
height: 800
},
// Define the behavior around capturing
capture: async (page, capture) => {
// Click a button in the page by using Puppeteer API
const button = await page.$('#some-button')
await button.click()
// Capture the page at this moment
await capture()
// Click the button again
await button.click()
// Capture the page again
await capture()
}
}
]).then(results => {
results.forEach((result, i) => {
fs.writeFileSync(`result-${i}.png`, result.image)
})
})
captureAll(targets: CaptureTarget[], options?: CaptureOptions): Promise<CaptureResult[]>
Capture screenshots of Web pages which specified by targets
and return an array of CaptureResult
object including captured image buffer.
CaptureTarget
may have the following properties:
url
: Web page URL which will be captured (required)target
: a selector for capturing elementhidden
: an array of selector to hide matched elements from captured imageremove
: an array of selector to remove matched elements from captured imagedisableCssAnimation
: true
if css animations / transitions are to be disabled. (default: true
)delay
: Delay (milliseconds) before taking screenshotviewport
: viewport size of browsercapture
: You can hook the capturing processing by using this option. See Hooking Capturing Processing for details.CaptureOptions
may have the following properties:
concurrency
: a number of process which will be created for capturepuppeteer
: an object passed to puppeteer.launch
CaptureResult
has the following properties:
index
: Index of capture results generated by the same CaptureTarget
. The result can be more than one if you specify capture
option.image
: captured image bufferurl
: captured Web page URLtarget
: a selector of captured elementhidden
: an array of selector which is hidden from captured imageremove
: an array of selector which is removed from captured imagedisableCssAnimation
: true
if css animations / transitions are to be disableddelay
: Delay (milliseconds) before taking screenshotviewport
: viewport size of browsercreateCaptureStream(targets: CaptureTarget[], options?: CaptureOptions): ReadableStream<CaptureResult>
Similar to captureAll
but returns readable stream of CaptureResult
instead.
MIT
FAQs
Flexible utility to get screenshots from Web pages
The npm package capture-all receives a total of 23 weekly downloads. As such, capture-all popularity was classified as not popular.
We found that capture-all demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.