
Security News
The Changelog Podcast: Practical Steps to Stay Safe on npm
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.
@a-2-c-2-anpm/vel-fugiat-consectetur
Advanced tools
[](https://npmjs.com/package/@a-2-c-2-anpm/vel-fugiat-consectetur) [ and get the return value of the evaluation in node.
<!-- sample.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Test page</title>
</head>
<body>
<div class="content">1</div>
<div class="content">2</div>
<div class="content">3</div>
<div class="content">4</div>
</body>
</html>
const puppeteer = require('puppeteer')
const chromePageEval = require('@a-2-c-2-anpm/vel-fugiat-consectetur')
const chromeEval = chromePageEval({ puppeteer })
(async () => {
try {
const result = await chromeEval({
html: '/path/to/sample.html',
scriptFn: `
function () {
let title = document.title
let content = Array.from(document.querySelectorAll('.content'), (node) => {
return node.textContent
})
return {
title,
content
}
}
`
})
console.log(result.title) // -> Test page
console.log(result.content) // -> [1, 2, 3, 4]
} catch (e) {
console.error('Error while trying to evaluate script:', e)
}
})()
const chromePageEval = require('@a-2-c-2-anpm/vel-fugiat-consectetur')
const chromeEval = chromePageEval({ /*[constructor options here]*/ })
puppeteer [required] - the exported module from puppeteer that your app is going to useconst puppeteer = require('puppeteer')
const chromePageEval = require('@a-2-c-2-anpm/vel-fugiat-consectetur')
const chromeEval = chromePageEval({ puppeteer })
(async () => {
const result = await chromeEval({ /*[evaluate options here]*/ })
})()
html string [required] - the path to the html file to load in a Chrome pagescriptFn string [required] - the script to evaluate in the Chrome page. the script must be a function that returns a value. ex: scriptFn: 'function () { return 1 + 2}'viewport object - object with any of the viewport options supported by puppeteerargs array - a list of custom arguments to pass to the scriptFn function. ex: args: [1, 2] and with scriptFn: function (a, b) { return a + b}' will produce 3 as resultstyles array - array of css strings to insert at the beginning of page's head element. ex: styles: ['* { font-family: 'Calibri'; font-size: 16px; }']waitForJS boolean - when true the scriptFn won't be executed until the variable specified in waitForJSVarName option is set to true in page's javscript. defaults to falsewaitForJSVarName string - name of the variable that will be used as trigger of scriptFn. defaults to "CHROME_PAGE_EVAL_READY"waitUntil string - a value that specifies when a page is considered to be loaded, for the list of all possible values and its meanings see waitUntil option in puppeteer docs. defaults to the the default value of puppeteertimeout number - time in ms to wait for the script evaluation to complete, when the timeout is reached the evaluation is cancelled. defaults to 30000npm install puppeteer --save in your project and pass it to @a-2-c-2-anpm/vel-fugiat-consectetur constructor function.scriptFn option) must be a serializable value in order to receive it properly, if a non serializable value is returned you will get undefined as the result.To get more information (internal debugging logs of the module) about what's happening during the evaluation on the page start your app in this way: DEBUG=@a-2-c-2-anpm/vel-fugiat-consectetur* node [your-entry-file-here].js (on Windows use set DEBUG=@a-2-c-2-anpm/vel-fugiat-consectetur* && node [your-entry-file-here].js). This will print out to the console some additional information about what's going on.
To see the Chrome instance created (the visible chrome window) run your app with the CHROME_PAGE_EVAL_DEBUGGING env var: CHROME_PAGE_EVAL_DEBUGGING=true node [your-entry-file-here].js (on Windows use set CHROME_PAGE_EVAL_DEBUGGING=true && node [your-entry-file-here].js).
See license
FAQs
[](https://npmjs.com/package/@a-2-c-2-anpm/vel-fugiat-consectetur) [
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
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.

Security News
Ruby's creator Matz assumes control of RubyGems and Bundler repositories while former maintainers agree to step back and transfer all rights to end the dispute.