gologin 2.0.21 → 2.0.23
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/examples/example-custom-args.js +34 -0
- package/package.json +1 -1
- package/src/gologin.js +6 -2
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import puppeteer from 'puppeteer-core';
|
|
2
|
+
|
|
3
|
+
import GoLogin from '../src/gologin.js';
|
|
4
|
+
|
|
5
|
+
(async () => {
|
|
6
|
+
const GL = new GoLogin({
|
|
7
|
+
profile_id: 'yU0Pr0f1leiD',
|
|
8
|
+
token: 'yU0token',
|
|
9
|
+
args: ['--disable-background-timer-throttling', '--disable-backgrounding-occluded-windows', '--disable-renderer-backgrounding'],
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
const { status, wsUrl } = await GL.start().catch((e) => {
|
|
13
|
+
console.trace(e);
|
|
14
|
+
|
|
15
|
+
return { status: 'failure' };
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
if (status !== 'success') {
|
|
19
|
+
console.log('Invalid status');
|
|
20
|
+
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const browser = await puppeteer.connect({
|
|
25
|
+
browserWSEndpoint: wsUrl.toString(),
|
|
26
|
+
ignoreHTTPSErrors: true,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const page = await browser.newPage();
|
|
30
|
+
await page.goto('https://myip.link/mini');
|
|
31
|
+
console.log(await page.content());
|
|
32
|
+
await browser.close();
|
|
33
|
+
await GL.stop();
|
|
34
|
+
})();
|
package/package.json
CHANGED
package/src/gologin.js
CHANGED
|
@@ -59,6 +59,7 @@ export class GoLogin {
|
|
|
59
59
|
this.waitWebsocket = false;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
+
this.isCloudHeadless = options.isCloudHeadless || true;
|
|
62
63
|
this.isNewCloudBrowser = true;
|
|
63
64
|
if (options.isNewCloudBrowser === false) {
|
|
64
65
|
this.isNewCloudBrowser = false;
|
|
@@ -72,6 +73,7 @@ export class GoLogin {
|
|
|
72
73
|
this.remote_debugging_port = options.remote_debugging_port || 0;
|
|
73
74
|
this.timezone = options.timezone;
|
|
74
75
|
this.extensionPathsToInstall = [];
|
|
76
|
+
this.customArgs = options.args || [];
|
|
75
77
|
this.restoreLastSession = options.restoreLastSession || false;
|
|
76
78
|
this.processSpawned = null;
|
|
77
79
|
this.processKillTimeout = 1 * 1000;
|
|
@@ -836,7 +838,7 @@ export class GoLogin {
|
|
|
836
838
|
}
|
|
837
839
|
|
|
838
840
|
async spawnBrowser() {
|
|
839
|
-
let { remote_debugging_port } = this;
|
|
841
|
+
let { remote_debugging_port, customArgs } = this;
|
|
840
842
|
if (!remote_debugging_port) {
|
|
841
843
|
remote_debugging_port = await this.getRandomPort();
|
|
842
844
|
}
|
|
@@ -927,6 +929,8 @@ export class GoLogin {
|
|
|
927
929
|
params.push('--restore-last-session');
|
|
928
930
|
}
|
|
929
931
|
|
|
932
|
+
params.push(...new Set(customArgs));
|
|
933
|
+
|
|
930
934
|
console.log(params);
|
|
931
935
|
const child = execFile(ORBITA_BROWSER, params, { env });
|
|
932
936
|
this.processSpawned = child;
|
|
@@ -1461,7 +1465,7 @@ export class GoLogin {
|
|
|
1461
1465
|
|
|
1462
1466
|
const profileResponse = await requests.post(`${API_URL}/browser/${this.profile_id}/web`, {
|
|
1463
1467
|
headers: { 'Authorization': `Bearer ${this.access_token}` },
|
|
1464
|
-
json: { isNewCloudBrowser: this.isNewCloudBrowser },
|
|
1468
|
+
json: { isNewCloudBrowser: this.isNewCloudBrowser, isHeadless: this.isCloudHeadless },
|
|
1465
1469
|
});
|
|
1466
1470
|
|
|
1467
1471
|
debug('profileResponse', profileResponse.statusCode, profileResponse.body);
|