@browserless/goto 10.9.15 → 10.9.18
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/README.md +194 -6
- package/package.json +15 -14
- package/src/engine.bin +0 -0
package/README.md
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
<div align="center">
|
|
2
|
-
<br>
|
|
3
2
|
<img style="width: 500px; margin:3rem 0 1.5rem;" src="https://github.com/microlinkhq/browserless/raw/master/static/logo-banner.png#gh-light-mode-only" alt="browserless">
|
|
4
3
|
<img style="width: 500px; margin:3rem 0 1.5rem;" src="https://github.com/microlinkhq/browserless/raw/master/static/logo-banner-light.png#gh-dark-mode-only" alt="browserless">
|
|
5
|
-
<br>
|
|
6
|
-
<
|
|
7
|
-
<
|
|
8
|
-
<
|
|
9
|
-
<
|
|
4
|
+
<br><br>
|
|
5
|
+
<a href="https://microlink.io"><img src="https://img.shields.io/badge/powered_by-microlink.io-blue?style=flat-square&color=%23EA407B" alt="Powered by microlink.io"></a>
|
|
6
|
+
<img src="https://img.shields.io/github/tag/microlinkhq/browserless.svg?style=flat-square" alt="Last version">
|
|
7
|
+
<a href="https://coveralls.io/github/microlinkhq/browserless"><img src="https://img.shields.io/coveralls/microlinkhq/browserless.svg?style=flat-square" alt="Coverage Status"></a>
|
|
8
|
+
<a href="https://www.npmjs.org/package/browserless"><img src="https://img.shields.io/npm/dm/browserless.svg?style=flat-square" alt="NPM Status"></a>
|
|
9
|
+
<br><br>
|
|
10
10
|
</div>
|
|
11
11
|
|
|
12
|
+
> @browserless/goto: Go to a page aborting unnecessary requests.
|
|
13
|
+
|
|
14
|
+
See the [Go To section](https://browserless.js.org/#/?id=gotopage-options) on our website for more details.
|
|
15
|
+
|
|
12
16
|
## Install
|
|
13
17
|
|
|
14
18
|
Using npm:
|
|
@@ -17,6 +21,190 @@ Using npm:
|
|
|
17
21
|
npm install @browserless/goto --save
|
|
18
22
|
```
|
|
19
23
|
|
|
24
|
+
## About
|
|
25
|
+
|
|
26
|
+
This package provides **advanced page navigation** with built-in ad blocking, smart waiting strategies, and extensive customization options. It's the core navigation engine that powers all browserless page loading operations.
|
|
27
|
+
|
|
28
|
+
### What this package does
|
|
29
|
+
|
|
30
|
+
The `@browserless/goto` package allows you to:
|
|
31
|
+
|
|
32
|
+
- **Navigate to pages** with optimized loading and smart waiting strategies
|
|
33
|
+
- **Block ads and trackers** using a precompiled Ghostery ad-blocker engine
|
|
34
|
+
- **Inject scripts, modules, and styles** into pages
|
|
35
|
+
- **Emulate devices** with viewport, user agent, and media features
|
|
36
|
+
- **Intercept and abort requests** by resource type
|
|
37
|
+
- **Handle cookies and authentication** seamlessly
|
|
38
|
+
|
|
39
|
+
### Usage
|
|
40
|
+
|
|
41
|
+
```js
|
|
42
|
+
const createGoto = require('@browserless/goto')
|
|
43
|
+
const puppeteer = require('puppeteer')
|
|
44
|
+
|
|
45
|
+
const goto = createGoto({
|
|
46
|
+
timeout: 30000,
|
|
47
|
+
defaultDevice: 'Macbook Pro 13'
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
const browser = await puppeteer.launch()
|
|
51
|
+
const page = await browser.newPage()
|
|
52
|
+
|
|
53
|
+
const { response, device, error } = await goto(page, {
|
|
54
|
+
url: 'https://example.com',
|
|
55
|
+
adblock: true,
|
|
56
|
+
waitUntil: 'auto'
|
|
57
|
+
})
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Options
|
|
61
|
+
|
|
62
|
+
| Option | Type | Default | Description |
|
|
63
|
+
|--------|------|---------|-------------|
|
|
64
|
+
| `url` | `string` | — | Target URL to navigate to |
|
|
65
|
+
| `html` | `string` | — | HTML content to render (instead of URL) |
|
|
66
|
+
| `adblock` | `boolean` | `true` | Enable built-in ad blocker |
|
|
67
|
+
| `waitUntil` | `string\|string[]` | `'auto'` | Navigation wait condition |
|
|
68
|
+
| `timeout` | `number` | `30000` | Navigation timeout in ms |
|
|
69
|
+
| `device` | `string` | `'Macbook Pro 13'` | Device to emulate |
|
|
70
|
+
| `headers` | `object` | `{}` | Extra HTTP headers |
|
|
71
|
+
| `javascript` | `boolean` | `true` | Enable/disable JavaScript |
|
|
72
|
+
| `animations` | `boolean` | `false` | Enable CSS animations |
|
|
73
|
+
| `colorScheme` | `string` | — | `'light'` or `'dark'` preference |
|
|
74
|
+
| `mediaType` | `string` | — | CSS media type (`'screen'`, `'print'`) |
|
|
75
|
+
| `timezone` | `string` | — | Timezone to emulate |
|
|
76
|
+
| `authenticate` | `object` | — | HTTP authentication credentials |
|
|
77
|
+
| `scripts` | `string\|string[]` | — | Scripts to inject |
|
|
78
|
+
| `modules` | `string\|string[]` | — | ES modules to inject |
|
|
79
|
+
| `styles` | `string\|string[]` | — | Stylesheets to inject |
|
|
80
|
+
| `click` | `string\|string[]` | — | CSS selectors to click |
|
|
81
|
+
| `scroll` | `string` | — | CSS selector to scroll into view |
|
|
82
|
+
| `abortTypes` | `string[]` | `[]` | Resource types to abort |
|
|
83
|
+
| `waitForSelector` | `string` | — | Wait for selector to appear |
|
|
84
|
+
| `waitForFunction` | `string` | — | Wait for function to return truthy |
|
|
85
|
+
| `waitForTimeout` | `number` | — | Wait for specified milliseconds |
|
|
86
|
+
| `onPageRequest` | `function` | — | Request interception handler |
|
|
87
|
+
|
|
88
|
+
### Smart waiting with `waitUntil: 'auto'`
|
|
89
|
+
|
|
90
|
+
The default `'auto'` mode intelligently waits for page readiness:
|
|
91
|
+
|
|
92
|
+
```js
|
|
93
|
+
// Auto mode combines 'load' with 'networkidle2' smartly
|
|
94
|
+
await goto(page, { url: 'https://example.com', waitUntil: 'auto' })
|
|
95
|
+
|
|
96
|
+
// Standard Puppeteer wait conditions also supported
|
|
97
|
+
await goto(page, { url: 'https://example.com', waitUntil: 'networkidle0' })
|
|
98
|
+
await goto(page, { url: 'https://example.com', waitUntil: ['load', 'domcontentloaded'] })
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Built-in Ad Blocker
|
|
102
|
+
|
|
103
|
+
The package includes a precompiled [Ghostery ad-blocker](https://github.com/ghostery/adblocker) engine that blocks ads and trackers automatically:
|
|
104
|
+
|
|
105
|
+
```js
|
|
106
|
+
// Enabled by default
|
|
107
|
+
await goto(page, { url: 'https://example.com', adblock: true })
|
|
108
|
+
|
|
109
|
+
// Disable for specific pages
|
|
110
|
+
await goto(page, { url: 'https://example.com', adblock: false })
|
|
111
|
+
|
|
112
|
+
// The adblocker can be disabled mid-session
|
|
113
|
+
page.disableAdblock()
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Script and style injection
|
|
117
|
+
|
|
118
|
+
Inject external resources or inline code:
|
|
119
|
+
|
|
120
|
+
```js
|
|
121
|
+
await goto(page, {
|
|
122
|
+
url: 'https://example.com',
|
|
123
|
+
// External URLs
|
|
124
|
+
scripts: ['https://cdn.example.com/library.js'],
|
|
125
|
+
// ES modules
|
|
126
|
+
modules: ['https://cdn.example.com/module.mjs'],
|
|
127
|
+
// CSS (URLs, paths, or inline)
|
|
128
|
+
styles: [
|
|
129
|
+
'https://cdn.example.com/styles.css',
|
|
130
|
+
'body { background: red; }'
|
|
131
|
+
]
|
|
132
|
+
})
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Request interception
|
|
136
|
+
|
|
137
|
+
Abort specific resource types to speed up navigation:
|
|
138
|
+
|
|
139
|
+
```js
|
|
140
|
+
await goto(page, {
|
|
141
|
+
url: 'https://example.com',
|
|
142
|
+
abortTypes: ['image', 'stylesheet', 'font', 'media'],
|
|
143
|
+
onPageRequest: (request, page) => {
|
|
144
|
+
console.log('Request:', request.url())
|
|
145
|
+
}
|
|
146
|
+
})
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### Device emulation
|
|
150
|
+
|
|
151
|
+
```js
|
|
152
|
+
// Use preset device
|
|
153
|
+
await goto(page, { url: 'https://example.com', device: 'iPhone 13' })
|
|
154
|
+
|
|
155
|
+
// Custom viewport
|
|
156
|
+
await goto(page, {
|
|
157
|
+
url: 'https://example.com',
|
|
158
|
+
viewport: { width: 1920, height: 1080 }
|
|
159
|
+
})
|
|
160
|
+
|
|
161
|
+
// Custom headers
|
|
162
|
+
await goto(page, {
|
|
163
|
+
url: 'https://example.com',
|
|
164
|
+
headers: {
|
|
165
|
+
'user-agent': 'custom-agent',
|
|
166
|
+
'cookie': 'session=abc123'
|
|
167
|
+
}
|
|
168
|
+
})
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### Return value
|
|
172
|
+
|
|
173
|
+
The `goto` function returns:
|
|
174
|
+
|
|
175
|
+
```js
|
|
176
|
+
const { response, device, error } = await goto(page, { url })
|
|
177
|
+
|
|
178
|
+
// response: Puppeteer Response object (or undefined if navigation failed)
|
|
179
|
+
// device: { userAgent, viewport } used for the request
|
|
180
|
+
// error: Error object if navigation failed
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### How it fits in the monorepo
|
|
184
|
+
|
|
185
|
+
This is the **core navigation engine** used by the entire browserless ecosystem:
|
|
186
|
+
|
|
187
|
+
| Consumer | Purpose |
|
|
188
|
+
|----------|---------|
|
|
189
|
+
| `browserless` (core) | Powers `.goto()`, `.html()`, `.text()`, `.pdf()`, `.screenshot()` |
|
|
190
|
+
| `@browserless/screenshot` | Navigation before capturing screenshots |
|
|
191
|
+
| `@browserless/pdf` | Navigation before generating PDFs |
|
|
192
|
+
| `@browserless/function` | Navigation for sandboxed function execution |
|
|
193
|
+
| `@browserless/lighthouse` | Navigation for Lighthouse audits |
|
|
194
|
+
|
|
195
|
+
### Dependencies
|
|
196
|
+
|
|
197
|
+
| Package | Purpose |
|
|
198
|
+
|---------|---------|
|
|
199
|
+
| `@browserless/devices` | Device descriptor lookups and emulation |
|
|
200
|
+
| `@ghostery/adblocker-puppeteer` | Ad and tracker blocking |
|
|
201
|
+
| `debug-logfmt` | Structured debug logging |
|
|
202
|
+
| `got` | HTTP client for postinstall script |
|
|
203
|
+
| `is-url-http` | Detect if value is URL for injection |
|
|
204
|
+
| `p-reflect` / `p-timeout` | Promise utilities for timeouts |
|
|
205
|
+
| `shallow-equal` | Viewport comparison optimization |
|
|
206
|
+
| `tough-cookie` | Cookie string parsing |
|
|
207
|
+
|
|
20
208
|
## License
|
|
21
209
|
|
|
22
210
|
**@browserless/goto** © [Microlink](https://microlink.io), released under the [MIT](https://github.com/microlinkhq/browserless/blob/master/LICENSE.md) License.<br>
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@browserless/goto",
|
|
3
|
-
"description": "
|
|
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.9.
|
|
5
|
+
"version": "10.9.18",
|
|
6
6
|
"main": "src/index.js",
|
|
7
7
|
"author": {
|
|
8
8
|
"email": "hello@microlink.io",
|
|
@@ -18,29 +18,30 @@
|
|
|
18
18
|
"url": "https://github.com/microlinkhq/browserless/issues"
|
|
19
19
|
},
|
|
20
20
|
"keywords": [
|
|
21
|
-
"browser",
|
|
22
21
|
"browserless",
|
|
23
|
-
"chrome",
|
|
24
|
-
"chromeless",
|
|
25
|
-
"core",
|
|
26
22
|
"goto",
|
|
23
|
+
"navigation",
|
|
27
24
|
"headless",
|
|
28
|
-
"
|
|
29
|
-
"puppeteer"
|
|
25
|
+
"chrome",
|
|
26
|
+
"puppeteer",
|
|
27
|
+
"adblock",
|
|
28
|
+
"automation",
|
|
29
|
+
"device-emulation",
|
|
30
|
+
"performance"
|
|
30
31
|
],
|
|
31
32
|
"dependencies": {
|
|
32
|
-
"@browserless/devices": "^10.
|
|
33
|
-
"@ghostery/adblocker-puppeteer": "~2.
|
|
34
|
-
"debug-logfmt": "~1.4.
|
|
33
|
+
"@browserless/devices": "^10.9.18",
|
|
34
|
+
"@ghostery/adblocker-puppeteer": "~2.13.4",
|
|
35
|
+
"debug-logfmt": "~1.4.7",
|
|
35
36
|
"got": "~11.8.6",
|
|
36
|
-
"is-url-http": "~2.3.
|
|
37
|
+
"is-url-http": "~2.3.13",
|
|
37
38
|
"p-reflect": "~2.1.0",
|
|
38
39
|
"p-timeout": "~4.1.0",
|
|
39
40
|
"shallow-equal": "~3.1.0",
|
|
40
41
|
"tough-cookie": "~6.0.0"
|
|
41
42
|
},
|
|
42
43
|
"devDependencies": {
|
|
43
|
-
"@browserless/test": "^10.9.
|
|
44
|
+
"@browserless/test": "^10.9.18",
|
|
44
45
|
"ava": "5",
|
|
45
46
|
"p-wait-for": "3"
|
|
46
47
|
},
|
|
@@ -64,5 +65,5 @@
|
|
|
64
65
|
"timeout": "2m",
|
|
65
66
|
"workerThreads": false
|
|
66
67
|
},
|
|
67
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "f5e8cd0788e4bad3b3ad9b007943754f96653817"
|
|
68
69
|
}
|
package/src/engine.bin
CHANGED
|
Binary file
|