You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

prerender

Package Overview
Dependencies
Maintainers
5
Versions
153
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prerender - npm Package Compare versions

Comparing version
5.18.0
to
5.19.0
+3
-0
CHANGELOG.md

@@ -5,2 +5,5 @@ # Change Log

## 5.19.0 - 2022-03-23
- Ability to parse content from the shadow DOM
## 5.18.0 - 2022-02-09

@@ -7,0 +10,0 @@ - Fire plugin event `tabNavigated` when tab navigation is finished. Save `errorText` in `tab.prerender.navigateError`

@@ -629,4 +629,18 @@ const CDP = require('chrome-remote-interface');

const getHtmlFunction = () => {
return document.firstElementChild.outerHTML;
}
const getHtmlWithShadowDomFunction = () => {
const innerText = document.firstElementChild.getInnerHTML({includeShadowRoots: true});
const htmlNode = document.firstElementChild;
const attributeNames = htmlNode.getAttributeNames();
const attrStringList = attributeNames.map((attributeName) => (`${attributeName}="${htmlNode.getAttribute(attributeName)}"`))
return `<!DOCTYPE html>
<html ${attrStringList.join(' ')}>
${innerText}
</html>`;
}
chrome.parseHtmlFromPage = function (tab) {

@@ -642,4 +656,10 @@ return new Promise((resolve, reject) => {

const getHtmlFunctionText = tab.prerender.parseShadowDom
? getHtmlWithShadowDomFunction.toString()
: getHtmlFunction.toString();
tab.Runtime.evaluate({
expression: "document.firstElementChild.outerHTML"
expression: `(${getHtmlFunctionText})()` // Call the function
}).then((resp) => {

@@ -646,0 +666,0 @@

+5
-2

@@ -24,4 +24,6 @@ const util = require('./util.js');

const TIMEOUT_STATUS_CODE = process.env.TIMEOUT_STATUS_CODE
const TIMEOUT_STATUS_CODE = process.env.TIMEOUT_STATUS_CODE;
const PARSE_SHADOW_DOM = process.env.PARSE_SHADOW_DOM || false;
const server = exports = module.exports = {};

@@ -47,2 +49,3 @@

this.options.timeoutStatusCode = this.options.timeoutStatusCode || TIMEOUT_STATUS_CODE;
this.options.parseShadowDom = this.options.parseShadowDom || PARSE_SHADOW_DOM;

@@ -472,2 +475,2 @@ this.browser = require('./browsers/chrome');

util.log('got', req.prerender.statusCode, 'in', ms + 'ms', 'for', req.prerender.url);
};
};

@@ -5,3 +5,3 @@ {

"description": "Service to prerender Javascript rendered pages for SEO",
"version": "5.18.0",
"version": "5.19.0",
"license": "MIT",

@@ -8,0 +8,0 @@ "repository": {