gologin 2.1.14 → 2.1.15
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-cloud.js +17 -0
- package/examples/example-iphey.js +1 -1
- package/package.json +1 -1
- package/src/gologin-api.js +15 -8
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { exitAll, GologinApi } from '../src/gologin-api.js';
|
|
2
|
+
|
|
3
|
+
const token = process.env.GOLOGIN_API_TOKEN; // get token https://app.gologin.com/personalArea/TokenApi
|
|
4
|
+
const gologin = GologinApi({ token });
|
|
5
|
+
|
|
6
|
+
async function main() {
|
|
7
|
+
const { browser } = await gologin.launch({ cloud: true });
|
|
8
|
+
const page = await browser.newPage();
|
|
9
|
+
await page.goto('https://iphey.com/', { waitUntil: 'networkidle2' });
|
|
10
|
+
const status = await page.$eval('.trustworthy:not(.hide)', (elt) =>
|
|
11
|
+
elt?.innerText?.trim(),
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
return status; // Expecting 'Trustworthy'
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
main().catch(console.error).then(console.info).finally(exitAll);
|
|
@@ -7,7 +7,7 @@ async function main() {
|
|
|
7
7
|
const { browser } = await gologin.launch();
|
|
8
8
|
const page = await browser.newPage();
|
|
9
9
|
await page.goto('https://iphey.com/', { waitUntil: 'networkidle2' });
|
|
10
|
-
const status = await page.$eval('.trustworthy
|
|
10
|
+
const status = await page.$eval('.trustworthy:not(.hide)', (elt) =>
|
|
11
11
|
elt?.innerText?.trim(),
|
|
12
12
|
);
|
|
13
13
|
|
package/package.json
CHANGED
package/src/gologin-api.js
CHANGED
|
@@ -61,15 +61,20 @@ export function GologinApi({ token }) {
|
|
|
61
61
|
};
|
|
62
62
|
|
|
63
63
|
const launchCloudProfile = async (params) => {
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
const legacyGologin = createLegacyGologin({
|
|
65
|
+
...params,
|
|
66
|
+
token,
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
if (!params.profileId) {
|
|
70
|
+
const { id } = await legacyGologin.quickCreateProfile();
|
|
71
|
+
await legacyGologin.setProfileId(id);
|
|
72
|
+
params.profileId = id;
|
|
73
|
+
}
|
|
67
74
|
|
|
68
|
-
|
|
69
|
-
? `&geolocation=${params.geolocation}`
|
|
70
|
-
: '';
|
|
75
|
+
legacyGls.push(legacyGologin);
|
|
71
76
|
|
|
72
|
-
const browserWSEndpoint = `https://
|
|
77
|
+
const browserWSEndpoint = `https://cloudbrowser.gologin.com/connect?token=${token}&profile=${params.profileId}`;
|
|
73
78
|
const browser = await puppeteer.connect({
|
|
74
79
|
browserWSEndpoint,
|
|
75
80
|
ignoreHTTPSErrors: true,
|
|
@@ -94,7 +99,9 @@ export function GologinApi({ token }) {
|
|
|
94
99
|
Promise.allSettled(
|
|
95
100
|
legacyGls.map((gl) => gl.stopLocal({ posting: false })),
|
|
96
101
|
);
|
|
97
|
-
|
|
102
|
+
Promise.allSettled(
|
|
103
|
+
legacyGls.map((gl) => gl.stopRemote({ posting: true })),
|
|
104
|
+
);
|
|
98
105
|
},
|
|
99
106
|
|
|
100
107
|
delay,
|