feat: launch new browser process per loop iteration to ensure fresh fingerprint per account
This commit is contained in:
+10
-7
@@ -45,11 +45,6 @@ const isHeadless = headlessIndex !== -1 ? (process.argv[headlessIndex + 1] !== '
|
||||
|
||||
async function run() {
|
||||
const { launch } = await import('cloakbrowser');
|
||||
console.log(`Launching CloakBrowser (headless: ${isHeadless})...`);
|
||||
const browser = await launch({
|
||||
headless: isHeadless,
|
||||
humanize: true, // CloakBrowser internal humanization (curves, touches, RTC, WebGL)
|
||||
});
|
||||
|
||||
for (let i = 0; i < accounts.length; i++) {
|
||||
const account = accounts[i];
|
||||
@@ -57,6 +52,12 @@ async function run() {
|
||||
console.log(`[Account ${i + 1}/${accounts.length}] Processing: ${account.email}`);
|
||||
console.log(`==================================================`);
|
||||
|
||||
console.log(`Launching CloakBrowser with new fingerprint (headless: ${isHeadless})...`);
|
||||
const browser = await launch({
|
||||
headless: isHeadless,
|
||||
humanize: true, // CloakBrowser internal humanization (curves, touches, RTC, WebGL)
|
||||
});
|
||||
|
||||
// Create a clean isolated context for each account to prevent session leaks
|
||||
const context = await browser.newContext({
|
||||
permissions: ['clipboard-read', 'clipboard-write'],
|
||||
@@ -216,13 +217,15 @@ async function run() {
|
||||
} catch (err) {
|
||||
console.error(`[Account ${i + 1}/${accounts.length}] Failed with error:`, err.message || err);
|
||||
} finally {
|
||||
// Close context to clear session cookies for the next account
|
||||
// Close context and browser to finalize this session and generate a new fingerprint for the next loop
|
||||
await context.close();
|
||||
await browser.close();
|
||||
console.log('Browser closed. Waiting a moment before processing next account...');
|
||||
await sleepRandom(2000, 4000);
|
||||
}
|
||||
}
|
||||
|
||||
console.log('\nAll accounts processed.');
|
||||
await browser.close();
|
||||
}
|
||||
|
||||
run().catch(console.error);
|
||||
Reference in New Issue
Block a user