prerender
Advanced tools
+3
-0
@@ -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); | ||
| }; | ||
| }; |
+1
-1
@@ -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": { |
Network access
Supply chain riskThis module accesses the network.
Found 2 instances in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 19 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 2 instances in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 18 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
90228
1.02%1613
1.19%25
4.17%