import { GologinApi } from 'gologin';
// Token can be passed here in code or from env
const token = process.env.GL_API_TOKEN || 'your dev token here';
const gologin = GologinApi({
token,
// If you want to run particular profile you need to pass profileId param
});
async function main() {
// This line of code creates new profile that will be run. If you want to run existed profile - delete this line of code
const profile = await gologin.createProfileRandomFingerprint();
const profileId = profile.id;
// This line of code adds gologin proxy to the profile.
await gologin.addGologinProxyToProfile(profileId, 'US');
// This line of code starts the browser and return object that can be managed by puppeteer
const { browser } = await gologin.launch({ profileId });
// Opens new page in browser
const page = await browser.newPage();
// Goes to website and waits untill all parts of the website is loaded
await page.goto('https://iphey.com/', { waitUntil: 'networkidle2' });
// Reads profile check result in website
const status = await page.$eval('.trustworthy:not(.hide)',
(elt) => elt?.innerText?.trim(),
);
await new Promise((resolve) => setTimeout(resolve, 10000));
console.log('status', status);
// This line of code deletes used profile. If you dont want to delete used profie - remove this line
await gologin.deleteProfile(profileId);
return status;
}
main().catch(console.error)
.finally(gologin.exit);