@browserless/goto 10.9.2 → 10.9.7

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.
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@browserless/goto",
3
3
  "description": "Go to a page aborting unnecessary requests",
4
4
  "homepage": "https://browserless.js.org/#/?id=gotopage-options",
5
- "version": "10.9.2",
5
+ "version": "10.9.7",
6
6
  "main": "src/index.js",
7
7
  "author": {
8
8
  "email": "hello@microlink.io",
@@ -30,17 +30,17 @@
30
30
  ],
31
31
  "dependencies": {
32
32
  "@browserless/devices": "^10.7.13",
33
- "@ghostery/adblocker-puppeteer": "~2.11.3",
34
- "debug-logfmt": "~1.4.0",
33
+ "@ghostery/adblocker-puppeteer": "~2.12.3",
34
+ "debug-logfmt": "~1.4.5",
35
35
  "got": "~11.8.6",
36
- "is-url-http": "~2.3.10",
36
+ "is-url-http": "~2.3.11",
37
37
  "p-reflect": "~2.1.0",
38
38
  "p-timeout": "~4.1.0",
39
39
  "shallow-equal": "~3.1.0",
40
40
  "tough-cookie": "~6.0.0"
41
41
  },
42
42
  "devDependencies": {
43
- "@browserless/test": "^10.9.0",
43
+ "@browserless/test": "^10.9.7",
44
44
  "ava": "5",
45
45
  "p-wait-for": "3"
46
46
  },
@@ -64,5 +64,5 @@
64
64
  "timeout": "2m",
65
65
  "workerThreads": false
66
66
  },
67
- "gitHead": "c693f31fb428b362ad32e3db53356e7d9c9ebbb6"
67
+ "gitHead": "1134ac8b6f7a110e4020042f1b8054af845bdb00"
68
68
  }
package/src/engine.bin CHANGED
Binary file
package/src/index.js CHANGED
@@ -235,14 +235,10 @@ module.exports = ({ defaultDevice = 'Macbook Pro 13', timeout: globalTimeout, ..
235
235
  )
236
236
  }
237
237
 
238
- // TODO: drop this when https://github.com/ghostery/adblocker/pull/5161 is merged
239
- let isRequestInterceptionEnabled = false
240
- page.isRequestInterceptionEnabled = () => isRequestInterceptionEnabled
241
-
242
238
  const enableInterception =
243
239
  (onPageRequest || abortTypes.length > 0) &&
244
240
  run({
245
- fn: page.setRequestInterception(true).then(() => (isRequestInterceptionEnabled = true)),
241
+ fn: page.setRequestInterception(true),
246
242
  debug: 'enableInterception'
247
243
  })
248
244
 
@@ -273,15 +269,28 @@ module.exports = ({ defaultDevice = 'Macbook Pro 13', timeout: globalTimeout, ..
273
269
  }
274
270
 
275
271
  if (adblock) {
276
- page.disableAdblock = async () => {
277
- await engine.disableBlockingInPage(page)
278
- isRequestInterceptionEnabled = false
272
+ let adblockContext
273
+
274
+ page.disableAdblock = () => {
275
+ // TODO: drop this when https://github.com/ghostery/adblocker/pull/5161 is merged
276
+
277
+ engine.contexts.delete(page)
278
+
279
+ if (adblockContext.blocker.config.loadNetworkFilters) {
280
+ adblockContext.page.off('request', adblockContext.onRequest)
281
+ }
282
+
283
+ if (adblockContext.blocker.config.loadCosmeticFilters) {
284
+ adblockContext.page.off('frameattached', adblockContext.onFrameNavigated)
285
+ adblockContext.page.off('domcontentloaded', adblockContext.onDomContentLoaded)
286
+ }
287
+
279
288
  debug.adblock('disabled')
280
289
  }
281
290
 
282
291
  prePromises.push(
283
292
  run({
284
- fn: engine.enableBlockingInPage(page),
293
+ fn: engine.enableBlockingInPage(page).then(context => (adblockContext = context)),
285
294
  timeout: actionTimeout,
286
295
  debug: 'adblock'
287
296
  })