cf-solver / test-tempmail.js
Samuel
update
15f7aec
const { connect } = require('puppeteer-real-browser');
async function getTempMail() {
console.log('Launching browser...');
const { browser, page } = await connect({
headless: 'auto',
args: ['--no-sandbox', '--disable-setuid-sandbox'],
turnstile: true
});
try {
console.log('Navigating to tmailor.com...');
await page.goto('https://tmailor.com', {
waitUntil: 'networkidle2',
timeout: 60000
});
console.log('Initial page load complete. Waiting...');
await new Promise(resolve => setTimeout(resolve, 3000));
console.log('Looking for Turnstile iframe to solve...');
async function solveTurnstile() {
const frames = page.frames();
for (const frame of frames) {
const url = frame.url();
console.log('Frame URL:', url);
if (url.includes('turnstile') || url.includes('challenges.cloudflare')) {
console.log('Found Turnstile challenge frame!');
try {
await new Promise(resolve => setTimeout(resolve, 2000));
const checkbox = await frame.$('input[type="checkbox"]');
if (checkbox) {
console.log('Clicking Turnstile checkbox...');
await checkbox.click();
return true;
}
const verifyButton = await frame.$('[id*="verify"], [class*="verify"], button');
if (verifyButton) {
console.log('Clicking verify button in frame...');
await verifyButton.click();
return true;
}
} catch (e) {
console.log('Error in Turnstile frame:', e.message);
}
}
}
return false;
}
let turnstileSolved = await solveTurnstile();
if (turnstileSolved) {
console.log('Turnstile interaction attempted, waiting for verification...');
await new Promise(resolve => setTimeout(resolve, 8000));
}
console.log('Checking for Confirm link on page...');
const confirmButtons = await page.$$('a[title*="verify"], a[href*="firewall"], button');
for (const btn of confirmButtons) {
const text = await page.evaluate(el => el.textContent, btn);
if (text && text.toLowerCase().includes('confirm')) {
console.log('Found Confirm button, clicking...');
await btn.click();
await new Promise(resolve => setTimeout(resolve, 5000));
turnstileSolved = await solveTurnstile();
if (turnstileSolved) {
await new Promise(resolve => setTimeout(resolve, 8000));
}
break;
}
}
console.log('Looking for New Email button...');
const buttons = await page.$$('button, a');
for (const btn of buttons) {
const text = await page.evaluate(el => el.textContent, btn);
if (text && text.includes('New Email')) {
console.log('Found New Email button, clicking...');
await btn.click();
await new Promise(resolve => setTimeout(resolve, 3000));
break;
}
}
console.log('Waiting for email to appear...');
await new Promise(resolve => setTimeout(resolve, 5000));
let email = null;
console.log('Searching for email in page...');
const allText = await page.evaluate(() => document.body.innerText);
const emailPatterns = allText.match(/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g);
if (emailPatterns) {
const filtered = emailPatterns.filter(e =>
!e.includes('gmail.com') &&
!e.includes('tmailor.com@') &&
!e.toLowerCase().includes('support')
);
if (filtered.length > 0) {
email = filtered[0];
console.log('Found email in page text:', email);
}
}
if (!email) {
const emailSelectors = [
'#email',
'#tempmail',
'.email-address',
'[data-email]',
'input[readonly]',
'input[type="text"]',
'.copy-text',
'code',
'pre'
];
for (const selector of emailSelectors) {
try {
const elements = await page.$$(selector);
for (const element of elements) {
const value = await page.evaluate(el => {
return el.value || el.textContent || el.getAttribute('data-email') || el.getAttribute('data-clipboard-text');
}, element);
if (value && value.includes('@') && !value.includes('gmail')) {
email = value.trim();
console.log(`Found email with selector "${selector}": ${email}`);
break;
}
}
if (email) break;
} catch (e) {}
}
}
console.log('\nTaking screenshot...');
await page.screenshot({ path: 'tmailor-screenshot.png', fullPage: true });
console.log('Screenshot saved to tmailor-screenshot.png');
console.log('\n=== RESULT ===');
if (email && email.includes('@')) {
console.log('SUCCESS! Temp Email:', email);
} else {
console.log('Could not find a temp email address');
console.log('\n--- Page visible text (first 1500 chars) ---');
console.log(allText.substring(0, 1500));
}
return email;
} catch (error) {
console.error('Error:', error.message);
} finally {
await browser.close();
console.log('Browser closed.');
}
}
getTempMail();