From 01d09ccbc4ff791664fd998a03c60fc18e0eeab1 Mon Sep 17 00:00:00 2001 From: adrapier03 Date: Wed, 8 Jul 2026 00:36:39 +0700 Subject: [PATCH] feat: launch new browser process per loop iteration to ensure fresh fingerprint per account --- automation.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/automation.js b/automation.js index 0edd51c..34513af 100644 --- a/automation.js +++ b/automation.js @@ -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); \ No newline at end of file