graceful-playwright 1.5.1 → 1.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/README.md CHANGED
@@ -122,6 +122,24 @@ export type GotoErrorDetails = {
122
122
  }
123
123
  ```
124
124
 
125
+ Helper Function: `getStealthChromiumArgs`
126
+
127
+ ```typescript
128
+ export function getStealthChromiumArgs(options: {
129
+ noSandbox?: boolean
130
+ /** default is a version of Mac OS */
131
+ userAgent?: string
132
+ }): string[]
133
+ ```
134
+
135
+ It returns list of arguments that can be used in `chromium.launch()` and `chromium.launchPersistentContext()`:
136
+
137
+ - `--no-sandbox` (conditionally)
138
+ - `--disable-setuid-sandbox` (conditionally)
139
+ - `--disable-dev-shm-usage`
140
+ - `--user-agent=${userAgent}`
141
+ - `--disable-blink-features=AutomationControlled`
142
+
125
143
  ## License
126
144
 
127
145
  This project is licensed with [BSD-2-Clause](./LICENSE)
package/core.d.ts CHANGED
@@ -1,4 +1,10 @@
1
1
  import { Browser, BrowserContext, Page } from 'playwright';
2
+ /** can be used in args by `chromium.launch()` and `chromium.launchPersistentContext()` */
3
+ export declare function getStealthChromiumArgs(options?: {
4
+ noSandbox?: boolean;
5
+ /** default is a version of Mac OS */
6
+ userAgent?: string;
7
+ }): string[];
2
8
  export declare class GracefulPage {
3
9
  options: {
4
10
  from: Browser | BrowserContext;
package/core.js CHANGED
@@ -1,7 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GotoError = exports.GracefulPage = void 0;
4
+ exports.getStealthChromiumArgs = getStealthChromiumArgs;
4
5
  exports.parseRetryAfter = parseRetryAfter;
6
+ /** can be used in args by `chromium.launch()` and `chromium.launchPersistentContext()` */
7
+ function getStealthChromiumArgs(options = {}) {
8
+ let userAgent = options.userAgent ||
9
+ 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.67 Safari/537.36';
10
+ let args = [];
11
+ if (options.noSandbox) {
12
+ args.push('--no-sandbox', '--disable-setuid-sandbox');
13
+ }
14
+ args.push('--disable-dev-shm-usage', `--user-agent=${userAgent}`, '--disable-blink-features=AutomationControlled');
15
+ return args;
16
+ }
5
17
  class GracefulPage {
6
18
  options;
7
19
  constructor(options) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "graceful-playwright",
3
- "version": "1.5.1",
3
+ "version": "1.6.0",
4
4
  "description": "Gracefully handle timeout and network error with auto retry.",
5
5
  "keywords": [
6
6
  "graceful",