gologin 2.0.22 → 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 +4 -1
|
@@ -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
|
@@ -73,6 +73,7 @@ export class GoLogin {
|
|
|
73
73
|
this.remote_debugging_port = options.remote_debugging_port || 0;
|
|
74
74
|
this.timezone = options.timezone;
|
|
75
75
|
this.extensionPathsToInstall = [];
|
|
76
|
+
this.customArgs = options.args || [];
|
|
76
77
|
this.restoreLastSession = options.restoreLastSession || false;
|
|
77
78
|
this.processSpawned = null;
|
|
78
79
|
this.processKillTimeout = 1 * 1000;
|
|
@@ -837,7 +838,7 @@ export class GoLogin {
|
|
|
837
838
|
}
|
|
838
839
|
|
|
839
840
|
async spawnBrowser() {
|
|
840
|
-
let { remote_debugging_port } = this;
|
|
841
|
+
let { remote_debugging_port, customArgs } = this;
|
|
841
842
|
if (!remote_debugging_port) {
|
|
842
843
|
remote_debugging_port = await this.getRandomPort();
|
|
843
844
|
}
|
|
@@ -928,6 +929,8 @@ export class GoLogin {
|
|
|
928
929
|
params.push('--restore-last-session');
|
|
929
930
|
}
|
|
930
931
|
|
|
932
|
+
params.push(...new Set(customArgs));
|
|
933
|
+
|
|
931
934
|
console.log(params);
|
|
932
935
|
const child = execFile(ORBITA_BROWSER, params, { env });
|
|
933
936
|
this.processSpawned = child;
|