mirror of
https://github.com/yeongpin/cursor-free-vip.git
synced 2025-08-03 04:57:36 +08:00
change other mail site
This commit is contained in:
parent
5d944fa3b1
commit
887239d80c
@ -65,33 +65,26 @@ class CursorRegistration:
|
||||
"""设置邮箱"""
|
||||
try:
|
||||
print(f"{Fore.CYAN}{EMOJI['START']} {self.translator.get('register.browser_start')}...{Style.RESET_ALL}")
|
||||
self.browser = self.browser_manager.init_browser()
|
||||
self.controller = BrowserControl(self.browser, self.translator)
|
||||
|
||||
# 打开邮箱生成器页面(第一个标签页)
|
||||
self.controller.navigate_to(self.mail_url)
|
||||
self.email_tab = self.browser # 保存邮箱标签页
|
||||
self.controller.email_tab = self.email_tab # 同时保存到controller
|
||||
# 使用 new_tempemail 创建临时邮箱,传入 translator
|
||||
from new_tempemail import NewTempEmail
|
||||
self.temp_email = NewTempEmail(self.translator) # 传入 translator
|
||||
|
||||
# 生成新邮箱
|
||||
self.controller.generate_new_email()
|
||||
# 创建临时邮箱
|
||||
email_address = self.temp_email.create_email()
|
||||
if not email_address:
|
||||
print(f"{Fore.RED}{EMOJI['ERROR']} {self.translator.get('register.email_create_failed')}{Style.RESET_ALL}")
|
||||
return False
|
||||
|
||||
# 选择随机域名
|
||||
self.controller.select_email_domain()
|
||||
# 保存邮箱地址和浏览器实例
|
||||
self.email_address = email_address
|
||||
self.email_tab = self.temp_email # 传递 NewTempEmail 实例而不是 page
|
||||
self.controller = BrowserControl(self.temp_email.page, self.translator)
|
||||
|
||||
# 获取邮箱地址
|
||||
self.email_address = self.controller.copy_and_get_email()
|
||||
if self.email_address:
|
||||
print(f"{EMOJI['MAIL']}{Fore.CYAN} {self.translator.get('register.get_email_address')}: {self.email_address}{Style.RESET_ALL}")
|
||||
|
||||
# 进入邮箱
|
||||
if self.controller.view_mailbox():
|
||||
return True
|
||||
|
||||
return False
|
||||
return True
|
||||
|
||||
except Exception as e:
|
||||
print(f"{Fore.RED}{EMOJI['ERROR']} {self.translator.get('register.setup_error', error=str(e))}{Style.RESET_ALL}")
|
||||
print(f"{Fore.RED}{EMOJI['ERROR']} {self.translator.get('register.email_setup_failed', error=str(e))}{Style.RESET_ALL}")
|
||||
return False
|
||||
|
||||
def register_cursor(self):
|
||||
@ -233,8 +226,12 @@ class CursorRegistration:
|
||||
return True
|
||||
return False
|
||||
finally:
|
||||
if self.browser_manager:
|
||||
self.browser_manager.quit()
|
||||
# 关闭邮箱标签页
|
||||
if hasattr(self, 'temp_email'):
|
||||
try:
|
||||
self.temp_email.close()
|
||||
except:
|
||||
pass
|
||||
|
||||
def update_cursor_auth(self, email=None, access_token=None, refresh_token=None):
|
||||
"""更新Cursor的认证信息的便捷函数"""
|
||||
|
@ -122,7 +122,8 @@
|
||||
"save_account_info_failed": "Save Account Info Failed",
|
||||
"get_email_address": "Get Email Address",
|
||||
"update_cursor_auth_info": "Update Cursor Auth Info",
|
||||
"register_process_error": "Register Process Error: {error}"
|
||||
"register_process_error": "Register Process Error: {error}",
|
||||
"setting_password": "Setting Password"
|
||||
},
|
||||
"auth": {
|
||||
"title": "Cursor Auth Manager",
|
||||
@ -174,5 +175,23 @@
|
||||
"database_updated_successfully": "Database Updated Successfully",
|
||||
"database_connection_closed": "Database Connection Closed",
|
||||
"no_valid_verification_code": "No Valid Verification Code"
|
||||
},
|
||||
"email": {
|
||||
"starting_browser": "Starting Browser",
|
||||
"visiting_site": "Visiting smailpro.com",
|
||||
"create_success": "Email Created Successfully",
|
||||
"create_failed": "Failed to Create Email",
|
||||
"create_error": "Email Creation Error: {error}",
|
||||
"refreshing": "Refreshing Email",
|
||||
"refresh_success": "Email Refreshed Successfully",
|
||||
"refresh_error": "Email Refresh Error: {error}",
|
||||
"refresh_button_not_found": "Refresh Button Not Found",
|
||||
"verification_found": "Verification Found",
|
||||
"verification_not_found": "Verification Not Found",
|
||||
"verification_error": "Verification Error: {error}",
|
||||
"verification_code_found": "Verification Code Found",
|
||||
"verification_code_not_found": "Verification Code Not Found",
|
||||
"verification_code_error": "Verification Code Error: {error}",
|
||||
"address": "Email Address"
|
||||
}
|
||||
}
|
@ -122,7 +122,8 @@
|
||||
"save_account_info_failed": "保存账户信息失败",
|
||||
"get_email_address": "获取邮箱地址",
|
||||
"register_process_error": "注册流程错误: {error}",
|
||||
"update_cursor_auth_info": "更新Cursor认证信息"
|
||||
"update_cursor_auth_info": "更新Cursor认证信息",
|
||||
"setting_password": "设置密码"
|
||||
},
|
||||
"auth": {
|
||||
"title": "Cursor 认证管理器",
|
||||
@ -171,5 +172,23 @@
|
||||
"get_cursor_session_token_failed": "获取Cursor Session Token失败",
|
||||
"save_token_failed": "保存Token失败",
|
||||
"no_valid_verification_code": "没有有效的验证码"
|
||||
},
|
||||
"email": {
|
||||
"starting_browser": "启动浏览器",
|
||||
"visiting_site": "访问 smailpro.com",
|
||||
"create_success": "邮箱创建成功",
|
||||
"create_failed": "邮箱创建失败",
|
||||
"create_error": "邮箱创建错误: {error}",
|
||||
"refreshing": "刷新邮箱",
|
||||
"refresh_success": "邮箱刷新成功",
|
||||
"refresh_error": "邮箱刷新错误: {error}",
|
||||
"refresh_button_not_found": "未找到刷新按钮",
|
||||
"verification_found": "找到验证码",
|
||||
"verification_not_found": "未找到验证码",
|
||||
"verification_error": "验证错误: {error}",
|
||||
"verification_code_found": "找到验证码",
|
||||
"verification_code_not_found": "未找到验证码",
|
||||
"verification_code_error": "验证码错误: {error}",
|
||||
"address": "邮箱地址"
|
||||
}
|
||||
}
|
@ -122,7 +122,8 @@
|
||||
"save_account_info_failed": "保存賬戶信息失敗",
|
||||
"get_email_address": "獲取郵箱地址",
|
||||
"register_process_error": "註冊流程錯誤: {error}",
|
||||
"update_cursor_auth_info": "更新Cursor認證信息"
|
||||
"update_cursor_auth_info": "更新Cursor認證信息",
|
||||
"setting_password": "設置密碼"
|
||||
},
|
||||
"auth": {
|
||||
"title": "Cursor 認證管理器",
|
||||
@ -171,5 +172,24 @@
|
||||
"save_token_failed": "保存Token失敗",
|
||||
"blocked_domain": "被屏蔽的域名",
|
||||
"no_valid_verification_code": "沒有有效的驗證碼"
|
||||
},
|
||||
"email": {
|
||||
"starting_browser": "啟動瀏覽器",
|
||||
"visiting_site": "訪問 smailpro.com",
|
||||
"create_success": "郵箱創建成功",
|
||||
"create_failed": "郵箱創建失敗",
|
||||
"create_error": "郵箱創建錯誤: {error}",
|
||||
"refreshing": "刷新郵箱",
|
||||
"refresh_success": "郵箱刷新成功",
|
||||
"refresh_error": "郵箱刷新錯誤: {error}",
|
||||
"refresh_button_not_found": "未找到刷新按鈕",
|
||||
"verification_found": "找到驗證碼",
|
||||
"verification_not_found": "未找到驗證碼",
|
||||
"verification_error": "驗證錯誤: {error}",
|
||||
"verification_code_found": "找到驗證碼",
|
||||
"verification_code_not_found": "未找到驗證碼",
|
||||
"verification_code_error": "驗證碼錯誤: {error}",
|
||||
"address": "郵箱地址"
|
||||
}
|
||||
|
||||
}
|
175
new_signup.py
175
new_signup.py
@ -3,6 +3,7 @@ import time
|
||||
import os
|
||||
import signal
|
||||
import random
|
||||
from colorama import Fore, Style
|
||||
|
||||
# 在文件开头添加全局变量
|
||||
_translator = None
|
||||
@ -19,7 +20,7 @@ def cleanup_chrome_processes(translator=None):
|
||||
os.system('pkill -f chromedriver')
|
||||
except Exception as e:
|
||||
if translator:
|
||||
print(f"{translator.get('register.cleanup_error', error=str(e))}")
|
||||
print(f"{Fore.RED}❌ {translator.get('register.cleanup_error', error=str(e))}{Style.RESET_ALL}")
|
||||
else:
|
||||
print(f"清理进程时出错: {e}")
|
||||
|
||||
@ -27,7 +28,7 @@ def signal_handler(signum, frame):
|
||||
"""处理Ctrl+C信号"""
|
||||
global _translator
|
||||
if _translator:
|
||||
print(f"{_translator.get('register.exit_signal')}")
|
||||
print(f"{Fore.CYAN}{_translator.get('register.exit_signal')}{Style.RESET_ALL}")
|
||||
else:
|
||||
print("\n接收到退出信号,正在关闭...")
|
||||
cleanup_chrome_processes(_translator)
|
||||
@ -36,7 +37,7 @@ def signal_handler(signum, frame):
|
||||
def simulate_human_input(page, url, translator=None):
|
||||
"""访问网址"""
|
||||
if translator:
|
||||
print(f"{translator.get('register.visiting_url')}: {url}")
|
||||
print(f"{Fore.CYAN}🚀 {translator.get('register.visiting_url')}: {url}{Style.RESET_ALL}")
|
||||
else:
|
||||
print("正在访问网址...")
|
||||
|
||||
@ -52,7 +53,7 @@ def fill_signup_form(page, first_name, last_name, email, translator=None):
|
||||
"""填写注册表单"""
|
||||
try:
|
||||
if translator:
|
||||
print(f"{translator.get('register.filling_form')}")
|
||||
print(f"{Fore.CYAN}📧 {translator.get('register.filling_form')}{Style.RESET_ALL}")
|
||||
else:
|
||||
print("\n正在填写注册表单...")
|
||||
|
||||
@ -81,14 +82,14 @@ def fill_signup_form(page, first_name, last_name, email, translator=None):
|
||||
time.sleep(random.uniform(2.0, 3.0))
|
||||
|
||||
if translator:
|
||||
print(f"{translator.get('register.form_success')}")
|
||||
print(f"{Fore.GREEN}✅ {translator.get('register.form_success')}{Style.RESET_ALL}")
|
||||
else:
|
||||
print("表单填写完成")
|
||||
return True
|
||||
|
||||
except Exception as e:
|
||||
if translator:
|
||||
print(f"{translator.get('register.form_error', error=str(e))}")
|
||||
print(f"{Fore.RED}❌ {translator.get('register.form_error', error=str(e))}{Style.RESET_ALL}")
|
||||
else:
|
||||
print(f"填写表单时出错: {e}")
|
||||
return False
|
||||
@ -99,6 +100,7 @@ def setup_driver(translator=None):
|
||||
|
||||
# 使用无痕模式
|
||||
co.set_argument("--incognito")
|
||||
co.set_argument("--headless=new")
|
||||
|
||||
# 设置随机端口
|
||||
co.auto_port()
|
||||
@ -114,12 +116,12 @@ def setup_driver(translator=None):
|
||||
co.add_extension(extension_path)
|
||||
except Exception as e:
|
||||
if translator:
|
||||
print(f"{translator.get('register.extension_load_error', error=str(e))}")
|
||||
print(f"{Fore.RED}❌ {translator.get('register.extension_load_error', error=str(e))}{Style.RESET_ALL}")
|
||||
else:
|
||||
print(f"加载插件失败: {e}")
|
||||
|
||||
if translator:
|
||||
print(f"{translator.get('register.starting_browser')}")
|
||||
print(f"{Fore.CYAN}🚀 {translator.get('register.starting_browser')}{Style.RESET_ALL}")
|
||||
else:
|
||||
print("正在启动浏览器...")
|
||||
page = ChromiumPage(co)
|
||||
@ -130,7 +132,7 @@ def handle_turnstile(page, translator=None):
|
||||
"""处理 Turnstile 验证"""
|
||||
try:
|
||||
if translator:
|
||||
print(f"{translator.get('register.handling_turnstile')}")
|
||||
print(f"{Fore.CYAN}🔄 {translator.get('register.handling_turnstile')}{Style.RESET_ALL}")
|
||||
else:
|
||||
print("\n正在处理 Turnstile 验证...")
|
||||
|
||||
@ -140,7 +142,7 @@ def handle_turnstile(page, translator=None):
|
||||
while retry_count < max_retries:
|
||||
retry_count += 1
|
||||
if translator:
|
||||
print(f"{translator.get('register.retry_verification', attempt=retry_count)}")
|
||||
print(f"{Fore.CYAN}🔄 {translator.get('register.retry_verification', attempt=retry_count)}{Style.RESET_ALL}")
|
||||
else:
|
||||
print(f"第 {retry_count} 次尝试验证...")
|
||||
|
||||
@ -160,7 +162,7 @@ def handle_turnstile(page, translator=None):
|
||||
|
||||
if challenge_check:
|
||||
if translator:
|
||||
print(f"{translator.get('register.detect_turnstile')}")
|
||||
print(f"{Fore.CYAN}🔄 {translator.get('register.detect_turnstile')}{Style.RESET_ALL}")
|
||||
else:
|
||||
print("检测到验证框...")
|
||||
|
||||
@ -172,21 +174,21 @@ def handle_turnstile(page, translator=None):
|
||||
# 检查验证结果
|
||||
if check_verification_success(page, translator):
|
||||
if translator:
|
||||
print(f"{translator.get('register.verification_success')}")
|
||||
print(f"{Fore.GREEN}✅ {translator.get('register.verification_success')}{Style.RESET_ALL}")
|
||||
else:
|
||||
print("验证通过!")
|
||||
return True
|
||||
|
||||
except Exception as e:
|
||||
if translator:
|
||||
print(f"{translator.get('register.verification_failed')}")
|
||||
print(f"{Fore.RED}❌ {translator.get('register.verification_failed')}{Style.RESET_ALL}")
|
||||
else:
|
||||
print(f"验证尝试失败: {e}")
|
||||
|
||||
# 检查是否已经验证成功
|
||||
if check_verification_success(page, translator):
|
||||
if translator:
|
||||
print(f"{translator.get('register.verification_success')}")
|
||||
print(f"{Fore.GREEN}✅ {translator.get('register.verification_success')}{Style.RESET_ALL}")
|
||||
else:
|
||||
print("验证通过!")
|
||||
return True
|
||||
@ -194,14 +196,14 @@ def handle_turnstile(page, translator=None):
|
||||
time.sleep(random.uniform(1, 2))
|
||||
|
||||
if translator:
|
||||
print(f"{translator.get('register.verification_failed')}")
|
||||
print(f"{Fore.RED}❌ {translator.get('register.verification_failed')}{Style.RESET_ALL}")
|
||||
else:
|
||||
print("超出最大重试次数")
|
||||
return False
|
||||
|
||||
except Exception as e:
|
||||
if translator:
|
||||
print(f"{translator.get('register.verification_error', error=str(e))}")
|
||||
print(f"{Fore.RED}❌ {translator.get('register.verification_error', error=str(e))}{Style.RESET_ALL}")
|
||||
else:
|
||||
print(f"验证过程出错: {e}")
|
||||
return False
|
||||
@ -239,7 +241,10 @@ def generate_password(length=12):
|
||||
def fill_password(page, password, translator=None):
|
||||
"""填写密码"""
|
||||
try:
|
||||
print("\n正在设置密码...")
|
||||
if translator:
|
||||
print(f"{Fore.CYAN}🔑 {translator.get('register.setting_password')}{Style.RESET_ALL}")
|
||||
else:
|
||||
print("\n正在设置密码...")
|
||||
password_input = page.ele("@name=password")
|
||||
if password_input:
|
||||
password_input.input(password)
|
||||
@ -251,14 +256,14 @@ def fill_password(page, password, translator=None):
|
||||
time.sleep(random.uniform(2.0, 3.0))
|
||||
|
||||
if translator:
|
||||
print(f"{translator.get('register.password_success')}")
|
||||
print(f"{Fore.GREEN}✅ {translator.get('register.password_success')}{Style.RESET_ALL}")
|
||||
else:
|
||||
print(f"密码设置完成: {password}")
|
||||
return True
|
||||
|
||||
except Exception as e:
|
||||
if translator:
|
||||
print(f"{translator.get('register.password_error', error=str(e))}")
|
||||
print(f"{Fore.RED}❌ {translator.get('register.password_error', error=str(e))}{Style.RESET_ALL}")
|
||||
else:
|
||||
print(f"设置密码时出错: {e}")
|
||||
return False
|
||||
@ -267,13 +272,54 @@ def handle_verification_code(browser_tab, email_tab, controller, email, password
|
||||
"""处理验证码"""
|
||||
try:
|
||||
if translator:
|
||||
print(f"\n{translator.get('register.waiting_for_verification_code')}")
|
||||
print(f"\n{Fore.CYAN}{translator.get('register.waiting_for_verification_code')}{Style.RESET_ALL}")
|
||||
else:
|
||||
print("\n等待并获取验证码...")
|
||||
|
||||
# 添加调试信息
|
||||
print(f"\n{Fore.CYAN}DEBUG: email_tab exists: {email_tab is not None}{Style.RESET_ALL}")
|
||||
|
||||
time.sleep(5) # 等待验证码邮件
|
||||
|
||||
# 刷新邮箱页面
|
||||
email_tab.refresh()
|
||||
# 使用已有的 email_tab 刷新邮箱
|
||||
email_tab.refresh_inbox()
|
||||
time.sleep(3)
|
||||
|
||||
# 检查邮箱是否有验证码邮件
|
||||
if email_tab.check_for_cursor_email():
|
||||
verification_code = email_tab.get_verification_code()
|
||||
if verification_code:
|
||||
# 在注册页面填写验证码
|
||||
for i, digit in enumerate(verification_code):
|
||||
browser_tab.ele(f"@data-index={i}").input(digit)
|
||||
time.sleep(random.uniform(0.1, 0.3))
|
||||
if translator:
|
||||
print(f"{Fore.GREEN}✅ {translator.get('register.verification_success')}{Style.RESET_ALL}")
|
||||
else:
|
||||
print("验证码填写完成")
|
||||
time.sleep(3)
|
||||
|
||||
# 处理最后一次 Turnstile 验证
|
||||
if handle_turnstile(browser_tab, translator):
|
||||
if translator:
|
||||
print(f"{Fore.GREEN}✅ {translator.get('register.verification_success')}{Style.RESET_ALL}")
|
||||
else:
|
||||
print("最后一次验证通过!")
|
||||
time.sleep(2)
|
||||
|
||||
# 访问设置页面
|
||||
if translator:
|
||||
print(f"{Fore.CYAN}🔑 {translator.get('register.visiting_url')}: https://www.cursor.com/settings{Style.RESET_ALL}")
|
||||
else:
|
||||
print("访问设置页面...")
|
||||
browser_tab.get("https://www.cursor.com/settings")
|
||||
time.sleep(3) # 等待页面加载
|
||||
return True
|
||||
else:
|
||||
print("最后一次验证失败")
|
||||
return False
|
||||
|
||||
return False
|
||||
|
||||
# 获取验证码,设置超时
|
||||
verification_code = None
|
||||
@ -283,7 +329,7 @@ def handle_verification_code(browser_tab, email_tab, controller, email, password
|
||||
timeout = 160
|
||||
|
||||
if translator:
|
||||
print(f"\n{translator.get('register.start_getting_verification_code')}")
|
||||
print(f"{Fore.CYAN}{translator.get('register.start_getting_verification_code')}{Style.RESET_ALL}")
|
||||
else:
|
||||
print("开始获取验证码...")
|
||||
|
||||
@ -291,7 +337,7 @@ def handle_verification_code(browser_tab, email_tab, controller, email, password
|
||||
# 检查是否超时
|
||||
if time.time() - start_time > timeout:
|
||||
if translator:
|
||||
print(f"{translator.get('register.verification_timeout')}")
|
||||
print(f"{Fore.RED}❌ {translator.get('register.verification_timeout')}{Style.RESET_ALL}")
|
||||
else:
|
||||
print("获取验证码超时...")
|
||||
break
|
||||
@ -299,19 +345,19 @@ def handle_verification_code(browser_tab, email_tab, controller, email, password
|
||||
verification_code = controller.get_verification_code()
|
||||
if verification_code:
|
||||
if translator:
|
||||
print(f"{translator.get('register.verification_success')}")
|
||||
print(f"{Fore.GREEN}✅ {translator.get('register.verification_success')}{Style.RESET_ALL}")
|
||||
else:
|
||||
print(f"成功获取验证码: {verification_code}")
|
||||
break
|
||||
|
||||
remaining_time = int(timeout - (time.time() - start_time))
|
||||
if translator:
|
||||
print(f"{translator.get('register.try_get_code', attempt=attempt + 1, time=remaining_time)}")
|
||||
print(f"{Fore.CYAN}{translator.get('register.try_get_code', attempt=attempt + 1, time=remaining_time)}{Style.RESET_ALL}")
|
||||
else:
|
||||
print(f"第 {attempt + 1} 次尝试获取验证码,剩余时间: {remaining_time}秒...")
|
||||
|
||||
# 刷新邮箱
|
||||
email_tab.refresh()
|
||||
email_tab.refresh_inbox()
|
||||
time.sleep(retry_interval)
|
||||
|
||||
if verification_code:
|
||||
@ -321,7 +367,7 @@ def handle_verification_code(browser_tab, email_tab, controller, email, password
|
||||
time.sleep(random.uniform(0.1, 0.3))
|
||||
|
||||
if translator:
|
||||
print(f"{translator.get('register.verification_success')}")
|
||||
print(f"{Fore.GREEN}✅ {translator.get('register.verification_success')}{Style.RESET_ALL}")
|
||||
else:
|
||||
print("验证码填写完成")
|
||||
time.sleep(3)
|
||||
@ -329,14 +375,14 @@ def handle_verification_code(browser_tab, email_tab, controller, email, password
|
||||
# 处理最后一次 Turnstile 验证
|
||||
if handle_turnstile(browser_tab, translator):
|
||||
if translator:
|
||||
print(f"{translator.get('register.verification_success')}")
|
||||
print(f"{Fore.GREEN}✅ {translator.get('register.verification_success')}{Style.RESET_ALL}")
|
||||
else:
|
||||
print("最后一次验证通过!")
|
||||
time.sleep(2)
|
||||
|
||||
# 直接访问设置页面
|
||||
if translator:
|
||||
print(f"{translator.get('register.visiting_url')}: https://www.cursor.com/settings")
|
||||
print(f"{Fore.CYAN}{translator.get('register.visiting_url')}: https://www.cursor.com/settings{Style.RESET_ALL}")
|
||||
else:
|
||||
print("访问设置页面...")
|
||||
browser_tab.get("https://www.cursor.com/settings")
|
||||
@ -347,7 +393,7 @@ def handle_verification_code(browser_tab, email_tab, controller, email, password
|
||||
|
||||
else:
|
||||
if translator:
|
||||
print(f"{translator.get('register.verification_failed')}")
|
||||
print(f"{Fore.RED}❌ {translator.get('register.verification_failed')}{Style.RESET_ALL}")
|
||||
else:
|
||||
print("最后一次验证失败")
|
||||
return False
|
||||
@ -356,11 +402,60 @@ def handle_verification_code(browser_tab, email_tab, controller, email, password
|
||||
|
||||
except Exception as e:
|
||||
if translator:
|
||||
print(f"{translator.get('register.verification_error', error=str(e))}")
|
||||
print(f"{Fore.RED}❌ {translator.get('register.verification_error', error=str(e))}{Style.RESET_ALL}")
|
||||
else:
|
||||
print(f"处理验证码时出错: {e}")
|
||||
return False
|
||||
|
||||
def handle_sign_in(browser_tab, email, password, translator=None):
|
||||
"""处理登录流程"""
|
||||
try:
|
||||
# 检查是否在登录页面
|
||||
sign_in_header = browser_tab.ele('xpath://h1[contains(text(), "Sign in")]')
|
||||
if not sign_in_header:
|
||||
return True # 如果不是登录页面,说明已经登录成功
|
||||
|
||||
print(f"{Fore.CYAN}检测到登录页面,开始登录...{Style.RESET_ALL}")
|
||||
|
||||
# 填写邮箱
|
||||
email_input = browser_tab.ele('@name=email')
|
||||
if email_input:
|
||||
email_input.input(email)
|
||||
time.sleep(1)
|
||||
|
||||
# 点击 Continue
|
||||
continue_button = browser_tab.ele('xpath://button[contains(@class, "BrandedButton") and text()="Continue"]')
|
||||
if continue_button:
|
||||
continue_button.click()
|
||||
time.sleep(2)
|
||||
|
||||
# 处理 Turnstile 验证
|
||||
if handle_turnstile(browser_tab, translator):
|
||||
# 填写密码
|
||||
password_input = browser_tab.ele('@name=password')
|
||||
if password_input:
|
||||
password_input.input(password)
|
||||
time.sleep(1)
|
||||
|
||||
# 点击 Sign in
|
||||
sign_in_button = browser_tab.ele('xpath://button[@name="intent" and @value="password"]')
|
||||
if sign_in_button:
|
||||
sign_in_button.click()
|
||||
time.sleep(2)
|
||||
|
||||
# 处理最后一次 Turnstile 验证
|
||||
if handle_turnstile(browser_tab, translator):
|
||||
print(f"{Fore.GREEN}登录成功!{Style.RESET_ALL}")
|
||||
time.sleep(3)
|
||||
return True
|
||||
|
||||
print(f"{Fore.RED}登录失败{Style.RESET_ALL}")
|
||||
return False
|
||||
|
||||
except Exception as e:
|
||||
print(f"{Fore.RED}登录过程出错: {str(e)}{Style.RESET_ALL}")
|
||||
return False
|
||||
|
||||
def main(email=None, password=None, first_name=None, last_name=None, email_tab=None, controller=None, translator=None):
|
||||
"""主函数,可以接收账号信息、邮箱标签页和翻译器"""
|
||||
global _translator
|
||||
@ -374,21 +469,21 @@ def main(email=None, password=None, first_name=None, last_name=None, email_tab=N
|
||||
try:
|
||||
page = setup_driver(translator)
|
||||
if translator:
|
||||
print(f"{translator.get('register.browser_started')}")
|
||||
print(f"{Fore.CYAN}🚀 {translator.get('register.browser_started')}{Style.RESET_ALL}")
|
||||
else:
|
||||
print("浏览器已启动")
|
||||
|
||||
# 访问注册页面
|
||||
url = "https://authenticator.cursor.sh/sign-up"
|
||||
if translator:
|
||||
print(f"\n{translator.get('register.visiting_url')}: {url}")
|
||||
print(f"\n{Fore.CYAN}{translator.get('register.visiting_url')}: {url}{Style.RESET_ALL}")
|
||||
else:
|
||||
print(f"\n正在访问: {url}")
|
||||
|
||||
# 访问页面
|
||||
simulate_human_input(page, url, translator)
|
||||
if translator:
|
||||
print(f"{translator.get('register.waiting_for_page_load')}")
|
||||
print(f"{Fore.CYAN}{translator.get('register.waiting_for_page_load')}{Style.RESET_ALL}")
|
||||
else:
|
||||
print("等待页面加载...")
|
||||
time.sleep(5)
|
||||
@ -410,21 +505,21 @@ def main(email=None, password=None, first_name=None, last_name=None, email_tab=N
|
||||
# 填写表单
|
||||
if fill_signup_form(page, first_name, last_name, email, translator):
|
||||
if translator:
|
||||
print(f"\n{translator.get('register.form_submitted')}")
|
||||
print(f"\n{Fore.GREEN}{translator.get('register.form_submitted')}{Style.RESET_ALL}")
|
||||
else:
|
||||
print("\n表单已提交,开始验证...")
|
||||
|
||||
# 处理第一次 Turnstile 验证
|
||||
if handle_turnstile(page, translator):
|
||||
if translator:
|
||||
print(f"\n{translator.get('register.first_verification_passed')}")
|
||||
print(f"\n{Fore.GREEN}{translator.get('register.first_verification_passed')}{Style.RESET_ALL}")
|
||||
else:
|
||||
print("\n第一阶段验证通过!")
|
||||
|
||||
# 填写密码
|
||||
if fill_password(page, password, translator):
|
||||
if translator:
|
||||
print(f"\n{translator.get('register.waiting_for_second_verification')}")
|
||||
print(f"\n{Fore.CYAN}{translator.get('register.waiting_for_second_verification')}{Style.RESET_ALL}")
|
||||
else:
|
||||
print("\n等待第二次验证...")
|
||||
time.sleep(2)
|
||||
@ -432,12 +527,12 @@ def main(email=None, password=None, first_name=None, last_name=None, email_tab=N
|
||||
# 处理第二次 Turnstile 验证
|
||||
if handle_turnstile(page, translator):
|
||||
if translator:
|
||||
print(f"\n{translator.get('register.waiting_for_verification_code')}")
|
||||
print(f"\n{Fore.CYAN}{translator.get('register.waiting_for_verification_code')}{Style.RESET_ALL}")
|
||||
else:
|
||||
print("\n开始处理验证码...")
|
||||
if handle_verification_code(page, email_tab, controller, email, password, translator):
|
||||
if translator:
|
||||
print(f"\n{translator.get('register.verification_success')}")
|
||||
print(f"\n{Fore.GREEN}{translator.get('register.verification_success')}{Style.RESET_ALL}")
|
||||
else:
|
||||
print("\n注册流程完成!")
|
||||
success = True
|
||||
|
226
new_tempemail.py
Normal file
226
new_tempemail.py
Normal file
@ -0,0 +1,226 @@
|
||||
from DrissionPage import ChromiumPage, ChromiumOptions
|
||||
import time
|
||||
import os
|
||||
import sys
|
||||
from colorama import Fore, Style, init
|
||||
|
||||
# 初始化 colorama
|
||||
init()
|
||||
|
||||
class NewTempEmail:
|
||||
def __init__(self, translator=None):
|
||||
self.translator = translator
|
||||
self.page = None
|
||||
self.setup_browser()
|
||||
|
||||
def get_extension_block(self):
|
||||
"""获取插件路径"""
|
||||
root_dir = os.getcwd()
|
||||
extension_path = os.path.join(root_dir, "uBlock0.chromium")
|
||||
|
||||
if hasattr(sys, "_MEIPASS"):
|
||||
extension_path = os.path.join(sys._MEIPASS, "uBlock0.chromium")
|
||||
|
||||
if not os.path.exists(extension_path):
|
||||
raise FileNotFoundError(f"插件不存在: {extension_path}")
|
||||
|
||||
return extension_path
|
||||
|
||||
def setup_browser(self):
|
||||
"""设置浏览器"""
|
||||
try:
|
||||
if self.translator:
|
||||
print(f"{Fore.CYAN}ℹ️ {self.translator.get('email.starting_browser')}{Style.RESET_ALL}")
|
||||
else:
|
||||
print(f"{Fore.CYAN}ℹ️ 正在启动浏览器...{Style.RESET_ALL}")
|
||||
|
||||
# 创建浏览器选项
|
||||
co = ChromiumOptions()
|
||||
co.set_argument("--headless=new")
|
||||
|
||||
co.auto_port() # 自动设置端口
|
||||
|
||||
# 加载 uBlock 插件
|
||||
try:
|
||||
extension_path = self.get_extension_block()
|
||||
co.set_argument("--allow-extensions-in-incognito")
|
||||
co.add_extension(extension_path)
|
||||
except Exception as e:
|
||||
if self.translator:
|
||||
print(f"{Fore.YELLOW}⚠️ {self.translator.get('email.extension_load_error')}: {str(e)}{Style.RESET_ALL}")
|
||||
else:
|
||||
print(f"{Fore.YELLOW}⚠️ 加载插件失败: {str(e)}{Style.RESET_ALL}")
|
||||
|
||||
self.page = ChromiumPage(co)
|
||||
return True
|
||||
except Exception as e:
|
||||
if self.translator:
|
||||
print(f"{Fore.RED}❌ {self.translator.get('email.browser_start_error')}: {str(e)}{Style.RESET_ALL}")
|
||||
else:
|
||||
print(f"{Fore.RED}❌ 启动浏览器失败: {str(e)}{Style.RESET_ALL}")
|
||||
return False
|
||||
|
||||
def create_email(self):
|
||||
"""创建临时邮箱"""
|
||||
try:
|
||||
if self.translator:
|
||||
print(f"{Fore.CYAN}ℹ️ {self.translator.get('email.visiting_site')}{Style.RESET_ALL}")
|
||||
else:
|
||||
print(f"{Fore.CYAN}ℹ️ 正在访问 smailpro.com...{Style.RESET_ALL}")
|
||||
|
||||
# 访问网站
|
||||
self.page.get("https://smailpro.com/")
|
||||
time.sleep(2)
|
||||
|
||||
# 点击创建邮箱按钮
|
||||
create_button = self.page.ele('xpath://button[@title="Create temporary email"]')
|
||||
if create_button:
|
||||
create_button.click()
|
||||
time.sleep(1)
|
||||
|
||||
# 点击弹窗中的 Create 按钮
|
||||
modal_create_button = self.page.ele('xpath://button[contains(text(), "Create")]')
|
||||
if modal_create_button:
|
||||
modal_create_button.click()
|
||||
time.sleep(2)
|
||||
|
||||
# 获取邮箱地址 - 修改选择器
|
||||
email_div = self.page.ele('xpath://div[@class="text-base sm:text-lg md:text-xl text-gray-700"]')
|
||||
if email_div:
|
||||
email = email_div.text.strip()
|
||||
if '@' in email: # 验证是否是有效的邮箱地址
|
||||
if self.translator:
|
||||
print(f"{Fore.GREEN}✅ {self.translator.get('email.create_success')}: {email}{Style.RESET_ALL}")
|
||||
else:
|
||||
print(f"{Fore.GREEN}✅ 创建邮箱成功: {email}{Style.RESET_ALL}")
|
||||
return email
|
||||
if self.translator:
|
||||
print(f"{Fore.RED}❌ {self.translator.get('email.create_failed')}{Style.RESET_ALL}")
|
||||
else:
|
||||
print(f"{Fore.RED}❌ 创建邮箱失败{Style.RESET_ALL}")
|
||||
return None
|
||||
|
||||
except Exception as e:
|
||||
if self.translator:
|
||||
print(f"{Fore.RED}❌ {self.translator.get('email.create_error')}: {str(e)}{Style.RESET_ALL}")
|
||||
else:
|
||||
print(f"{Fore.RED}❌ 创建邮箱出错: {str(e)}{Style.RESET_ALL}")
|
||||
return None
|
||||
|
||||
def close(self):
|
||||
"""关闭浏览器"""
|
||||
if self.page:
|
||||
self.page.quit()
|
||||
|
||||
def refresh_inbox(self):
|
||||
"""刷新邮箱"""
|
||||
try:
|
||||
if self.translator:
|
||||
print(f"{Fore.CYAN}🔄 {self.translator.get('email.refreshing')}{Style.RESET_ALL}")
|
||||
else:
|
||||
print(f"{Fore.CYAN}🔄 正在刷新邮箱...{Style.RESET_ALL}")
|
||||
|
||||
# 点击刷新按钮
|
||||
refresh_button = self.page.ele('xpath://button[@id="refresh"]')
|
||||
if refresh_button:
|
||||
refresh_button.click()
|
||||
time.sleep(2) # 等待刷新完成
|
||||
if self.translator:
|
||||
print(f"{Fore.GREEN}✅ {self.translator.get('email.refresh_success')}{Style.RESET_ALL}")
|
||||
else:
|
||||
print(f"{Fore.GREEN}✅ 邮箱刷新成功{Style.RESET_ALL}")
|
||||
return True
|
||||
|
||||
if self.translator:
|
||||
print(f"{Fore.RED}❌ {self.translator.get('email.refresh_button_not_found')}{Style.RESET_ALL}")
|
||||
else:
|
||||
print(f"{Fore.RED}❌ 未找到刷新按钮{Style.RESET_ALL}")
|
||||
return False
|
||||
|
||||
except Exception as e:
|
||||
if self.translator:
|
||||
print(f"{Fore.RED}❌ {self.translator.get('email.refresh_error')}: {str(e)}{Style.RESET_ALL}")
|
||||
else:
|
||||
print(f"{Fore.RED}❌ 刷新邮箱出错: {str(e)}{Style.RESET_ALL}")
|
||||
return False
|
||||
|
||||
def check_for_cursor_email(self):
|
||||
"""检查是否有 Cursor 的验证邮件"""
|
||||
try:
|
||||
# 查找验证邮件 - 使用更精确的选择器
|
||||
email_div = self.page.ele('xpath://div[contains(@class, "p-2") and contains(@class, "cursor-pointer") and contains(@class, "bg-white") and contains(@class, "shadow") and .//b[text()="no-reply@cursor.sh"] and .//span[text()="Verify your email address"]]')
|
||||
if email_div:
|
||||
if self.translator:
|
||||
print(f"{Fore.GREEN}✅ {self.translator.get('email.verification_found')}{Style.RESET_ALL}")
|
||||
else:
|
||||
print(f"{Fore.GREEN}✅ 找到验证邮件{Style.RESET_ALL}")
|
||||
# 使用 JavaScript 点击元素
|
||||
self.page.run_js('arguments[0].click()', email_div)
|
||||
time.sleep(2) # 等待邮件内容加载
|
||||
return True
|
||||
if self.translator:
|
||||
print(f"{Fore.YELLOW}⚠️ {self.translator.get('email.verification_not_found')}{Style.RESET_ALL}")
|
||||
else:
|
||||
print(f"{Fore.YELLOW}⚠️ 未找到验证邮件{Style.RESET_ALL}")
|
||||
return False
|
||||
|
||||
except Exception as e:
|
||||
if self.translator:
|
||||
print(f"{Fore.RED}❌ {self.translator.get('email.verification_error')}: {str(e)}{Style.RESET_ALL}")
|
||||
else:
|
||||
print(f"{Fore.RED}❌ 检查验证邮件出错: {str(e)}{Style.RESET_ALL}")
|
||||
return False
|
||||
|
||||
def get_verification_code(self):
|
||||
"""获取验证码"""
|
||||
try:
|
||||
# 查找验证码元素
|
||||
code_element = self.page.ele('xpath://td//div[contains(@style, "font-size:28px") and contains(@style, "letter-spacing:2px")]')
|
||||
if code_element:
|
||||
code = code_element.text.strip()
|
||||
if code.isdigit() and len(code) == 6:
|
||||
if self.translator:
|
||||
print(f"{Fore.GREEN}✅ {self.translator.get('email.verification_code_found')}: {code}{Style.RESET_ALL}")
|
||||
else:
|
||||
print(f"{Fore.GREEN}✅ 获取验证码成功: {code}{Style.RESET_ALL}")
|
||||
return code
|
||||
if self.translator:
|
||||
print(f"{Fore.YELLOW}⚠️ {self.translator.get('email.verification_code_not_found')}{Style.RESET_ALL}")
|
||||
else:
|
||||
print(f"{Fore.YELLOW}⚠️ 未找到有效的验证码{Style.RESET_ALL}")
|
||||
return None
|
||||
|
||||
except Exception as e:
|
||||
if self.translator:
|
||||
print(f"{Fore.RED}❌ {self.translator.get('email.verification_code_error')}: {str(e)}{Style.RESET_ALL}")
|
||||
else:
|
||||
print(f"{Fore.RED}❌ 获取验证码出错: {str(e)}{Style.RESET_ALL}")
|
||||
return None
|
||||
|
||||
def main(translator=None):
|
||||
temp_email = NewTempEmail(translator)
|
||||
|
||||
try:
|
||||
email = temp_email.create_email()
|
||||
if email:
|
||||
if translator:
|
||||
print(f"\n{Fore.CYAN}📧 {translator.get('email.address')}: {email}{Style.RESET_ALL}")
|
||||
else:
|
||||
print(f"\n{Fore.CYAN}📧 临时邮箱地址: {email}{Style.RESET_ALL}")
|
||||
|
||||
# 测试刷新功能
|
||||
while True:
|
||||
if translator:
|
||||
choice = input(f"\n{translator.get('email.refresh_prompt')}: ").lower()
|
||||
else:
|
||||
choice = input("\n按 R 刷新邮箱,按 Q 退出: ").lower()
|
||||
if choice == 'r':
|
||||
temp_email.refresh_inbox()
|
||||
elif choice == 'q':
|
||||
break
|
||||
|
||||
finally:
|
||||
temp_email.close()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Loading…
x
Reference in New Issue
Block a user