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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f2409cbc42fc0fcb80876e1d4238f08cfbeae1d7fc7dada4cb958e8178bafc95
4
- data.tar.gz: 8189bc362f4979028340f17095c0e9aade0d7950f605fb2062740452316e2b60
3
+ metadata.gz: c3d4e3648c63a1906a953202433b88805bd2d602d2d96d871debd4d251fc415e
4
+ data.tar.gz: 7756206771af66e2483c97933601bf74aa57bd2ac3cf8c2e2031c9c4cc0cc0fb
5
5
  SHA512:
6
- metadata.gz: 0ed3057d89a650c43dbd5c606edcef96e31702cde46a18896af692aaa0b000c2824df2cc90d33e2a8767486940cc4063a2c28bdd609b459579d698fb282465b4
7
- data.tar.gz: 23ede80fa749b4095cf94733690d398fd5027c33a1d11adccc63fa3300dbc2cf89e466c6ff8e8b63be6f67a3a00eff91d9c3c9124ea98d37ef4ab86df439fb3d
6
+ metadata.gz: 398afda3dd93724ef5699f1b2304eecee81ec5e1c1cbc2ca03ff5562c8506d2bb660848995c153ff652ad29b798a2156334d1963e3aa7e0a61a07df0d2860f48
7
+ data.tar.gz: 9c6d8a6641c6a0c3a193abd34b50f28086b9aecb78c661c186566c684543a0c8c4cce23c96b093739d44598d41db1613b483c8bc19f74a36cffefb140e01420a
@@ -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
- page.once('request', request => {
149
- request.respond({ body: urlOrHtml === '' ? ' ' : urlOrHtml });
150
- // Reset the request interception
151
- // (we only want to intercept the first request - ie our HTML)
152
- page.on('request', request => request.continue());
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) {
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Grover
4
- VERSION = '1.0.1'
4
+ VERSION = '1.0.5'
5
5
  end
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.1
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-06-02 00:00:00.000000000 Z
11
+ date: 2021-08-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: combine_pdf