-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathindex.js
33 lines (26 loc) · 1.19 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/* eslint-disable @typescript-eslint/no-require-imports */
const { KameleoLocalApiClient } = require("@kameleo/local-api-client");
const { setTimeout } = require("timers/promises");
void (async () => {
// This is the port Kameleo.CLI is listening on. Default value is 5050, but can be overridden in appsettings.json file
const kameleoPort = process.env["KAMELEO_PORT"] || 5050;
const client = new KameleoLocalApiClient({
basePath: `http://localhost:${kameleoPort}`,
});
// Search Chrome fingerprints
const fingerprints = await client.fingerprint.searchFingerprints("desktop", undefined, "chrome");
// Create a new profile with recommended settings
/** @type {import('@kameleo/local-api-client').CreateProfileRequest} */
const createProfileRequest = {
fingerprintId: fingerprints[0].id,
name: "CommonJS example",
startPage: "https://kameleo.io",
};
const profile = await client.profile.createProfile(createProfileRequest);
// Start the profile
await client.profile.startProfile(profile.id);
// Wait for 10 seconds
await setTimeout(10_000);
// Stop the profile
await client.profile.stopProfile(profile.id);
})();