@browserless/goto 10.11.3 → 10.12.6

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": "Navigate to web pages with built-in ad blocking, device emulation, and optimized loading for faster automation.",
4
4
  "homepage": "https://browserless.js.org/#/?id=gotopage-options",
5
- "version": "10.11.3",
5
+ "version": "10.12.6",
6
6
  "main": "src/index.js",
7
7
  "author": {
8
8
  "email": "hello@microlink.io",
@@ -31,18 +31,18 @@
31
31
  ],
32
32
  "dependencies": {
33
33
  "@browserless/devices": "^10.11.3",
34
- "@duckduckgo/autoconsent": "~14.56.0",
34
+ "@duckduckgo/autoconsent": "~14.67.0",
35
35
  "@ghostery/adblocker-puppeteer": "~2.14.1",
36
- "debug-logfmt": "~1.4.8",
36
+ "debug-logfmt": "~1.4.10",
37
37
  "got": "~11.8.6",
38
38
  "is-url-http": "~2.3.13",
39
39
  "p-reflect": "~2.1.0",
40
40
  "p-timeout": "~4.1.0",
41
41
  "shallow-equal": "~3.1.0",
42
- "tough-cookie": "~6.0.0"
42
+ "tough-cookie": "~6.0.1"
43
43
  },
44
44
  "devDependencies": {
45
- "@browserless/test": "^10.11.3",
45
+ "@browserless/test": "^10.12.6",
46
46
  "ava": "5",
47
47
  "p-wait-for": "3"
48
48
  },
@@ -66,5 +66,5 @@
66
66
  "timeout": "2m",
67
67
  "workerThreads": false
68
68
  },
69
- "gitHead": "2f86ba8d35c9b92c3c19e310282a3d24d0e0c7e0"
69
+ "gitHead": "5d4aaa106be3e196f5bfb1b52fc3d712ba9d512c"
70
70
  }
package/src/adblock.js CHANGED
@@ -1,6 +1,8 @@
1
1
  'use strict'
2
2
 
3
3
  const { PuppeteerBlocker } = require('@ghostery/adblocker-puppeteer')
4
+ const { randomUUID } = require('crypto')
5
+ const pTimeout = require('p-timeout')
4
6
  const fs = require('fs/promises')
5
7
  const path = require('path')
6
8
 
@@ -53,6 +55,10 @@ const autoconsentConfig = Object.freeze({
53
55
  enablePrehide: true,
54
56
  /* apply CSS-only rules that hide popups lacking a reject button */
55
57
  enableCosmeticRules: true,
58
+ /* enable rules auto-generated from common CMP patterns */
59
+ enableGeneratedRules: true,
60
+ /* fall back to heuristic click when no specific rule matches */
61
+ enableHeuristicAction: true,
56
62
  /* skip bundled ABP/uBO cosmetic filter list (saves bundle size) */
57
63
  enableFilterList: false,
58
64
  /* how many times to retry CMP detection (~50 ms apart) */
@@ -80,29 +86,44 @@ const sendMessage = (page, message) =>
80
86
  }, message)
81
87
  .catch(() => {})
82
88
 
83
- const setupAutoConsent = async page => {
89
+ const setupAutoConsent = async (page, timeout) => {
84
90
  if (page._autoconsentSetup) return
85
91
  const autoconsentPlaywrightScript = await getAutoconsentPlaywrightScript()
92
+ const nonce = randomUUID()
86
93
 
87
94
  await page.exposeFunction('autoconsentSendMessage', async message => {
88
95
  if (!message || typeof message !== 'object') return
96
+ if (message.__nonce !== nonce) return
89
97
 
90
98
  if (message.type === 'init') {
91
99
  return sendMessage(page, { type: 'initResp', config: autoconsentConfig })
92
100
  }
93
101
 
94
102
  if (message.type === 'eval') {
95
- return sendMessage(page, { type: 'evalResp', id: message.id, result: false })
103
+ let result = false
104
+ try {
105
+ result = await pTimeout(page.evaluate(message.code), timeout)
106
+ } catch {}
107
+ return sendMessage(page, { type: 'evalResp', id: message.id, result })
96
108
  }
97
109
  })
98
110
 
111
+ /* Wrap the binding in the top frame so every outgoing message carries the
112
+ nonce. Child frames (including cross-origin iframes) keep the raw CDP
113
+ binding which lacks the nonce, so their messages are silently rejected. */
114
+ await page.evaluateOnNewDocument(n => {
115
+ if (window.self !== window.top) return
116
+ const raw = window.autoconsentSendMessage
117
+ if (raw) window.autoconsentSendMessage = msg => raw({ ...msg, __nonce: n })
118
+ }, nonce)
119
+
99
120
  await page.evaluateOnNewDocument(autoconsentPlaywrightScript)
100
121
  page._autoconsentSetup = true
101
122
  }
102
123
 
103
124
  const runAutoConsent = async page => page.evaluate(await getAutoconsentPlaywrightScript())
104
125
 
105
- const enableBlockingInPage = (page, run, actionTimeout) => {
126
+ const enableBlockingInPage = (page, run, timeout) => {
106
127
  page.disableAdblock = () =>
107
128
  getEngine()
108
129
  .then(engine => engine.disableBlockingInPage(page, { keepRequestInterception: true }))
@@ -111,13 +132,13 @@ const enableBlockingInPage = (page, run, actionTimeout) => {
111
132
 
112
133
  return [
113
134
  run({
114
- fn: setupAutoConsent(page),
115
- timeout: actionTimeout,
135
+ fn: setupAutoConsent(page, timeout),
136
+ timeout,
116
137
  debug: 'autoconsent:setup'
117
138
  }),
118
139
  run({
119
140
  fn: getEngine().then(engine => engine.enableBlockingInPage(page)),
120
- timeout: actionTimeout,
141
+ timeout,
121
142
  debug: 'adblock'
122
143
  })
123
144
  ]
package/src/engine.bin CHANGED
Binary file