mirror of
https://github.com/yeongpin/cursor-free-vip.git
synced 2025-08-02 20:47:35 +08:00
Revert "feat: Add GitHub-based trial reset"
This commit is contained in:
parent
0226c9e735
commit
5574091273
@ -1,170 +0,0 @@
|
|||||||
import os
|
|
||||||
import time
|
|
||||||
from colorama import init, Fore
|
|
||||||
from DrissionPage import ChromiumPage
|
|
||||||
from cursor_auth import CursorAuth
|
|
||||||
from utils import MachineIDResetter
|
|
||||||
import keyring
|
|
||||||
|
|
||||||
# Initialize colorama
|
|
||||||
init()
|
|
||||||
|
|
||||||
# Emoji constants
|
|
||||||
CHECK_MARK = "✓"
|
|
||||||
CROSS_MARK = "❌"
|
|
||||||
|
|
||||||
def get_saved_credentials():
|
|
||||||
"""Retrieve saved GitHub credentials from keyring."""
|
|
||||||
try:
|
|
||||||
email = keyring.get_password("cursor-github", "email")
|
|
||||||
password = keyring.get_password("cursor-github", "password")
|
|
||||||
return email, password
|
|
||||||
except Exception:
|
|
||||||
return None, None
|
|
||||||
|
|
||||||
def save_credentials(email, password):
|
|
||||||
"""Save GitHub credentials to keyring."""
|
|
||||||
try:
|
|
||||||
keyring.set_password("cursor-github", "email", email)
|
|
||||||
keyring.set_password("cursor-github", "password", password)
|
|
||||||
return True
|
|
||||||
except Exception:
|
|
||||||
return False
|
|
||||||
|
|
||||||
def extract_auth_data(page, github_email=None):
|
|
||||||
"""Extract authentication data from the page."""
|
|
||||||
print(f"\n{Fore.CYAN}Checking cookies...{Fore.RESET}")
|
|
||||||
cookies = page.get_cookies()
|
|
||||||
print(f"Found {len(cookies)} cookies")
|
|
||||||
|
|
||||||
for cookie in cookies:
|
|
||||||
print(f"Cookie: {cookie['name']} = {cookie['value'][:10]}...")
|
|
||||||
|
|
||||||
auth_token = None
|
|
||||||
cursor_email = None
|
|
||||||
|
|
||||||
# Try to get token from cookies with different separators
|
|
||||||
for cookie in cookies:
|
|
||||||
if cookie['name'] == 'WorkosCursorSessionToken':
|
|
||||||
value = cookie['value']
|
|
||||||
if '::' in value:
|
|
||||||
auth_token = value.split('::')[1]
|
|
||||||
elif '%3A%3A' in value:
|
|
||||||
auth_token = value.split('%3A%3A')[1]
|
|
||||||
if auth_token:
|
|
||||||
print(f"{CHECK_MARK} Found auth token: {auth_token[:10]}...")
|
|
||||||
break
|
|
||||||
|
|
||||||
# Try to get token from localStorage if not found in cookies
|
|
||||||
if not auth_token:
|
|
||||||
try:
|
|
||||||
local_storage = page.get_local_storage()
|
|
||||||
if 'WorkosCursorSessionToken' in local_storage:
|
|
||||||
value = local_storage['WorkosCursorSessionToken']
|
|
||||||
if '::' in value:
|
|
||||||
auth_token = value.split('::')[1]
|
|
||||||
elif '%3A%3A' in value:
|
|
||||||
auth_token = value.split('%3A%3A')[1]
|
|
||||||
if auth_token:
|
|
||||||
print(f"{CHECK_MARK} Found auth token in localStorage: {auth_token[:10]}...")
|
|
||||||
except Exception as e:
|
|
||||||
print(f"{CROSS_MARK} Error accessing localStorage: {str(e)}")
|
|
||||||
|
|
||||||
# Get cursor_email from cookies or use github_email as fallback
|
|
||||||
for cookie in cookies:
|
|
||||||
if cookie['name'] == 'cursor_email':
|
|
||||||
cursor_email = cookie['value']
|
|
||||||
print(f"{CHECK_MARK} Found cursor_email: {cursor_email}")
|
|
||||||
break
|
|
||||||
|
|
||||||
if not cursor_email and github_email:
|
|
||||||
cursor_email = github_email
|
|
||||||
print(f"{CHECK_MARK} Using GitHub email as fallback: {cursor_email}")
|
|
||||||
|
|
||||||
if not auth_token or not cursor_email:
|
|
||||||
missing = []
|
|
||||||
if not auth_token:
|
|
||||||
missing.append("auth_token")
|
|
||||||
if not cursor_email:
|
|
||||||
missing.append("cursor_email")
|
|
||||||
print(f"{CROSS_MARK} Could not extract: {', '.join(missing)}")
|
|
||||||
return None, None
|
|
||||||
|
|
||||||
return auth_token, cursor_email
|
|
||||||
|
|
||||||
def reset_trial(translator=None):
|
|
||||||
"""Reset trial using GitHub authentication."""
|
|
||||||
print(f"\n{Fore.CYAN}Starting GitHub trial reset...{Fore.RESET}")
|
|
||||||
|
|
||||||
# Initialize browser
|
|
||||||
page = ChromiumPage()
|
|
||||||
|
|
||||||
try:
|
|
||||||
# Get saved credentials
|
|
||||||
email, password = get_saved_credentials()
|
|
||||||
|
|
||||||
if not email or not password:
|
|
||||||
print(f"{Fore.YELLOW}Please enter your GitHub credentials:{Fore.RESET}")
|
|
||||||
email = input("Email: ")
|
|
||||||
password = input("Password: ")
|
|
||||||
|
|
||||||
# Save credentials if user wants
|
|
||||||
save = input("Save credentials for next time? (y/n): ").lower() == 'y'
|
|
||||||
if save:
|
|
||||||
if save_credentials(email, password):
|
|
||||||
print(f"{CHECK_MARK} Credentials saved successfully")
|
|
||||||
else:
|
|
||||||
print(f"{CROSS_MARK} Failed to save credentials")
|
|
||||||
|
|
||||||
# Navigate to GitHub login
|
|
||||||
print(f"\n{Fore.CYAN}Navigating to GitHub login...{Fore.RESET}")
|
|
||||||
page.get('https://github.com/login')
|
|
||||||
|
|
||||||
# Fill in login form
|
|
||||||
page.ele('input[name="login"]').input(email)
|
|
||||||
page.ele('input[name="password"]').input(password)
|
|
||||||
page.ele('input[name="commit"]').click()
|
|
||||||
|
|
||||||
# Wait for login to complete
|
|
||||||
time.sleep(2)
|
|
||||||
|
|
||||||
# Check if login was successful
|
|
||||||
if 'login' in page.url:
|
|
||||||
print(f"{CROSS_MARK} Login failed. Please check your credentials.")
|
|
||||||
return False
|
|
||||||
|
|
||||||
print(f"{CHECK_MARK} Successfully logged in to GitHub")
|
|
||||||
|
|
||||||
# Extract authentication data
|
|
||||||
auth_token, cursor_email = extract_auth_data(page, email)
|
|
||||||
if not auth_token or not cursor_email:
|
|
||||||
print(f"{CROSS_MARK} Could not extract authentication data")
|
|
||||||
return False
|
|
||||||
|
|
||||||
# Initialize CursorAuth and save authentication data
|
|
||||||
cursor_auth = CursorAuth()
|
|
||||||
cursor_auth.set_access_token(auth_token)
|
|
||||||
cursor_auth.set_refresh_token(auth_token) # Using same token for both
|
|
||||||
cursor_auth.set_email(cursor_email)
|
|
||||||
|
|
||||||
if not cursor_auth.verify_and_save():
|
|
||||||
print(f"{CROSS_MARK} Failed to save authentication data")
|
|
||||||
return False
|
|
||||||
|
|
||||||
print(f"{CHECK_MARK} Successfully saved authentication data")
|
|
||||||
|
|
||||||
# Reset machine ID
|
|
||||||
print(f"\n{Fore.CYAN}Resetting machine ID...{Fore.RESET}")
|
|
||||||
resetter = MachineIDResetter()
|
|
||||||
resetter.reset()
|
|
||||||
print(f"{CHECK_MARK} Machine ID reset complete")
|
|
||||||
|
|
||||||
print(f"\n{Fore.GREEN}Trial reset complete! You can now launch Cursor.{Fore.RESET}")
|
|
||||||
return True
|
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
print(f"{CROSS_MARK} An error occurred: {str(e)}")
|
|
||||||
return False
|
|
||||||
|
|
||||||
finally:
|
|
||||||
page.quit()
|
|
29
main.py
29
main.py
@ -10,12 +10,6 @@ import platform
|
|||||||
import requests
|
import requests
|
||||||
import subprocess
|
import subprocess
|
||||||
from config import get_config
|
from config import get_config
|
||||||
import time
|
|
||||||
from cursor_register import CursorRegistration
|
|
||||||
from cursor_register_github import main as register_github
|
|
||||||
from cursor_register_google import main as register_google
|
|
||||||
from github_trial_reset import reset_trial as github_reset_trial
|
|
||||||
from utils import MachineIDResetter
|
|
||||||
|
|
||||||
# Only import windll on Windows systems
|
# Only import windll on Windows systems
|
||||||
if platform.system() == 'Windows':
|
if platform.system() == 'Windows':
|
||||||
@ -375,23 +369,24 @@ def main():
|
|||||||
print(f"{Fore.CYAN}{'═' * 50}{Style.RESET_ALL}")
|
print(f"{Fore.CYAN}{'═' * 50}{Style.RESET_ALL}")
|
||||||
return
|
return
|
||||||
elif choice == "1":
|
elif choice == "1":
|
||||||
resetter = MachineIDResetter()
|
import reset_machine_manual
|
||||||
resetter.reset()
|
reset_machine_manual.run(translator)
|
||||||
print(f"{Fore.GREEN}Machine ID reset complete!{Fore.RESET}")
|
print_menu()
|
||||||
elif choice == "2":
|
elif choice == "2":
|
||||||
if github_reset_trial():
|
import cursor_register
|
||||||
print(f"{Fore.GREEN}GitHub trial reset completed successfully!{Fore.RESET}")
|
cursor_register.main(translator)
|
||||||
else:
|
print_menu()
|
||||||
print(f"{Fore.RED}GitHub trial reset failed.{Fore.RESET}")
|
|
||||||
elif choice == "3":
|
elif choice == "3":
|
||||||
registration = CursorRegistration()
|
import cursor_register_google
|
||||||
registration.register()
|
cursor_register_google.main(translator)
|
||||||
print_menu()
|
print_menu()
|
||||||
elif choice == "4":
|
elif choice == "4":
|
||||||
register_github()
|
import cursor_register_github
|
||||||
|
cursor_register_github.main(translator)
|
||||||
print_menu()
|
print_menu()
|
||||||
elif choice == "5":
|
elif choice == "5":
|
||||||
register_google()
|
import cursor_register_manual
|
||||||
|
cursor_register_manual.main(translator)
|
||||||
print_menu()
|
print_menu()
|
||||||
elif choice == "6":
|
elif choice == "6":
|
||||||
import quit_cursor
|
import quit_cursor
|
||||||
|
@ -610,8 +610,8 @@ class OAuthHandler:
|
|||||||
print(f"{Fore.CYAN}{EMOJI['INFO']} Redirecting to authenticator.cursor.sh...{Style.RESET_ALL}")
|
print(f"{Fore.CYAN}{EMOJI['INFO']} Redirecting to authenticator.cursor.sh...{Style.RESET_ALL}")
|
||||||
|
|
||||||
# Explicitly navigate to the authentication page
|
# Explicitly navigate to the authentication page
|
||||||
self.browser.get("https://authenticator.cursor.sh/sign-up")
|
#self.browser.get("https://authenticator.cursor.sh/sign-up")
|
||||||
time.sleep(get_random_wait_time(self.config, 'page_load_wait'))
|
# time.sleep(get_random_wait_time(self.config, 'page_load_wait'))
|
||||||
|
|
||||||
# Call handle_google_auth again to repeat the entire process
|
# Call handle_google_auth again to repeat the entire process
|
||||||
print(f"{Fore.CYAN}{EMOJI['INFO']} Starting new Google authentication...{Style.RESET_ALL}")
|
print(f"{Fore.CYAN}{EMOJI['INFO']} Starting new Google authentication...{Style.RESET_ALL}")
|
||||||
|
@ -14,7 +14,6 @@ import configparser
|
|||||||
from new_signup import get_user_documents_path
|
from new_signup import get_user_documents_path
|
||||||
import traceback
|
import traceback
|
||||||
from config import get_config
|
from config import get_config
|
||||||
from github_trial_reset import reset_trial as github_reset_trial
|
|
||||||
|
|
||||||
# Initialize colorama
|
# Initialize colorama
|
||||||
init()
|
init()
|
||||||
@ -692,30 +691,19 @@ class MachineIDResetter:
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def run(translator=None):
|
def run(translator=None):
|
||||||
"""Main function to run the reset process"""
|
config = get_config(translator)
|
||||||
try:
|
if not config:
|
||||||
print(f"\n{Fore.CYAN}{EMOJI['RESET']} {translator.get('reset.starting_reset') if translator else 'Starting reset process...'}{Style.RESET_ALL}")
|
|
||||||
|
|
||||||
# First, try GitHub trial reset
|
|
||||||
print(f"\n{Fore.CYAN}{EMOJI['INFO']} Attempting GitHub trial reset...{Style.RESET_ALL}")
|
|
||||||
if github_reset_trial(translator):
|
|
||||||
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} GitHub trial reset completed successfully!{Style.RESET_ALL}")
|
|
||||||
else:
|
|
||||||
print(f"{Fore.YELLOW}{EMOJI['INFO']} GitHub trial reset failed, falling back to manual reset...{Style.RESET_ALL}")
|
|
||||||
|
|
||||||
# Then proceed with manual reset
|
|
||||||
resetter = MachineIDResetter(translator)
|
|
||||||
if resetter.reset():
|
|
||||||
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} {translator.get('reset.completed_successfully') if translator else 'Reset completed successfully!'}{Style.RESET_ALL}")
|
|
||||||
else:
|
|
||||||
print(f"{Fore.RED}{EMOJI['ERROR']} {translator.get('reset.failed') if translator else 'Reset failed!'}{Style.RESET_ALL}")
|
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
print(f"{Fore.RED}{EMOJI['ERROR']} {translator.get('reset.error_occurred', error=str(e)) if translator else f'An error occurred: {str(e)}'}{Style.RESET_ALL}")
|
|
||||||
print(f"{Fore.YELLOW}{EMOJI['INFO']} {translator.get('reset.stack_trace')}: {traceback.format_exc()}{Style.RESET_ALL}")
|
|
||||||
return False
|
return False
|
||||||
|
print(f"\n{Fore.CYAN}{'='*50}{Style.RESET_ALL}")
|
||||||
|
print(f"{Fore.CYAN}{EMOJI['RESET']} {translator.get('reset.title')}{Style.RESET_ALL}")
|
||||||
|
print(f"{Fore.CYAN}{'='*50}{Style.RESET_ALL}")
|
||||||
|
|
||||||
return True
|
resetter = MachineIDResetter(translator) # Correctly pass translator
|
||||||
|
resetter.reset_machine_ids()
|
||||||
|
|
||||||
|
print(f"\n{Fore.CYAN}{'='*50}{Style.RESET_ALL}")
|
||||||
|
input(f"{EMOJI['INFO']} {translator.get('reset.press_enter')}...")
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
run()
|
from main import translator as main_translator
|
||||||
|
run(main_translator)
|
Loading…
x
Reference in New Issue
Block a user