@browserless/cli 10.10.1 → 10.10.3

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/cli",
3
3
  "description": "Command-line interface for headless browser automation. Take screenshots, generate PDFs, and extract content from websites.",
4
4
  "homepage": "https://browserless.js.org",
5
- "version": "10.10.1",
5
+ "version": "10.10.3",
6
6
  "bin": {
7
7
  "browserless": "src/index.js"
8
8
  },
@@ -35,7 +35,7 @@
35
35
  ],
36
36
  "dependencies": {
37
37
  "beauty-error": "~1.2.21",
38
- "browserless": "^10.10.1",
38
+ "browserless": "^10.10.3",
39
39
  "dark-mode": "~3.0.0",
40
40
  "dset": "~3.1.4",
41
41
  "mri": "~1.2.0",
@@ -59,5 +59,5 @@
59
59
  "test": "exit 0"
60
60
  },
61
61
  "license": "MIT",
62
- "gitHead": "32f6e72bcb489a83ac9659520a3961aeb97c47b7"
62
+ "gitHead": "4d2b893e8215a91d830f4471f51c567a53cd6bbb"
63
63
  }
@@ -28,7 +28,9 @@ const BACKGROUNDS = [
28
28
 
29
29
  const randBackground = uniqueRandomArray(BACKGROUNDS)
30
30
 
31
- module.exports = async ({ url, browserless, opts }) => {
31
+ module.exports = async ({ url, browserless, opts, isPageReady }) => {
32
+ if (typeof isPageReady === 'function') opts.isPageReady = isPageReady
33
+
32
34
  if (opts.background === 'unsplash') {
33
35
  dset(opts, 'overlay.background', 'https://source.unsplash.com/random/1920x1080')
34
36
  }
package/src/index.js CHANGED
@@ -41,6 +41,22 @@ process.on('SIGINT', () => {
41
41
  process.exit(130)
42
42
  })
43
43
 
44
+ const VERIFICATION_MARKERS = Object.freeze([
45
+ 'verifying you are human',
46
+ 'please wait while we verify that you are',
47
+ 'security check',
48
+ 'checking your browser',
49
+ 'request has been denied by the security policy',
50
+ 'vercel security checkpoint',
51
+ '/_vercel/challenge'
52
+ ])
53
+
54
+ const isPageReady = ({ title = '', bodyText = '', url = '', isWhite = false } = {}) => {
55
+ const haystack = `${title}\n${bodyText}\n${url}`.toLowerCase()
56
+ const isVerificationPage = VERIFICATION_MARKERS.some(marker => haystack.includes(marker))
57
+ return !isWhite && !isVerificationPage
58
+ }
59
+
44
60
  const run = async () => {
45
61
  if (cli.input.length === 0) return cli.showHelp()
46
62
  spinner.start()
@@ -50,7 +66,7 @@ const run = async () => {
50
66
  const browser = createBrowser({ headless })
51
67
  onExit(browser.close)
52
68
  const browserless = await browser.createContext()
53
- return fn({ url, browserless, opts: nestie(opts) })
69
+ return fn({ url, browserless, opts: nestie(opts), isPageReady })
54
70
  }
55
71
 
56
72
  run()