@browserless/goto 9.4.1 → 9.6.0
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 +4 -3
- package/src/engine.bin +0 -0
- package/src/evasions/index.js +4 -2
- package/src/evasions/navigator-vendor.js +25 -0
- package/src/evasions/window-frame.js +9 -0
- package/src/index.js +7 -31
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": "9.
|
|
5
|
+
"version": "9.6.0",
|
|
6
6
|
"main": "src/index.js",
|
|
7
7
|
"author": {
|
|
8
8
|
"email": "hello@microlink.io",
|
|
@@ -47,7 +47,8 @@
|
|
|
47
47
|
"@browserless/test": "latest",
|
|
48
48
|
"ava": "3",
|
|
49
49
|
"browserless": "latest",
|
|
50
|
-
"exit-hook": "2"
|
|
50
|
+
"exit-hook": "2",
|
|
51
|
+
"fpscanner": "latest"
|
|
51
52
|
},
|
|
52
53
|
"engines": {
|
|
53
54
|
"node": ">= 12"
|
|
@@ -68,5 +69,5 @@
|
|
|
68
69
|
"timeout": "2m",
|
|
69
70
|
"verbose": true
|
|
70
71
|
},
|
|
71
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "ed21c66d61affc17cf23dfb54a1c2071dc08de11"
|
|
72
73
|
}
|
package/src/engine.bin
CHANGED
|
Binary file
|
package/src/evasions/index.js
CHANGED
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
module.exports = {
|
|
4
4
|
chromeRuntime: require('./chrome-runtime'),
|
|
5
|
-
stackTraces: require('./stack-traces'),
|
|
6
5
|
mediaCodecs: require('./media-codecs'),
|
|
7
6
|
navigatorPermissions: require('./navigator-permissions'),
|
|
8
7
|
navigatorPlugins: require('./navigator-plugins'),
|
|
8
|
+
navigatorVendor: require('./navigator-vendor'),
|
|
9
9
|
randomizeUserAgent: require('./randomize-user-agent'),
|
|
10
|
-
|
|
10
|
+
stackTraces: require('./stack-traces'),
|
|
11
|
+
webglVendor: require('./webgl-vendor'),
|
|
12
|
+
windowFrame: require('./window-frame')
|
|
11
13
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module.exports = page =>
|
|
2
|
+
page.evaluateOnNewDocument(async () => {
|
|
3
|
+
const getUserAgentVendor = userAgent => {
|
|
4
|
+
let vendor
|
|
5
|
+
|
|
6
|
+
if (userAgent.includes('Firefox')) {
|
|
7
|
+
vendor = 'firefox'
|
|
8
|
+
} else if (userAgent.includes('Chrome')) {
|
|
9
|
+
vendor = 'chrome'
|
|
10
|
+
} else {
|
|
11
|
+
vendor = 'safari'
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return vendor
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const userAgent = navigator.userAgent
|
|
18
|
+
const userAgentVendor = getUserAgentVendor(userAgent)
|
|
19
|
+
|
|
20
|
+
if (userAgentVendor === 'chrome') return
|
|
21
|
+
|
|
22
|
+
Object.defineProperty(navigator, 'vendor', {
|
|
23
|
+
value: userAgentVendor === 'safari' ? 'Apple Computer, Inc.' : ''
|
|
24
|
+
})
|
|
25
|
+
})
|
package/src/index.js
CHANGED
|
@@ -14,6 +14,8 @@ const isUrl = require('is-url-http')
|
|
|
14
14
|
const path = require('path')
|
|
15
15
|
const fs = require('fs')
|
|
16
16
|
|
|
17
|
+
const truncate = (str, n = 80) => (str.length > n ? str.substr(0, n - 1) + '…' : str)
|
|
18
|
+
|
|
17
19
|
const EVASIONS = require('./evasions')
|
|
18
20
|
|
|
19
21
|
const ALL_EVASIONS_KEYS = Object.keys(EVASIONS)
|
|
@@ -92,10 +94,7 @@ const disableAnimations = `
|
|
|
92
94
|
}
|
|
93
95
|
`.trim()
|
|
94
96
|
|
|
95
|
-
const inject = async (
|
|
96
|
-
page,
|
|
97
|
-
{ timeout, mediaType, animations, hide, remove, modules, scripts, styles }
|
|
98
|
-
) => {
|
|
97
|
+
const inject = async (page, { timeout, mediaType, animations, modules, scripts, styles }) => {
|
|
99
98
|
const postPromises = []
|
|
100
99
|
|
|
101
100
|
if (mediaType) {
|
|
@@ -118,26 +117,6 @@ const inject = async (
|
|
|
118
117
|
)
|
|
119
118
|
}
|
|
120
119
|
|
|
121
|
-
if (hide) {
|
|
122
|
-
postPromises.push(
|
|
123
|
-
run({
|
|
124
|
-
fn: injectStyle(page, `${castArray(hide).join(', ')} { visibility: hidden !important; }`),
|
|
125
|
-
timeout,
|
|
126
|
-
debug: 'hide'
|
|
127
|
-
})
|
|
128
|
-
)
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
if (remove) {
|
|
132
|
-
postPromises.push(
|
|
133
|
-
run({
|
|
134
|
-
fn: injectStyle(page, `${castArray(remove).join(', ')} { display: none !important; }`),
|
|
135
|
-
timeout,
|
|
136
|
-
debug: 'remove'
|
|
137
|
-
})
|
|
138
|
-
)
|
|
139
|
-
}
|
|
140
|
-
|
|
141
120
|
if (modules) {
|
|
142
121
|
postPromises.push(
|
|
143
122
|
run({
|
|
@@ -215,12 +194,10 @@ module.exports = ({
|
|
|
215
194
|
click,
|
|
216
195
|
colorScheme,
|
|
217
196
|
headers = {},
|
|
218
|
-
hide,
|
|
219
197
|
html,
|
|
220
198
|
javascript = true,
|
|
221
199
|
mediaType,
|
|
222
200
|
modules,
|
|
223
|
-
remove,
|
|
224
201
|
scripts,
|
|
225
202
|
scroll,
|
|
226
203
|
styles,
|
|
@@ -249,13 +226,14 @@ module.exports = ({
|
|
|
249
226
|
await page.setRequestInterception(true)
|
|
250
227
|
page.on('request', req => {
|
|
251
228
|
if (req.isInterceptResolutionHandled()) return
|
|
252
|
-
|
|
253
229
|
const resourceType = req.resourceType()
|
|
230
|
+
const url = truncate(req.url())
|
|
231
|
+
|
|
254
232
|
if (!abortTypes.includes(resourceType)) {
|
|
255
|
-
debug('continue', { url
|
|
233
|
+
debug('continue', { url, resourceType })
|
|
256
234
|
return req.continue(req.continueRequestOverrides(), 0)
|
|
257
235
|
}
|
|
258
|
-
debug('abort', { url
|
|
236
|
+
debug('abort', { url, resourceType })
|
|
259
237
|
return req.abort('blockedbyclient', 0)
|
|
260
238
|
})
|
|
261
239
|
}
|
|
@@ -384,8 +362,6 @@ module.exports = ({
|
|
|
384
362
|
timeout: actionTimeout,
|
|
385
363
|
mediaType,
|
|
386
364
|
animations,
|
|
387
|
-
hide,
|
|
388
|
-
remove,
|
|
389
365
|
modules,
|
|
390
366
|
scripts,
|
|
391
367
|
styles
|