diff --git a/CursorKeepAlive.mac.spec b/CursorKeepAlive.mac.spec index 5dbdff4..c15dc91 100644 --- a/CursorKeepAlive.mac.spec +++ b/CursorKeepAlive.mac.spec @@ -5,7 +5,6 @@ a = Analysis( pathex=[], binaries=[], datas=[ - ('config.ini', '.'), ('turnstilePatch', 'turnstilePatch'), ('cursor_auth_manager.py', '.'), ], diff --git a/cursor_pro_keep_alive.py b/cursor_pro_keep_alive.py index 212e355..931a983 100644 --- a/cursor_pro_keep_alive.py +++ b/cursor_pro_keep_alive.py @@ -1,6 +1,7 @@ import os -os.environ['PYTHONVERBOSE'] = '0' -os.environ['PYINSTALLER_VERBOSE'] = '0' + +os.environ["PYTHONVERBOSE"] = "0" +os.environ["PYINSTALLER_VERBOSE"] = "0" from DrissionPage import ChromiumOptions, Chromium from DrissionPage.common import Keys @@ -16,11 +17,11 @@ import logging # 在文件开头设置日志 logging.basicConfig( level=logging.WARNING, - format='%(asctime)s - %(levelname)s - %(message)s', + format="%(asctime)s - %(levelname)s - %(message)s", handlers=[ logging.StreamHandler(), - logging.FileHandler('cursor_keep_alive.log', encoding='utf-8') - ] + logging.FileHandler("cursor_keep_alive.log", encoding="utf-8"), + ], ) @@ -28,19 +29,20 @@ def load_config(): """加载配置文件""" config = ConfigParser() - # 修改获取配置文件路径的方式 - if getattr(sys, 'frozen', False): - # 如果是打包后的执行文件 - root_dir = sys._MEIPASS + # 获取程序运行的实际目录 + if getattr(sys, "frozen", False): + # 打包后的情况:使用可执行文件所在目录 + root_dir = os.path.dirname(sys.executable) else: - # 如果是直接运行 Python 脚本 + # 开发环境:使用当前工作目录 root_dir = os.getcwd() - + config_path = os.path.join(root_dir, "config.ini") if os.path.exists(config_path): config.read(config_path, encoding="utf-8") print(f"已加载配置文件: {config_path}") + print(config["Account"]["email"]) return { "account": config["Account"]["email"], "password": config["Account"]["password"], @@ -401,18 +403,20 @@ def get_browser_options(): co.add_extension(extension_path) except FileNotFoundError as e: print(f"警告: {e}") - + co.headless() - co.set_user_agent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.6723.92 Safari/537.36") + co.set_user_agent( + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.6723.92 Safari/537.36" + ) co.set_pref("credentials_enable_service", False) co.set_argument("--hide-crash-restore-bubble") co.auto_port() - + # Mac 系统特殊处理 - if sys.platform == 'darwin': - co.set_argument('--no-sandbox') - co.set_argument('--disable-gpu') - + if sys.platform == "darwin": + co.set_argument("--no-sandbox") + co.set_argument("--disable-gpu") + return co @@ -420,13 +424,14 @@ def cleanup_temp_files(): """清理临时文件和缓存""" try: temp_dirs = [ - os.path.join(os.getcwd(), '__pycache__'), - os.path.join(os.getcwd(), 'build'), + os.path.join(os.getcwd(), "__pycache__"), + os.path.join(os.getcwd(), "build"), ] - + for dir_path in temp_dirs: if os.path.exists(dir_path): import shutil + shutil.rmtree(dir_path) except Exception as e: logging.warning(f"清理临时文件失败: {str(e)}") @@ -485,6 +490,7 @@ if __name__ == "__main__": except Exception as e: print(f"程序执行出错: {str(e)}") import traceback + print(traceback.format_exc()) finally: # 确保浏览器实例被正确关闭 diff --git a/dist/CursorPro b/dist/CursorPro deleted file mode 100755 index a18a254..0000000 Binary files a/dist/CursorPro and /dev/null differ diff --git a/dist/CursorPro.app/Contents/Info.plist b/dist/CursorPro.app/Contents/Info.plist deleted file mode 100644 index 9078a98..0000000 --- a/dist/CursorPro.app/Contents/Info.plist +++ /dev/null @@ -1,28 +0,0 @@ - - - - - CFBundleDisplayName - CursorPro - CFBundleExecutable - CursorPro - CFBundleIconFile - icon-windowed.icns - CFBundleIdentifier - com.yourcompany.cursorpro - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - CursorPro - CFBundlePackageType - APPL - CFBundleShortVersionString - 1.0.0 - CFBundleVersion - 1.0.0 - LSBackgroundOnly - - NSHighResolutionCapable - - - diff --git a/dist/CursorPro.app/Contents/MacOS/CursorPro b/dist/CursorPro.app/Contents/MacOS/CursorPro deleted file mode 100755 index 947d98c..0000000 Binary files a/dist/CursorPro.app/Contents/MacOS/CursorPro and /dev/null differ diff --git a/dist/CursorPro.app/Contents/Resources/icon-windowed.icns b/dist/CursorPro.app/Contents/Resources/icon-windowed.icns deleted file mode 100644 index 954a9a0..0000000 Binary files a/dist/CursorPro.app/Contents/Resources/icon-windowed.icns and /dev/null differ diff --git a/dist/CursorPro.app/Contents/_CodeSignature/CodeResources b/dist/CursorPro.app/Contents/_CodeSignature/CodeResources deleted file mode 100644 index ae69c02..0000000 --- a/dist/CursorPro.app/Contents/_CodeSignature/CodeResources +++ /dev/null @@ -1,128 +0,0 @@ - - - - - files - - Resources/icon-windowed.icns - - eEHOuYpZLB0vKGVIWGZOh5rH8+o= - - - files2 - - Resources/icon-windowed.icns - - hash2 - - uQo7VuWRab4Phv4EEGmfQsyqFqDIXZgO8OtgaAMvCzY= - - - - rules - - ^Resources/ - - ^Resources/.*\.lproj/ - - optional - - weight - 1000 - - ^Resources/.*\.lproj/locversion.plist$ - - omit - - weight - 1100 - - ^Resources/Base\.lproj/ - - weight - 1010 - - ^version.plist$ - - - rules2 - - .*\.dSYM($|/) - - weight - 11 - - ^(.*/)?\.DS_Store$ - - omit - - weight - 2000 - - ^(Frameworks|SharedFrameworks|PlugIns|Plug-ins|XPCServices|Helpers|MacOS|Library/(Automator|Spotlight|LoginItems))/ - - nested - - weight - 10 - - ^.* - - ^Info\.plist$ - - omit - - weight - 20 - - ^PkgInfo$ - - omit - - weight - 20 - - ^Resources/ - - weight - 20 - - ^Resources/.*\.lproj/ - - optional - - weight - 1000 - - ^Resources/.*\.lproj/locversion.plist$ - - omit - - weight - 1100 - - ^Resources/Base\.lproj/ - - weight - 1010 - - ^[^/]+$ - - nested - - weight - 10 - - ^embedded\.provisionprofile$ - - weight - 20 - - ^version\.plist$ - - weight - 20 - - - - diff --git a/dist/config.ini b/dist/config.ini deleted file mode 100644 index a063651..0000000 --- a/dist/config.ini +++ /dev/null @@ -1,5 +0,0 @@ -[Account] -email = apxeme@mailto.plus -password = ccz14321@ -first_name = cheng -last_name = zhen \ No newline at end of file diff --git a/dist/readme.md b/dist/readme.md deleted file mode 100644 index 7dc7064..0000000 --- a/dist/readme.md +++ /dev/null @@ -1,80 +0,0 @@ - - -# Cursor Pro Keep Alive 使用说明文档 - -## 1. 软件介绍 -Cursor Pro Keep Alive 是一个自动化工具,用于管理 Cursor 账号的注册和更新。该工具可以自动执行账号删除和重新注册流程,以保持账号活跃。 - -> 在执行之前,一定要确保账号是通过 https://tempmail.plus/zh 获取的临时邮箱注册了 cursor账号。在注册账号时要设置好名字和密码。 - -## 2. 安装和准备 - -### 2.1 必要文件 -确保您有以下文件: -- `cursor_pro_keep_alive.exe` - 主程序 -- `config.ini` - 配置文件 - - - -## 3. 配置文件设置 - -在运行程序前,需要正确配置 `config.ini` 文件: - -```ini -[Account] -email = your_username@mailto.plus # 邮箱地址(必须使用 mailto.plus 域名) -password = your_password # 账号密码 -first_name = your_firstname # 名字 -last_name = your_lastname # 姓氏 -``` - -注意事项: -- 邮箱必须使用 `mailto.plus` 域名 -- 请确保配置文件使用 UTF-8 编码保存 - -## 4. 运行程序 - -### 4.1 运行步骤 -1. 确保所有必要文件都在同一目录下 -2. 双击运行 `cursor_pro_keep_alive.exe` -3. 程序会自动执行以下操作: - - 删除现有账号 - - 注册新账号 - - 更新认证信息 - -### 4.2 运行提示 -- 程序运行过程中会显示各个步骤的执行状态 -- 如果出现验证码,程序会自动处理 -- 运行完成后会显示操作结果 - -## 5. 常见问题解决 - -### 5.1 配置文件错误 -错误提示:`配置文件不存在` -- 解决方法:确保 `config.ini` 文件在程序同目录下 - - -## 6. 注意事项 - -1. 运行环境要求: - - Windows 操作系统 - - 稳定的网络连接 - -2. 安全提示: - - 请妥善保管配置文件,避免泄露账号信息 - - 建议定期更改密码 - -3. 使用建议: - - 建议在非高峰时段运行程序 - - 保持配置文件的定期备份 - -## 7. 技术支持 - -如遇到问题,请检查: -1. 配置文件格式是否正确 -2. 必要文件是否完整 -3. 网络连接是否正常 - -## 8. 免责声明 - -本程序仅供学习和研究使用,请遵守相关服务条款和法律法规。使用本程序产生的任何后果由用户自行承担。