Skip to content

Commit

Permalink
feat: 增加自动登录的逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
cheng zhen committed Jan 4, 2025
1 parent c8ea777 commit 90922ad
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
16 changes: 14 additions & 2 deletions cursor_auth_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,26 @@ def update_auth(self, email=None, access_token=None, refresh_token=None):
print("没有提供任何要更新的值")
return False

updates.append(("cursorAuth/cachedSignUpType", "Auth_0"))
conn = None
try:
conn = sqlite3.connect(self.db_path)
cursor = conn.cursor()

for key, value in updates:
query = "UPDATE itemTable SET value = ? WHERE key = ?"
cursor.execute(query, (value, key))

# 如果没有更新任何行,说明key不存在,执行插入
# 检查 accessToken 是否存在
check_query = f"SELECT COUNT(*) FROM itemTable WHERE key = ?"
cursor.execute(check_query, (key,))
if cursor.fetchone()[0] == 0:
insert_query = "INSERT INTO itemTable (key, value) VALUES (?, ?)"
cursor.execute(insert_query, (key, value))
else:
if key == "cursorAuth/cachedSignUpType":
continue
update_query = "UPDATE itemTable SET value = ? WHERE key = ?"
cursor.execute(update_query, (value, key))

if cursor.rowcount > 0:
print(f"成功更新 {key.split('/')[-1]}")
Expand Down
2 changes: 1 addition & 1 deletion cursor_pro_keep_alive.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def sign_up_account(browser, tab):
print(e)

handle_turnstile(tab)
wait_time = random.randint(3, 6)
wait_time = random.randint(5, 8)
for i in range(wait_time):
print(f"等待中... {wait_time-i}秒")
time.sleep(1)
Expand Down

0 comments on commit 90922ad

Please sign in to comment.