grover 1.0.1 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/grover/js/processor.js +27 -16
- data/lib/grover/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c3d4e3648c63a1906a953202433b88805bd2d602d2d96d871debd4d251fc415e
|
4
|
+
data.tar.gz: 7756206771af66e2483c97933601bf74aa57bd2ac3cf8c2e2031c9c4cc0cc0fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 398afda3dd93724ef5699f1b2304eecee81ec5e1c1cbc2ca03ff5562c8506d2bb660848995c153ff652ad29b798a2156334d1963e3aa7e0a61a07df0d2860f48
|
7
|
+
data.tar.gz: 9c6d8a6641c6a0c3a193abd34b50f28086b9aecb78c661c186566c684543a0c8c4cce23c96b093739d44598d41db1613b483c8bc19f74a36cffefb140e01420a
|
data/lib/grover/js/processor.js
CHANGED
@@ -91,7 +91,7 @@ const _processPage = (async (convertAction, urlOrHtml, options) => {
|
|
91
91
|
// Emulate the media features, if specified
|
92
92
|
const mediaFeatures = options.mediaFeatures; delete options.mediaFeatures;
|
93
93
|
if (Array.isArray(mediaFeatures)) {
|
94
|
-
page.emulateMediaFeatures(mediaFeatures);
|
94
|
+
await page.emulateMediaFeatures(mediaFeatures);
|
95
95
|
}
|
96
96
|
|
97
97
|
// Emulate timezone (if provided)
|
@@ -100,34 +100,28 @@ const _processPage = (async (convertAction, urlOrHtml, options) => {
|
|
100
100
|
await page.emulateTimezone(timezone);
|
101
101
|
}
|
102
102
|
|
103
|
-
// Emulate vision deficiency (if provided)
|
104
|
-
const visionDeficiency = options.visionDeficiency; delete options.visionDeficiency;
|
105
|
-
if (visionDeficiency !== undefined) {
|
106
|
-
page.emulateVisionDeficiency(type);
|
107
|
-
}
|
108
|
-
|
109
103
|
// Bypass CSP (content security policy), if provided
|
110
104
|
const bypassCSP = options.bypassCSP; delete options.bypassCSP;
|
111
105
|
if (bypassCSP !== undefined) {
|
112
|
-
page.setBypassCSP(bypassCSP);
|
106
|
+
await page.setBypassCSP(bypassCSP);
|
113
107
|
}
|
114
108
|
|
115
109
|
// Add extra HTTP headers (if provided)
|
116
110
|
const extraHTTPHeaders = options.extraHTTPHeaders; delete options.extraHTTPHeaders;
|
117
111
|
if (extraHTTPHeaders !== undefined) {
|
118
|
-
page.setExtraHTTPHeaders(extraHTTPHeaders);
|
112
|
+
await page.setExtraHTTPHeaders(extraHTTPHeaders);
|
119
113
|
}
|
120
114
|
|
121
115
|
// Set geolocation (if provided)
|
122
116
|
const geolocation = options.geolocation; delete options.geolocation;
|
123
117
|
if (geolocation !== undefined) {
|
124
|
-
page.setGeolocation(geolocation);
|
118
|
+
await page.setGeolocation(geolocation);
|
125
119
|
}
|
126
120
|
|
127
121
|
const raiseOnRequestFailure = options.raiseOnRequestFailure; delete options.raiseOnRequestFailure;
|
128
122
|
if (raiseOnRequestFailure) {
|
129
123
|
page.on('requestfinished', (request) => {
|
130
|
-
if (request.response() && !request.response().ok() && !request.redirectChain().length > 0) {
|
124
|
+
if (request.response() && !(request.response().ok() || request.response().status() == 304) && !request.redirectChain().length > 0) {
|
131
125
|
errors.push(request);
|
132
126
|
}
|
133
127
|
});
|
@@ -145,11 +139,15 @@ const _processPage = (async (convertAction, urlOrHtml, options) => {
|
|
145
139
|
// Request is some HTML content. Use request interception to assign the body
|
146
140
|
requestOptions.waitUntil = waitUntil || 'networkidle0';
|
147
141
|
await page.setRequestInterception(true);
|
148
|
-
|
149
|
-
|
150
|
-
//
|
151
|
-
|
152
|
-
|
142
|
+
let htmlIntercepted = false;
|
143
|
+
page.on('request', request => {
|
144
|
+
// We only want to intercept the first request - ie our HTML
|
145
|
+
if (htmlIntercepted)
|
146
|
+
request.continue();
|
147
|
+
else {
|
148
|
+
htmlIntercepted = true
|
149
|
+
request.respond({ body: urlOrHtml === '' ? ' ' : urlOrHtml });
|
150
|
+
}
|
153
151
|
});
|
154
152
|
const displayUrl = options.displayUrl; delete options.displayUrl;
|
155
153
|
await page.goto(displayUrl || 'http://example.com', requestOptions);
|
@@ -184,12 +182,25 @@ const _processPage = (async (convertAction, urlOrHtml, options) => {
|
|
184
182
|
await page.waitForSelector(waitForSelector, waitForSelectorOptions);
|
185
183
|
}
|
186
184
|
|
185
|
+
// If specified, wait for function
|
186
|
+
const waitForFunction = options.waitForFunction; delete options.waitForFunction;
|
187
|
+
const waitForFunctionOptions = options.waitForFunctionOptions; delete options.waitForFunctionOptions;
|
188
|
+
if (waitForFunction !== undefined) {
|
189
|
+
await page.waitForFunction(waitForFunction, waitForFunctionOptions);
|
190
|
+
}
|
191
|
+
|
187
192
|
// If specified, wait for timeout
|
188
193
|
const waitForTimeout = options.waitForTimeout; delete options.waitForTimeout;
|
189
194
|
if (waitForTimeout !== undefined) {
|
190
195
|
await page.waitForTimeout(waitForTimeout);
|
191
196
|
}
|
192
197
|
|
198
|
+
// Emulate vision deficiency (if provided)
|
199
|
+
const visionDeficiency = options.visionDeficiency; delete options.visionDeficiency;
|
200
|
+
if (visionDeficiency !== undefined) {
|
201
|
+
await page.emulateVisionDeficiency(visionDeficiency);
|
202
|
+
}
|
203
|
+
|
193
204
|
// If specified, focus on the specified selector
|
194
205
|
const focusSelector = options.focus; delete options.focus;
|
195
206
|
if (focusSelector !== undefined) {
|
data/lib/grover/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grover
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Bromwich
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: combine_pdf
|