Update English Message

This commit is contained in:
yeongpin 2025-01-14 15:35:37 +08:00
parent ddaafd5c3d
commit 803fea0b71
3 changed files with 96 additions and 96 deletions

View File

@ -25,20 +25,20 @@ class BrowserControl:
# 保存新标签页
self.signup_tab = new_browser
print(f"{Fore.GREEN}成功创建新窗口{Style.RESET_ALL}")
print(f"{Fore.GREEN}Create New Tab Success | 成功创建新窗口{Style.RESET_ALL}")
return new_browser
except Exception as e:
print(f"{Fore.RED}创建新窗口时发生错误: {str(e)}{Style.RESET_ALL}")
print(f"{Fore.RED}Create New Tab Failed | 创建新窗口时发生错误: {str(e)}{Style.RESET_ALL}")
return None
def switch_to_tab(self, browser):
"""切换到指定浏览器窗口"""
try:
self.browser = browser
print(f"{Fore.GREEN}成功切换窗口{Style.RESET_ALL}")
print(f"{Fore.GREEN}Switch Tab Success | 成功切换窗口{Style.RESET_ALL}")
return True
except Exception as e:
print(f"{Fore.RED}切换窗口时发生错误: {str(e)}{Style.RESET_ALL}")
print(f"{Fore.RED}Switch Tab Failed | 切换窗口时发生错误: {str(e)}{Style.RESET_ALL}")
return False
def get_current_tab(self):
@ -48,24 +48,24 @@ class BrowserControl:
def generate_new_email(self):
"""点击新的按钮生成新邮箱"""
try:
print(f"{Fore.CYAN}点击生成新邮箱...{Style.RESET_ALL}")
print(f"{Fore.CYAN}Click Generate New Email | 点击生成新邮箱...{Style.RESET_ALL}")
new_button = self.browser.ele('xpath://button[contains(@class, "egenbut")]')
if new_button:
new_button.click()
time.sleep(1) # 等待生成
print(f"{Fore.GREEN}成功生成新邮箱{Style.RESET_ALL}")
print(f"{Fore.GREEN}Generate New Email | 成功生成新邮箱{Style.RESET_ALL}")
return True
else:
print(f"{Fore.RED}未找到生成按钮{Style.RESET_ALL}")
print(f"{Fore.RED}No Generate Button Found | 未找到生成按钮{Style.RESET_ALL}")
return False
except Exception as e:
print(f"{Fore.RED}生成新邮箱时发生错误: {str(e)}{Style.RESET_ALL}")
print(f"{Fore.RED}Generate New Email Failed | 生成新邮箱时发生错误: {str(e)}{Style.RESET_ALL}")
return False
def select_email_domain(self, domain_index=None):
"""选择邮箱域名如果不指定index则随机选择"""
try:
print(f"{Fore.CYAN}选择邮箱域名...{Style.RESET_ALL}")
print(f"{Fore.CYAN}Select Email Domain | 选择邮箱域名...{Style.RESET_ALL}")
# 找到下拉框
select_element = self.browser.ele('xpath://select[@id="seldom"]')
if select_element:
@ -88,21 +88,21 @@ class BrowserControl:
if domain_index < len(all_options):
# 获取选中选项的文本
selected_domain = all_options[domain_index].text
print(f"{Fore.CYAN}选择域名: {selected_domain}{Style.RESET_ALL}")
print(f"{Fore.CYAN}Select Email Domain | 选择域名: {selected_domain}{Style.RESET_ALL}")
# 点击选择
all_options[domain_index].click()
time.sleep(1)
print(f"{Fore.GREEN}成功选择邮箱域名{Style.RESET_ALL}")
print(f"{Fore.GREEN}Select Email Domain | 成功选择邮箱域名{Style.RESET_ALL}")
return True
print(f"{Fore.RED}未找到可用的域名选项,总共有 {len(all_options)} 个选项{Style.RESET_ALL}")
print(f"{Fore.RED}No Available Domain Options | 未找到可用的域名选项,总共有 {len(all_options)} 个选项{Style.RESET_ALL}")
return False
else:
print(f"{Fore.RED}未找到域名选择框{Style.RESET_ALL}")
print(f"{Fore.RED}No Domain Select Box Found | 未找到域名选择框{Style.RESET_ALL}")
return False
except Exception as e:
print(f"{Fore.RED}选择邮箱域名时发生错误: {str(e)}{Style.RESET_ALL}")
print(f"{Fore.RED}Select Email Domain Failed | 选择邮箱域名时发生错误: {str(e)}{Style.RESET_ALL}")
return False
def wait_for_page_load(self, seconds=2):
@ -112,18 +112,18 @@ class BrowserControl:
def navigate_to(self, url):
"""导航到指定URL"""
try:
print(f"{Fore.CYAN}正在访问 {url}...{Style.RESET_ALL}")
print(f"{Fore.CYAN}Navigate to {url} | 正在访问 {url}...{Style.RESET_ALL}")
self.browser.get(url)
self.wait_for_page_load()
return True
except Exception as e:
print(f"{Fore.RED}访问 {url} 时发生错误: {str(e)}{Style.RESET_ALL}")
print(f"{Fore.RED}Visit {url} Failed | 访问 {url} 时发生错误: {str(e)}{Style.RESET_ALL}")
return False
def copy_and_get_email(self):
"""获取邮箱地址"""
try:
print(f"{Fore.CYAN}获取邮箱信息...{Style.RESET_ALL}")
print(f"{Fore.CYAN}Get Email Info | 获取邮箱信息...{Style.RESET_ALL}")
# 等待元素加载
time.sleep(1)
@ -133,12 +133,12 @@ class BrowserControl:
email_div = self.browser.ele('xpath://div[@class="segen"]//div[contains(@style, "color: #e5e5e5")]')
if email_div:
email_name = email_div.text.split()[0]
print(f"{Fore.CYAN}找到邮箱名称: {email_name}{Style.RESET_ALL}")
print(f"{Fore.CYAN}Get Email Name | 找到邮箱名称: {email_name}{Style.RESET_ALL}")
else:
print(f"{Fore.RED}无法找到邮箱名称元素{Style.RESET_ALL}")
print(f"{Fore.RED}Get Email Name Failed | 无法找到邮箱名称元素{Style.RESET_ALL}")
return None
except Exception as e:
print(f"{Fore.RED}获取邮箱名称时出错: {str(e)}{Style.RESET_ALL}")
print(f"{Fore.RED}Get Email Name Failed | 获取邮箱名称时出错: {str(e)}{Style.RESET_ALL}")
return None
# 直接使用上一步选择的域名
@ -152,45 +152,45 @@ class BrowserControl:
# 组合完整邮箱地址
full_email = f"{email_name}{domain}"
print(f"{Fore.GREEN}完整邮箱地址: {full_email}{Style.RESET_ALL}")
print(f"{Fore.GREEN}Get Email Address | 完整邮箱地址: {full_email}{Style.RESET_ALL}")
return full_email
except Exception as e:
print(f"{Fore.RED}获取邮箱地址时发生错误: {str(e)}{Style.RESET_ALL}")
print(f"{Fore.RED}Get Email Address Failed | 获取邮箱地址时发生错误: {str(e)}{Style.RESET_ALL}")
return None
def view_mailbox(self):
"""点击查看邮箱按钮"""
try:
print(f"{Fore.CYAN}正在进入邮箱...{Style.RESET_ALL}")
print(f"{Fore.CYAN}Enter Mailbox | 正在进入邮箱...{Style.RESET_ALL}")
view_button = self.browser.ele('xpath://button[contains(@class, "egenbut") and contains(.//span, "查看邮箱")]')
if view_button:
view_button.click()
time.sleep(2) # 等待页面加载
print(f"{Fore.GREEN}成功进入邮箱{Style.RESET_ALL}")
print(f"{Fore.GREEN}Successfully Entered Mailbox | 成功进入邮箱{Style.RESET_ALL}")
return True
else:
print(f"{Fore.RED}未找到查看邮箱按钮{Style.RESET_ALL}")
print(f"{Fore.RED}No View Mailbox Button Found | 未找到查看邮箱按钮{Style.RESET_ALL}")
return False
except Exception as e:
print(f"{Fore.RED}进入邮箱时发生错误: {str(e)}{Style.RESET_ALL}")
print(f"{Fore.RED}Enter Mailbox Failed | 进入邮箱时发生错误: {str(e)}{Style.RESET_ALL}")
return False
def refresh_mailbox(self):
"""刷新邮箱获取最新信息"""
try:
print(f"{Fore.CYAN}正在刷新邮箱...{Style.RESET_ALL}")
print(f"{Fore.CYAN}Refresh Mailbox | 正在刷新邮箱...{Style.RESET_ALL}")
refresh_button = self.browser.ele('xpath://button[@id="refresh"]')
if refresh_button:
refresh_button.click()
time.sleep(2) # 等待刷新完成
print(f"{Fore.GREEN}邮箱刷新成功{Style.RESET_ALL}")
print(f"{Fore.GREEN}Mailbox Refreshed Successfully | 邮箱刷新成功{Style.RESET_ALL}")
return True
else:
print(f"{Fore.RED}未找到刷新按钮{Style.RESET_ALL}")
print(f"{Fore.RED}No Refresh Button Found | 未找到刷新按钮{Style.RESET_ALL}")
return False
except Exception as e:
print(f"{Fore.RED}刷新邮箱时发生错误: {str(e)}{Style.RESET_ALL}")
print(f"{Fore.RED}Refresh Mailbox Failed | 刷新邮箱时发生错误: {str(e)}{Style.RESET_ALL}")
return False
def check_and_click_recaptcha(self):
@ -204,12 +204,12 @@ class BrowserControl:
# 直接点击预设坐标
self.browser.page.mouse.click(click_x, click_y)
print(f"{Fore.GREEN}已点击 reCAPTCHA 位置{Style.RESET_ALL}")
print(f"{Fore.GREEN}Clicked reCAPTCHA Position | 已点击 reCAPTCHA 位置{Style.RESET_ALL}")
time.sleep(1)
return True
except Exception as e:
print(f"{Fore.YELLOW}点击 reCAPTCHA 失败: {str(e)}{Style.RESET_ALL}")
print(f"{Fore.YELLOW}Click reCAPTCHA Failed | 点击 reCAPTCHA 失败: {str(e)}{Style.RESET_ALL}")
return False
def get_verification_code(self):
@ -220,10 +220,10 @@ class BrowserControl:
if code_div:
verification_code = code_div.text.strip()
if verification_code.isdigit() and len(verification_code) == 6:
print(f"{Fore.GREEN}找到验证码: {verification_code}{Style.RESET_ALL}")
print(f"{Fore.GREEN}Found Verification Code | 找到验证码: {verification_code}{Style.RESET_ALL}")
return verification_code
else:
print(f"{Fore.RED}验证码格式不正确: {verification_code}{Style.RESET_ALL}")
print(f"{Fore.RED}Verification Code Format Error | 验证码格式不正确: {verification_code}{Style.RESET_ALL}")
return None
else:
# 尝试备用XPath
@ -231,22 +231,22 @@ class BrowserControl:
if code_div:
verification_code = code_div.text.strip()
if verification_code.isdigit() and len(verification_code) == 6:
print(f"{Fore.GREEN}找到验证码: {verification_code}{Style.RESET_ALL}")
print(f"{Fore.GREEN}Found Verification Code | 找到验证码: {verification_code}{Style.RESET_ALL}")
return verification_code
print(f"{Fore.RED}未找到验证码{Style.RESET_ALL}")
print(f"{Fore.RED}No Verification Code Found | 未找到验证码{Style.RESET_ALL}")
return None
except Exception as e:
print(f"{Fore.RED}获取验证码时发生错误: {str(e)}{Style.RESET_ALL}")
print(f"{Fore.RED}Get Verification Code Failed | 获取验证码时发生错误: {str(e)}{Style.RESET_ALL}")
return None
def fill_verification_code(self, code):
"""填写验证码"""
try:
if not code or len(code) != 6:
print(f"{Fore.RED}验证码格式不正确{Style.RESET_ALL}")
print(f"{Fore.RED}Verification Code Format Error | 验证码格式不正确{Style.RESET_ALL}")
return False
print(f"{Fore.CYAN}正在填写验证码...{Style.RESET_ALL}")
print(f"{Fore.CYAN}Fill Verification Code | 正在填写验证码...{Style.RESET_ALL}")
# 记住当前标签页(邮箱页面)
email_tab = self.browser
@ -260,10 +260,10 @@ class BrowserControl:
self.browser.actions.input(digit)
time.sleep(random.uniform(0.1, 0.3))
print(f"{Fore.GREEN}验证码填写完成{Style.RESET_ALL}")
print(f"{Fore.GREEN}Verification Code Filled | 验证码填写完成{Style.RESET_ALL}")
# 等待页面加载和登录完成
print(f"{Fore.CYAN}等待登录完成...{Style.RESET_ALL}")
print(f"{Fore.CYAN}Wait for Login | 等待登录完成...{Style.RESET_ALL}")
time.sleep(5)
# 先访问登录页面确保登录状态
@ -274,7 +274,7 @@ class BrowserControl:
# 获取cookies第一次尝试
token = self.get_cursor_session_token()
if not token:
print(f"{Fore.YELLOW}首次获取token失败等待后重试...{Style.RESET_ALL}")
print(f"{Fore.YELLOW}Get Token Failed | 首次获取token失败等待后重试...{Style.RESET_ALL}")
time.sleep(3)
token = self.get_cursor_session_token()
@ -283,7 +283,7 @@ class BrowserControl:
# 获取到token后再访问设置页面
settings_url = "https://www.cursor.com/settings"
print(f"{Fore.CYAN}正在访问设置页面获取账户信息...{Style.RESET_ALL}")
print(f"{Fore.CYAN}Get Account Info | 正在访问设置页面获取账户信息...{Style.RESET_ALL}")
self.browser.get(settings_url)
time.sleep(2)
@ -298,9 +298,9 @@ class BrowserControl:
if usage_ele:
usage_info = usage_ele.text
total_usage = usage_info.split("/")[-1].strip()
print(f"{Fore.GREEN}账户可用额度上限: {total_usage}{Style.RESET_ALL}")
print(f"{Fore.GREEN}Account Usage Limit | 账户可用额度上限: {total_usage}{Style.RESET_ALL}")
except Exception as e:
print(f"{Fore.RED}获取账户额度信息失败: {str(e)}{Style.RESET_ALL}")
print(f"{Fore.RED}Get Account Usage Failed | 获取账户额度信息失败: {str(e)}{Style.RESET_ALL}")
# 切换回邮箱页面
self.switch_to_tab(email_tab)
@ -308,7 +308,7 @@ class BrowserControl:
return True
except Exception as e:
print(f"{Fore.RED}填写验证码时发生错误: {str(e)}{Style.RESET_ALL}")
print(f"{Fore.RED}Fill Verification Code Failed | 填写验证码时发生错误: {str(e)}{Style.RESET_ALL}")
return False
def check_and_click_turnstile(self):
@ -320,19 +320,19 @@ class BrowserControl:
# 查找验证框
verify_checkbox = self.browser.ele('xpath://label[contains(@class, "cb-lb")]//input[@type="checkbox"]')
if verify_checkbox:
print(f"{Fore.CYAN}找到 Turnstile 验证框,尝试点击...{Style.RESET_ALL}")
print(f"{Fore.CYAN}Find Turnstile Verification Box | 找到 Turnstile 验证框,尝试点击...{Style.RESET_ALL}")
verify_checkbox.click()
time.sleep(2) # 等待验证完成
print(f"{Fore.GREEN}已点击 Turnstile 验证框{Style.RESET_ALL}")
print(f"{Fore.GREEN}Clicked Turnstile Verification Box | 已点击 Turnstile 验证框{Style.RESET_ALL}")
return True
return False
except Exception as e:
print(f"{Fore.YELLOW}未找到 Turnstile 验证框或点击失败: {str(e)}{Style.RESET_ALL}")
print(f"{Fore.YELLOW}Check and Click Turnstile Failed | 未找到 Turnstile 验证框或点击失败: {str(e)}{Style.RESET_ALL}")
return False
def get_cursor_session_token(self, max_attempts=3, retry_interval=2):
"""获取Cursor会话token"""
print(f"{Fore.CYAN}开始获取cookie...{Style.RESET_ALL}")
print(f"{Fore.CYAN}Get Cursor Session Token | 开始获取cookie...{Style.RESET_ALL}")
attempts = 0
while attempts < max_attempts:
@ -349,16 +349,16 @@ class BrowserControl:
attempts += 1
if attempts < max_attempts:
print(f"{Fore.YELLOW}{attempts} 次尝试未获取到CursorSessionToken{retry_interval}秒后重试...{Style.RESET_ALL}")
print(f"{Fore.YELLOW} Try | {attempts} 次尝试未获取到CursorSessionToken{retry_interval}秒后重试...{Style.RESET_ALL}")
time.sleep(retry_interval)
else:
print(f"{Fore.RED}已达到最大尝试次数({max_attempts})获取CursorSessionToken失败{Style.RESET_ALL}")
print(f"{Fore.RED}Reach Max Attempts ({max_attempts}) | 已达到最大尝试次数({max_attempts})获取CursorSessionToken失败{Style.RESET_ALL}")
except Exception as e:
print(f"{Fore.RED}获取cookie失败: {str(e)}{Style.RESET_ALL}")
attempts += 1
if attempts < max_attempts:
print(f"{Fore.YELLOW}将在 {retry_interval} 秒后重试...{Style.RESET_ALL}")
print(f"{Fore.YELLOW}Will Retry in {retry_interval} seconds | 将在 {retry_interval} 秒后重试...{Style.RESET_ALL}")
time.sleep(retry_interval)
return None
@ -369,6 +369,6 @@ class BrowserControl:
with open('cursor_tokens.txt', 'a', encoding='utf-8') as f:
f.write(f"Token: {token}\n")
f.write("-" * 50 + "\n")
print(f"{Fore.GREEN}Token已保存到 cursor_tokens.txt{Style.RESET_ALL}")
print(f"{Fore.GREEN}Token Saved to cursor_tokens.txt | Token已保存到 cursor_tokens.txt{Style.RESET_ALL}")
except Exception as e:
print(f"{Fore.RED}保存Token时发生错误: {str(e)}{Style.RESET_ALL}")
print(f"{Fore.RED}Save Token Failed | 保存Token时发生错误: {str(e)}{Style.RESET_ALL}")

View File

@ -54,7 +54,7 @@ class CursorAuth:
# 重新连接数据库
conn = sqlite3.connect(self.db_path)
print(f"{EMOJI['INFO']} {Fore.GREEN}Successfully connected to database{Style.RESET_ALL}")
print(f"{EMOJI['INFO']} {Fore.GREEN}Successfully connected to database | 成功连接到数据库{Style.RESET_ALL}")
cursor = conn.cursor()
# 增加超时和其他优化设置
@ -91,7 +91,7 @@ class CursorAuth:
print(f"{EMOJI['INFO']} {Fore.CYAN}Updating {key.split('/')[-1]}...{Style.RESET_ALL}")
cursor.execute("COMMIT")
print(f"{EMOJI['SUCCESS']} {Fore.GREEN}Database updated successfully{Style.RESET_ALL}")
print(f"{EMOJI['SUCCESS']} {Fore.GREEN}Database updated successfully | 数据库更新成功{Style.RESET_ALL}")
return True
except Exception as e:
@ -99,14 +99,14 @@ class CursorAuth:
raise e
except sqlite3.Error as e:
print(f"\n{EMOJI['ERROR']} {Fore.RED}Database error: {str(e)}{Style.RESET_ALL}")
print(f"\n{EMOJI['ERROR']} {Fore.RED}Database error | 数据库错误: {str(e)}{Style.RESET_ALL}")
return False
except Exception as e:
print(f"\n{EMOJI['ERROR']} {Fore.RED}An error occurred: {str(e)}{Style.RESET_ALL}")
print(f"\n{EMOJI['ERROR']} {Fore.RED}An error occurred | 发生错误: {str(e)}{Style.RESET_ALL}")
return False
finally:
if conn:
conn.close()
print(f"{EMOJI['DB']} {Fore.CYAN}Database connection closed{Style.RESET_ALL}")
print(f"{EMOJI['DB']} {Fore.CYAN}Database connection closed | 数据库连接已关闭{Style.RESET_ALL}")

View File

@ -49,20 +49,20 @@ class CursorRegistration:
self.last_name = self._generate_name()
def _generate_password(self, length=12):
"""生成随机密码"""
"""Generate Random Password"""
chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*"
return ''.join(random.choices(chars, k=length))
def _generate_name(self, length=6):
"""生成随机名字"""
"""Generate Random Name"""
first_letter = random.choice("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
rest_letters = ''.join(random.choices("abcdefghijklmnopqrstuvwxyz", k=length-1))
return first_letter + rest_letters
def setup_email(self):
"""设置临时邮箱"""
"""Setup Temporary Email"""
try:
print(f"{Fore.CYAN}正在启动浏览器...{Style.RESET_ALL}")
print(f"{Fore.CYAN}Staring Browser | 正在启动浏览器...{Style.RESET_ALL}")
self.browser = self.browser_manager.init_browser()
self.controller = BrowserControl(self.browser)
@ -80,7 +80,7 @@ class CursorRegistration:
# 获取邮箱地址
self.email_address = self.controller.copy_and_get_email()
if self.email_address:
print(f"{Fore.CYAN}获取到的邮箱地址: {self.email_address}{Style.RESET_ALL}")
print(f"{Fore.CYAN}Get Email Address | 获取到的邮箱地址: {self.email_address}{Style.RESET_ALL}")
# 进入邮箱
if self.controller.view_mailbox():
@ -89,14 +89,14 @@ class CursorRegistration:
return False
except Exception as e:
print(f"{Fore.RED}发生错误: {str(e)}{Style.RESET_ALL}")
print(f"{Fore.RED}Error Occured | 发生错误: {str(e)}{Style.RESET_ALL}")
return False
def register_cursor(self):
"""注册 Cursor 账号"""
signup_browser_manager = None
try:
print(f"\n{Fore.CYAN}{EMOJI['START']} 开始 Cursor 注册流程{Style.RESET_ALL}")
print(f"\n{Fore.CYAN}{EMOJI['START']}Start Register | 开始 Cursor 注册流程{Style.RESET_ALL}")
# 创建新的浏览器实例用于注册
from browser import BrowserManager
@ -109,7 +109,7 @@ class CursorRegistration:
# 填写注册表单
if self.signup_tab.ele("@name=first_name"):
print(f"{Fore.YELLOW}{EMOJI['FORM']} 填写注册信息...{Style.RESET_ALL}")
print(f"{Fore.YELLOW}{EMOJI['FORM']}Fill Form | 填写注册信息...{Style.RESET_ALL}")
self.signup_tab.ele("@name=first_name").input(self.first_name)
time.sleep(random.uniform(1, 2))
@ -121,14 +121,14 @@ class CursorRegistration:
time.sleep(random.uniform(1, 2))
self.signup_tab.ele("@type=submit").click()
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} 基本信息提交完成{Style.RESET_ALL}")
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} Basic Info Submitted | 基本信息提交完成{Style.RESET_ALL}")
# 处理 Turnstile 验证
self._handle_turnstile()
# 设置密码
if self.signup_tab.ele("@name=password"):
print(f"{Fore.YELLOW}{EMOJI['PASSWORD']} 设置密码...{Style.RESET_ALL}")
print(f"{Fore.YELLOW}{EMOJI['PASSWORD']} Set Password | 设置密码...{Style.RESET_ALL}")
self.signup_tab.ele("@name=password").input(self.password)
time.sleep(random.uniform(1, 2))
self.signup_tab.ele("@type=submit").click()
@ -147,21 +147,21 @@ class CursorRegistration:
start_time = time.time()
timeout = 60 # 60秒超时
print(f"{Fore.CYAN}{EMOJI['WAIT']} 开始获取验证码将在60秒内尝试...{Style.RESET_ALL}")
print(f"{Fore.CYAN}{EMOJI['WAIT']} Start Getting Verification Code | 开始获取验证码将在60秒内尝试...{Style.RESET_ALL}")
for attempt in range(max_attempts):
# 检查是否超时
if time.time() - start_time > timeout:
print(f"{Fore.RED}{EMOJI['ERROR']} 获取验证码超时{Style.RESET_ALL}")
print(f"{Fore.RED}{EMOJI['ERROR']} Get Verification Code Timeout | 获取验证码超时{Style.RESET_ALL}")
break
verification_code = self.controller.get_verification_code()
if verification_code:
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} 成功获取验证码: {verification_code}{Style.RESET_ALL}")
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} Get Verification Code Success | 成功获取验证码: {verification_code}{Style.RESET_ALL}")
break
remaining_time = int(timeout - (time.time() - start_time))
print(f"{Fore.YELLOW}{EMOJI['WAIT']} {attempt + 1} 次尝试未获取到验证码,剩余时间: {remaining_time}{Style.RESET_ALL}")
print(f"{Fore.YELLOW}{EMOJI['WAIT']} Try | {attempt + 1} Get Verification Code | 次尝试未获取到验证码,Time Remaining | 剩余时间: {remaining_time}{Style.RESET_ALL}")
# 刷新邮箱
self.browser.refresh()
@ -173,7 +173,7 @@ class CursorRegistration:
self.signup_tab.ele(f"@data-index={i}").input(digit)
time.sleep(random.uniform(0.1, 0.3))
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} 验证码填写完成{Style.RESET_ALL}")
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} Verification Code Filled | 验证码填写完成{Style.RESET_ALL}")
time.sleep(3)
self._handle_turnstile()
@ -181,7 +181,7 @@ class CursorRegistration:
# 检查当前URL
current_url = self.signup_tab.url
if "authenticator.cursor.sh" in current_url:
print(f"{Fore.CYAN}{EMOJI['VERIFY']} 检测到登录页面,开始登录...{Style.RESET_ALL}")
print(f"{Fore.CYAN}{EMOJI['VERIFY']} Detect Login Page | 检测到登录页面,开始登录...{Style.RESET_ALL}")
# 填写邮箱
email_input = self.signup_tab.ele('@name=email')
@ -218,7 +218,7 @@ class CursorRegistration:
start_time = time.time()
while time.time() - start_time < max_wait:
if "cursor.com/settings" in self.signup_tab.url:
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} 成功登录并跳转到设置页面{Style.RESET_ALL}")
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} Login Success and Jump to Settings Page | 成功登录并跳转到设置页面{Style.RESET_ALL}")
break
time.sleep(1)
@ -231,11 +231,11 @@ class CursorRegistration:
return result
else:
print(f"{Fore.RED}{EMOJI['ERROR']} 未能在60秒内获取到验证码{Style.RESET_ALL}")
print(f"{Fore.RED}{EMOJI['ERROR']} Get Verification Code Timeout | 未能在60秒内获取到验证码{Style.RESET_ALL}")
return False
except Exception as e:
print(f"{Fore.RED}{EMOJI['ERROR']} 注册过程出错: {str(e)}{Style.RESET_ALL}")
print(f"{Fore.RED}{EMOJI['ERROR']} Register Process Error | 注册过程出错: {str(e)}{Style.RESET_ALL}")
return False
finally:
# 确保在任何情况下都关闭注册窗口
@ -244,7 +244,7 @@ class CursorRegistration:
def _handle_turnstile(self):
"""处理 Turnstile 验证"""
print(f"{Fore.YELLOW}{EMOJI['VERIFY']} 处理 Turnstile 验证...{Style.RESET_ALL}")
print(f"{Fore.YELLOW}{EMOJI['VERIFY']} Handle Turnstile | 处理 Turnstile 验证...{Style.RESET_ALL}")
# 设置最大等待时间(秒)
max_wait_time = 5
@ -254,7 +254,7 @@ class CursorRegistration:
try:
# 检查是否超时
if time.time() - start_time > max_wait_time:
print(f"{Fore.YELLOW}{EMOJI['WAIT']} 未检测到 Turnstile 验证,继续下一步...{Style.RESET_ALL}")
print(f"{Fore.YELLOW}{EMOJI['WAIT']} Not Detect Turnstile | 未检测到 Turnstile 验证,继续下一步...{Style.RESET_ALL}")
break
# 检查是否存在验证框
@ -269,12 +269,12 @@ class CursorRegistration:
if challengeCheck:
challengeCheck.click()
time.sleep(2)
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} Turnstile 验证通过{Style.RESET_ALL}")
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} Turnstile Passed | 验证通过{Style.RESET_ALL}")
break
# 检查是否已经通过验证(检查下一步的元素是否存在)
if self.signup_tab.ele("@name=password"):
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} 验证已通过{Style.RESET_ALL}")
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} Verification Passed | 验证已通过{Style.RESET_ALL}")
break
except:
@ -301,7 +301,7 @@ class CursorRegistration:
total_usage = usage_ele.text.split("/")[-1].strip()
# 获取 Token
print(f"{Fore.CYAN}{EMOJI['WAIT']} 开始获取 Cursor Session Token...{Style.RESET_ALL}")
print(f"{Fore.CYAN}{EMOJI['WAIT']} Get Cursor Session Token | 开始获取 Cursor Session Token...{Style.RESET_ALL}")
max_attempts = 30
retry_interval = 2
attempts = 0
@ -312,7 +312,7 @@ class CursorRegistration:
for cookie in cookies:
if cookie.get("name") == "WorkosCursorSessionToken":
token = cookie["value"].split("%3A%3A")[1]
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} Token 获取成功{Style.RESET_ALL}")
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} Get Token Success | Token 获取成功{Style.RESET_ALL}")
# 保存账户信息
self._save_account_info(token, total_usage)
return True
@ -320,23 +320,23 @@ class CursorRegistration:
attempts += 1
if attempts < max_attempts:
print(
f"{Fore.YELLOW}{EMOJI['WAIT']} {attempts} 次尝试未获取到 Token{retry_interval}秒后重试...{Style.RESET_ALL}"
f"{Fore.YELLOW}{EMOJI['WAIT']} Try | {attempts} times to get Token | 次尝试未获取到 Token{retry_interval}秒后重试...{Style.RESET_ALL}"
)
time.sleep(retry_interval)
else:
print(f"{Fore.RED}{EMOJI['ERROR']} 已达到最大尝试次数({max_attempts}),获取 Token 失败{Style.RESET_ALL}")
print(f"{Fore.RED}{EMOJI['ERROR']} Reach Max Attempts ({max_attempts}) | 已达到最大尝试次数({max_attempts}),获取 Token 失败{Style.RESET_ALL}")
except Exception as e:
print(f"{Fore.RED}{EMOJI['ERROR']} 获取 Token 失败: {str(e)}{Style.RESET_ALL}")
print(f"{Fore.RED}{EMOJI['ERROR']} Get Token Failed | 获取 Token 失败: {str(e)}{Style.RESET_ALL}")
attempts += 1
if attempts < max_attempts:
print(f"{Fore.YELLOW}{EMOJI['WAIT']} 将在 {retry_interval} 秒后重试...{Style.RESET_ALL}")
print(f"{Fore.YELLOW}{EMOJI['WAIT']} Will Retry in {retry_interval} seconds | 将在 {retry_interval} 秒后重试...{Style.RESET_ALL}")
time.sleep(retry_interval)
return False
except Exception as e:
print(f"{Fore.RED}{EMOJI['ERROR']} 获取账户信息失败: {str(e)}{Style.RESET_ALL}")
print(f"{Fore.RED}{EMOJI['ERROR']} Get Account Info Failed | 获取账户信息失败: {str(e)}{Style.RESET_ALL}")
return False
def _save_account_info(self, token, total_usage):
@ -345,12 +345,12 @@ class CursorRegistration:
# 先更新认证信息
print(f"{Fore.CYAN}{EMOJI['KEY']} 正在更新 Cursor 认证信息...{Style.RESET_ALL}")
if update_cursor_auth(email=self.email_address, access_token=token, refresh_token=token):
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} Cursor 认证信息更新成功{Style.RESET_ALL}")
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} Cursor Auth Info Updated | 认证信息更新成功{Style.RESET_ALL}")
else:
print(f"{Fore.RED}{EMOJI['ERROR']} Cursor 认证信息更新失败{Style.RESET_ALL}")
print(f"{Fore.RED}{EMOJI['ERROR']} Cursor Auth Info Update Failed | 认证信息更新失败{Style.RESET_ALL}")
# 重置机器ID
print(f"{Fore.CYAN}{EMOJI['UPDATE']} 正在重置机器ID...{Style.RESET_ALL}")
print(f"{Fore.CYAN}{EMOJI['UPDATE']} Reset Machine ID | 正在重置机器ID...{Style.RESET_ALL}")
MachineIDResetter().reset_machine_ids()
# 保存账户信息到文件
@ -362,11 +362,11 @@ class CursorRegistration:
f.write(f"Usage Limit: {total_usage}\n")
f.write(f"{'='*50}\n")
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} 账户信息已保存到 cursor_accounts.txt{Style.RESET_ALL}")
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} Account Info Saved to cursor_accounts.txt | 账户信息已保存到 cursor_accounts.txt{Style.RESET_ALL}")
return True
except Exception as e:
print(f"{Fore.RED}{EMOJI['ERROR']} 保存账户信息失败: {str(e)}{Style.RESET_ALL}")
print(f"{Fore.RED}{EMOJI['ERROR']} Save Account Info Failed | 保存账户信息失败: {str(e)}{Style.RESET_ALL}")
return False
def start(self):
@ -374,7 +374,7 @@ class CursorRegistration:
try:
if self.setup_email():
if self.register_cursor():
print(f"\n{Fore.GREEN}{EMOJI['DONE']} Cursor 注册完成!{Style.RESET_ALL}")
print(f"\n{Fore.GREEN}{EMOJI['DONE']} Cursor Registration Completed | 注册完成!{Style.RESET_ALL}")
return True
return False
finally: