forked from mirrors/cursor-free-vip
Compare commits
83 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fb3e532058 | ||
|
|
a7c4631ea4 | ||
|
|
5b64e54e90 | ||
|
|
f667da64b3 | ||
|
|
26a8e8da28 | ||
|
|
3862176867 | ||
|
|
5adc598661 | ||
|
|
5e6651bb32 | ||
|
|
bdc606ce2d | ||
|
|
564e421288 | ||
|
|
dce359dc33 | ||
|
|
ff79fae77b | ||
|
|
db3a2032dc | ||
|
|
e2a33d178d | ||
|
|
42d97cfa87 | ||
|
|
c42d7d5422 | ||
|
|
c7a84ca59f | ||
|
|
4746af7ce9 | ||
|
|
9f51ba8128 | ||
|
|
9aa09c436e | ||
|
|
1e3e9c99eb | ||
|
|
3f9cbc3d08 | ||
|
|
12d46d5f18 | ||
|
|
6cb3ad79af | ||
|
|
6470c65f8b | ||
|
|
491b227486 | ||
|
|
96c0cd5274 | ||
|
|
60a438e618 | ||
|
|
6a25871366 | ||
|
|
b46a58bd23 | ||
|
|
fea2b88a8e | ||
|
|
63fe39f2c1 | ||
|
|
386ffa4568 | ||
|
|
9c66725caf | ||
|
|
16b6ba95e2 | ||
|
|
3424f49a57 | ||
|
|
07bed23848 | ||
|
|
c12c52269e | ||
|
|
8d279ce972 | ||
|
|
849ec5ea8d | ||
|
|
c48c35fd09 | ||
|
|
a361d2fe6d | ||
|
|
74be8a0a77 | ||
|
|
bce205b252 | ||
|
|
8fcf3b62cf | ||
|
|
eeaee073cf | ||
|
|
2f353da381 | ||
|
|
efd1417407 | ||
|
|
2cc7cce283 | ||
|
|
4c30afcd7f | ||
|
|
bfb2f5e95a | ||
|
|
35e01edf9c | ||
|
|
df9e88131b | ||
|
|
8a4d22103e | ||
|
|
1244d86994 | ||
|
|
a2833fcbd4 | ||
|
|
b3e7c101d3 | ||
|
|
0a779063bf | ||
|
|
c96433e446 | ||
|
|
5604f5073d | ||
|
|
3cad68be36 | ||
|
|
d8799cdf2e | ||
|
|
3e5c22b816 | ||
|
|
893c3f8a52 | ||
|
|
edb74e21be | ||
|
|
be52ce98a6 | ||
|
|
163748fd96 | ||
|
|
f888b8c90c | ||
|
|
3c12561997 | ||
|
|
80aab8741f | ||
|
|
2595c4c95d | ||
|
|
f18e65f391 | ||
|
|
671307b53b | ||
|
|
f58bb70d3a | ||
|
|
5bfe653a92 | ||
|
|
a66a0e5395 | ||
|
|
ea44218a8a | ||
|
|
fdc8317380 | ||
|
|
523daea54e | ||
|
|
5a4e32f3f4 | ||
|
|
d91485ec75 | ||
|
|
51cef9c2b2 | ||
|
|
6e6180e331 |
75
.github/ISSUE_TEMPLATE/cn_feature_request.yml
vendored
Normal file
75
.github/ISSUE_TEMPLATE/cn_feature_request.yml
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
name: 💡 功能建议
|
||||
description: 为这个项目提出新的想法
|
||||
title: "[功能建议]: "
|
||||
labels: ["enhancement"]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
感谢您抽出时间提出新功能建议!
|
||||
请确保填写以下所有部分。
|
||||
- type: textarea
|
||||
id: feature-description
|
||||
attributes:
|
||||
label: 功能描述
|
||||
description: 清晰简洁地描述您想要实现的功能。
|
||||
placeholder: "我希望能够..."
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: problem-solution
|
||||
attributes:
|
||||
label: 问题和解决方案
|
||||
description: 描述您试图解决的问题,以及这个功能将如何帮助解决。
|
||||
placeholder: "目前,当我尝试..."
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: alternatives
|
||||
attributes:
|
||||
label: 考虑过的替代方案
|
||||
description: 描述您考虑过的任何替代解决方案或功能。
|
||||
placeholder: "我考虑过..."
|
||||
- type: dropdown
|
||||
id: priority
|
||||
attributes:
|
||||
label: 优先级
|
||||
description: 这个功能对您来说有多重要?
|
||||
options:
|
||||
- 高(对我的工作流程至关重要)
|
||||
- 中(会很有帮助)
|
||||
- 低(有更好)
|
||||
validations:
|
||||
required: true
|
||||
- type: dropdown
|
||||
id: impact
|
||||
attributes:
|
||||
label: 影响范围
|
||||
description: 有多少用户会从这个功能中受益?
|
||||
options:
|
||||
- 所有用户
|
||||
- 大多数用户
|
||||
- 部分用户
|
||||
- 仅我个人
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: technical-details
|
||||
attributes:
|
||||
label: 技术细节
|
||||
description: 您想分享的任何技术考虑或实现细节。
|
||||
placeholder: "这个功能可以通过..."
|
||||
- type: textarea
|
||||
id: screenshots
|
||||
attributes:
|
||||
label: 截图
|
||||
description: 如果适用,添加截图以帮助解释您的功能建议。
|
||||
placeholder: "您可以在此处拖放截图..."
|
||||
- type: checkboxes
|
||||
id: terms
|
||||
attributes:
|
||||
label: 行为准则
|
||||
description: 提交此问题即表示您同意遵守本项目的行为准则
|
||||
options:
|
||||
- label: 我同意遵守本项目的行为准则
|
||||
required: true
|
||||
75
.github/ISSUE_TEMPLATE/en_feature_request.yml
vendored
Normal file
75
.github/ISSUE_TEMPLATE/en_feature_request.yml
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
name: 💡 Feature Request
|
||||
description: Suggest an idea for this project
|
||||
title: "[Feature]: "
|
||||
labels: ["enhancement"]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Thanks for taking the time to suggest a new feature!
|
||||
Please make sure to fill out all the sections below.
|
||||
- type: textarea
|
||||
id: feature-description
|
||||
attributes:
|
||||
label: Feature Description
|
||||
description: A clear and concise description of what you want to happen.
|
||||
placeholder: "I would like to..."
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: problem-solution
|
||||
attributes:
|
||||
label: Problem & Solution
|
||||
description: Describe the problem you're trying to solve and how this feature would help.
|
||||
placeholder: "Currently, when I try to..."
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: alternatives
|
||||
attributes:
|
||||
label: Alternatives Considered
|
||||
description: Describe any alternative solutions or features you've considered.
|
||||
placeholder: "I've considered..."
|
||||
- type: dropdown
|
||||
id: priority
|
||||
attributes:
|
||||
label: Priority
|
||||
description: How important is this feature to you?
|
||||
options:
|
||||
- High (Critical for my workflow)
|
||||
- Medium (Would be very helpful)
|
||||
- Low (Nice to have)
|
||||
validations:
|
||||
required: true
|
||||
- type: dropdown
|
||||
id: impact
|
||||
attributes:
|
||||
label: Impact
|
||||
description: How many users would benefit from this feature?
|
||||
options:
|
||||
- All users
|
||||
- Most users
|
||||
- Some users
|
||||
- Just me
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: technical-details
|
||||
attributes:
|
||||
label: Technical Details
|
||||
description: Any technical considerations or implementation details you'd like to share.
|
||||
placeholder: "The feature could be implemented by..."
|
||||
- type: textarea
|
||||
id: screenshots
|
||||
attributes:
|
||||
label: Screenshots
|
||||
description: If applicable, add screenshots to help explain your feature.
|
||||
placeholder: "You can drag and drop screenshots here..."
|
||||
- type: checkboxes
|
||||
id: terms
|
||||
attributes:
|
||||
label: Code of Conduct
|
||||
description: By submitting this issue, you agree to follow this project's Code of Conduct
|
||||
options:
|
||||
- label: I agree to follow this project's Code of Conduct
|
||||
required: true
|
||||
4
.github/workflows/build.yml
vendored
4
.github/workflows/build.yml
vendored
@@ -6,7 +6,7 @@ on:
|
||||
version:
|
||||
description: 'Version number (e.g. 1.0.9)'
|
||||
required: true
|
||||
default: '1.8.04'
|
||||
default: '1.9.02'
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
@@ -241,4 +241,4 @@ jobs:
|
||||
draft: false
|
||||
prerelease: false
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
78
CHANGELOG.md
78
CHANGELOG.md
@@ -1,5 +1,81 @@
|
||||
# Change Log
|
||||
|
||||
## v1.9.03
|
||||
1. Hotfix: Some Issues | 修復一些問題
|
||||
2. Add: Bypass Cursor JWT EXP Problem | 添加繞過 Cursor JWT EXP 問題
|
||||
3. Fix: Cursor editor redirects to logout page and logout automatically | 修復 Cursor 編輯器重定向到登出頁面並自動登出
|
||||
4. Fix: Some Issues | 修復一些問題
|
||||
|
||||
## v1.9.02
|
||||
1. Add: Bypass Token Limit | 添加繞過 Token 限制
|
||||
2. Add: More Browser Support | 添加更多瀏覽器支持
|
||||
3. Add: Bypass Cursor JWT EXP Problem | 添加繞過 Cursor JWT EXP 問題
|
||||
4. Support: Add Opera, Brave, Edge, Firefox | 添加支持 Opera, Brave, Edge, Firefox
|
||||
5. Add config manual browser path | 添加配置手動選擇遊覽器路徑
|
||||
5. Fix: Browser Profile Selection | 修復瀏覽器配置文件選擇
|
||||
6. Fix: Cursor editor redirects to logout page and logout automatically | 修復 Cursor 編輯器重定向到登出頁面並自動登出
|
||||
7. Fix: Config File Path | 修復配置文件路徑
|
||||
8. Fix: window user permission | 修復 window 用戶權限
|
||||
9. Fix: Some Issues | 修復一些問題
|
||||
|
||||
## v1.9.01
|
||||
1. Add: Bypass Token Limit | 添加繞過 Token 限制
|
||||
2. Add: More Browser Support | 添加更多瀏覽器支持
|
||||
3. Support: Add Opera, Brave, Edge, Firefox | 添加支持 Opera, Brave, Edge, Firefox
|
||||
4. Add config manual browser path | 添加配置手動選擇遊覽器路徑
|
||||
5. Fix: Browser Profile Selection | 修復瀏覽器配置文件選擇
|
||||
6. Fix: Some Issues | 修復一些問題
|
||||
|
||||
|
||||
## v1.8.10
|
||||
1. Add: Check User Authorized | 添加檢查用戶授權
|
||||
2. Fix: Linux Reset Process Error: 'base' | 修復 Linux 重置過程錯誤:'base'
|
||||
3. Updated the get_workbench_cursor_path function to handle Linux systems more effectively. | 更新 get_workbench_cursor_path 函數以更有效地處理 Linux 系統
|
||||
4. Added logic to use the first base path if no valid paths are found in the existing loop. | 添加邏輯以在找不到有效路徑時使用第一個基礎路徑
|
||||
5. Improved maintainability and clarity of the code by explicitly handling different operating systems. | 通過明確處理不同的操作系統,顯著提高了代碼的可維護性和清晰性
|
||||
6. Fix: Some Issues | 修復一些問題
|
||||
|
||||
## v1.8.09
|
||||
1. Add: Bypass Token Limit Check | 繞過 Token 使用限制檢查
|
||||
2. Add:Bypass Claude Limit 30000 set to 900000(9e5) | 繞過 Claude 使用限制 30000 設置為 900000(9e5)
|
||||
3. Add: Force Update Config | 添加強制更新配置
|
||||
4. Add: Multilanguage support for force update | 添加強制更新功能的多語言支持
|
||||
5. Fix: Reset break | 修復重置中斷
|
||||
4. Fix: Some Issues | 修復一些問題
|
||||
|
||||
## v1.8.08
|
||||
1. Add: Force Update Config | 添加強制更新配置
|
||||
2. Add: Multilanguage support for force update | 添加強制更新功能的多語言支持
|
||||
3. Fix: Google Auth & Github Auth JWT Problem | 修復 Google Auth & Github Auth JWT 問題
|
||||
4. Fix: Totally reset import & import * raw options problem | 修復 totally reset import & import * raw 選項問題
|
||||
5. Fix: reset.file_not_found problem | 修復 reset.file_not_found 問題
|
||||
6. Outdated: Bypass Cursor Version Check | 過期:繞過 Cursor 版本檢查
|
||||
7. Document: i.header.set("x-cursor-config-version", "UUID4-xxxxxx-xxxxxx-xxxxxx-xxxxxx"); | 文檔:i.header.set("x-cursor-config-version", "UUID4-xxxxxx-xxxxxx-xxxxxx-xxxxxx");
|
||||
8. Fix: Some Issues | 修復一些問題
|
||||
|
||||
## v1.8.07
|
||||
1. Add: Bypass Cursor Version Check | 添加繞過 Cursor 版本檢查
|
||||
2. Add: Multilanguage support for bypass | 添加繞過的多語言支持
|
||||
3. MSG: Free & free trial accounts can no longer use chat with premium models on Cursor Version 0.45 or less. Please upgrade to Pro or use Cursor Version 0.46 or later. Install Cursor at https://www.cursor.com/downloads or update from within the editor.
|
||||
4. Fix: Some Issues | 修復一些問題
|
||||
|
||||
## v1.8.06
|
||||
1. Add: Google Account Deletion Feature | 添加 Google 账号删除功能
|
||||
2. Update: Menu with new account deletion option | 更新菜单添加账号删除选项
|
||||
3. Add: Multilanguage support for account deletion | 添加账号删除功能的多语言支持
|
||||
4. Fix: Improve usage limits check and tuple index error | 修复使用限制检查和元组索引错误
|
||||
5. Fix: bug in disable cursor auto update | 修复禁用 Cursor 自动更新的错误
|
||||
6. Fix: Linux-appimage | 修复 Linux-appimage 问题
|
||||
7. Add: Support for custom Cursor installation paths on Windows | 添加 Windows 系统下自定义 Cursor 安装路径支持
|
||||
8. Add: Chrome profile selection feature | 添加 Chrome 配置文件选择功能
|
||||
9. Fix: improve account usage limit detection | 修復賬號檢測
|
||||
10. Fix: For custom Chrome Installations | 修復自定義chrome遊覽器安裝
|
||||
|
||||
## v1.8.05
|
||||
1. Fix: Linux Path Not Found | 修復linuxpath問題
|
||||
2. Add: support for detecting both 150/150 and 50/50 usage limits | 添加偵測50 或者150的使用量
|
||||
3. Improve: usage parsing and validation | 檢測使用量
|
||||
|
||||
## v1.8.04
|
||||
1. Update totally_reset_cursor.py | 更新 totally_reset_cursor.py
|
||||
2. Fix: improve Linux Chrome visibility and root user handling | 修復 Linux Chrome 可見性以及 root 用戶處理
|
||||
@@ -222,7 +298,7 @@ These changes make the application more user-friendly by only requesting admin p
|
||||
1. Fix: Cursor Auth | 修復 Cursor Auth
|
||||
2. Add: Create Account Maximum Retry | 增加創建賬號最大重試次數
|
||||
3. Fix: Cursor Auth Error | 修復 Cursor Auth 錯誤
|
||||
4. Fix: Update Curl Faild | 修復更新 Curl 失敗
|
||||
4. Fix: Update Curl Failed | 修復更新 Curl 失敗
|
||||
|
||||
## v1.5.03
|
||||
1. HOTFIX: Stuck on starting browser | 修復啟動瀏覽器卡住問題
|
||||
|
||||
37
README.md
37
README.md
@@ -27,12 +27,14 @@ Always clean your browser's cache and cookies. If possible, use a VPN to create
|
||||
這是一個自動化工具,自動註冊,支持 Windows 和 macOS 系統,完成 Auth 驗證,重置 Cursor 的配置。
|
||||
|
||||
<p align="center">
|
||||
<img src="./images/new_2025-03-22_19-53-10.png" alt="new" width="400" style="border-radius: 6px;"/><br>
|
||||
<img src="./images/pro_2025-04-05_18-47-56.png" alt="new" width="800" style="border-radius: 6px;"/><br>
|
||||
</p>
|
||||
|
||||
##### If you don't have Google Chrome, you can download it from [here](https://www.google.com/intl/en_pk/chrome/)
|
||||
##### If you don't have browser, you can download it from
|
||||
[Google Chrome](https://www.google.com/intl/en_pk/chrome/) or [Opera](https://www.opera.com/download) or [Edge](https://www.microsoft.com/en-us/edge) or [Firefox](https://www.mozilla.org/en-US/firefox/new/) or [Brave](https://www.brave.com/download/)
|
||||
|
||||
##### 如果沒有 Google Chrome,可以從[這裡](https://www.google.com/intl/en_pk/chrome/)下載
|
||||
##### 如果沒有瀏覽器,可以從
|
||||
[Google Chrome](https://www.google.com/intl/en_pk/chrome/) 或 [Opera](https://www.opera.com/download) 或 [Edge](https://www.microsoft.com/en-us/edge) 或 [Firefox](https://www.mozilla.org/en-US/firefox/new/) 或 [Brave](https://www.brave.com/download/) 下載
|
||||
|
||||
</div>
|
||||
|
||||
@@ -54,6 +56,8 @@ Always clean your browser's cache and cookies. If possible, use a VPN to create
|
||||
|
||||
* Reset Cursor's configuration<br>重置 Cursor 的配置<br>
|
||||
|
||||
* Delete Cursor Google Account<br>删除 Cursor Google 账号<br>
|
||||
|
||||
* Multi-language support (English, 简体中文, 繁體中文, Vietnamese)<br>多語言支持(英文、简体中文、繁體中文、越南語)<br>
|
||||
|
||||
## 💻 System Support | 系統支持
|
||||
@@ -164,6 +168,33 @@ max_timeout = 160
|
||||
check_update = True
|
||||
# Show Account Info | 顯示賬號信息
|
||||
show_account_info = True
|
||||
|
||||
[WindowsPaths]
|
||||
storage_path = C:\Users\yeongpin\AppData\Roaming\Cursor\User\globalStorage\storage.json
|
||||
sqlite_path = C:\Users\yeongpin\AppData\Roaming\Cursor\User\globalStorage\state.vscdb
|
||||
machine_id_path = C:\Users\yeongpin\AppData\Roaming\Cursor\machineId
|
||||
cursor_path = C:\Users\yeongpin\AppData\Local\Programs\Cursor\resources\app
|
||||
updater_path = C:\Users\yeongpin\AppData\Local\cursor-updater
|
||||
update_yml_path = C:\Users\yeongpin\AppData\Local\Programs\Cursor\resources\app-update.yml
|
||||
product_json_path = C:\Users\yeongpin\AppData\Local\Programs\Cursor\resources\app\product.json
|
||||
|
||||
[Browser]
|
||||
default_browser = opera
|
||||
chrome_path = C:\Program Files\Google\Chrome\Application\chrome.exe
|
||||
edge_path = C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe
|
||||
firefox_path = C:\Program Files\Mozilla Firefox\firefox.exe
|
||||
brave_path = C:\Program Files\BraveSoftware/Brave-Browser/Application/brave.exe
|
||||
chrome_driver_path = D:\VisualCode\cursor-free-vip-new\drivers\chromedriver.exe
|
||||
edge_driver_path = D:\VisualCode\cursor-free-vip-new\drivers\msedgedriver.exe
|
||||
firefox_driver_path = D:\VisualCode\cursor-free-vip-new\drivers\geckodriver.exe
|
||||
brave_driver_path = D:\VisualCode\cursor-free-vip-new\drivers\chromedriver.exe
|
||||
opera_path = C:\Users\yeongpin\AppData\Local\Programs\Opera\opera.exe
|
||||
opera_driver_path = D:\VisualCode\cursor-free-vip-new\drivers\chromedriver.exe
|
||||
|
||||
[OAuth]
|
||||
show_selection_alert = False
|
||||
timeout = 120
|
||||
max_attempts = 3
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
@@ -19,4 +19,65 @@ begemail.com
|
||||
dugmail.com
|
||||
solerbe.net
|
||||
corhash.net
|
||||
mailshou.com
|
||||
mailshou.com
|
||||
0-mail.com
|
||||
1secmail.com
|
||||
20minutemail.com
|
||||
2prong.com
|
||||
33mail.com
|
||||
anonbox.net
|
||||
anonymbox.com
|
||||
boun.cr
|
||||
burnermail.io
|
||||
byom.de
|
||||
chammy.info
|
||||
cloud-mail.top
|
||||
cool.fr.nf
|
||||
crazymailing.com
|
||||
cuvox.de
|
||||
deadaddress.com
|
||||
dispostable.com
|
||||
dudmail.com
|
||||
emailondeck.com
|
||||
fakeinbox.com
|
||||
fakemailgenerator.com
|
||||
filzmail.com
|
||||
fizmail.com
|
||||
guerrillamail.com
|
||||
harakirimail.com
|
||||
hottempmail.com
|
||||
inboxbear.com
|
||||
inboxkitten.com
|
||||
incognitomail.org
|
||||
letthemeatspam.com
|
||||
maildrop.cc
|
||||
mailinator.com
|
||||
mailnesia.com
|
||||
mailsac.com
|
||||
mailtemp.net
|
||||
mailzilla.org
|
||||
mintemail.com
|
||||
moakt.com
|
||||
my10minutemail.com
|
||||
mytrashmail.com
|
||||
nospamfor.us
|
||||
nowmymail.com
|
||||
openmailbox.org
|
||||
privacyroot.com
|
||||
sharklasers.com
|
||||
spam4.me
|
||||
spamavert.com
|
||||
spambog.com
|
||||
spamex.com
|
||||
spamfree24.org
|
||||
spaml.com
|
||||
temp-mail.org
|
||||
tempmail.net
|
||||
tempmailaddress.com
|
||||
temporaryemail.net
|
||||
throwawayemail.com
|
||||
trash-mail.com
|
||||
trashmail.com
|
||||
trbvn.com
|
||||
yopmail.com
|
||||
zippymail.info
|
||||
|
||||
@@ -33,6 +33,8 @@ a = Analysis(
|
||||
('new_tempemail.py', '.'),
|
||||
('quit_cursor.py', '.'),
|
||||
('cursor_register_manual.py', '.'),
|
||||
('oauth_auth.py', '.'),
|
||||
('utils.py', '.'),
|
||||
('.env', '.'),
|
||||
('block_domain.txt', '.')
|
||||
],
|
||||
@@ -42,7 +44,9 @@ a = Analysis(
|
||||
'new_signup',
|
||||
'new_tempemail',
|
||||
'quit_cursor',
|
||||
'cursor_register_manual'
|
||||
'cursor_register_manual',
|
||||
'oauth_auth',
|
||||
'utils'
|
||||
],
|
||||
hookspath=[],
|
||||
hooksconfig={},
|
||||
|
||||
174
bypass_token_limit.py
Normal file
174
bypass_token_limit.py
Normal file
@@ -0,0 +1,174 @@
|
||||
import os
|
||||
import shutil
|
||||
import platform
|
||||
import tempfile
|
||||
import glob
|
||||
from colorama import Fore, Style, init
|
||||
import configparser
|
||||
from new_signup import get_user_documents_path
|
||||
from config import get_config
|
||||
from datetime import datetime
|
||||
|
||||
# Initialize colorama
|
||||
init()
|
||||
|
||||
# Define emoji constants
|
||||
EMOJI = {
|
||||
"FILE": "📄",
|
||||
"BACKUP": "💾",
|
||||
"SUCCESS": "✅",
|
||||
"ERROR": "❌",
|
||||
"INFO": "ℹ️",
|
||||
"RESET": "🔄",
|
||||
"WARNING": "⚠️",
|
||||
}
|
||||
|
||||
def get_workbench_cursor_path(translator=None) -> str:
|
||||
"""Get Cursor workbench.desktop.main.js path"""
|
||||
system = platform.system()
|
||||
|
||||
# Read configuration
|
||||
config_dir = os.path.join(get_user_documents_path(), ".cursor-free-vip")
|
||||
config_file = os.path.join(config_dir, "config.ini")
|
||||
config = configparser.ConfigParser()
|
||||
|
||||
if os.path.exists(config_file):
|
||||
config.read(config_file)
|
||||
|
||||
paths_map = {
|
||||
"Darwin": { # macOS
|
||||
"base": "/Applications/Cursor.app/Contents/Resources/app",
|
||||
"main": "out/vs/workbench/workbench.desktop.main.js"
|
||||
},
|
||||
"Windows": {
|
||||
"main": "out\\vs\\workbench\\workbench.desktop.main.js"
|
||||
},
|
||||
"Linux": {
|
||||
"bases": ["/opt/Cursor/resources/app", "/usr/share/cursor/resources/app", "/usr/lib/cursor/app/"],
|
||||
"main": "out/vs/workbench/workbench.desktop.main.js"
|
||||
}
|
||||
}
|
||||
|
||||
if system == "Linux":
|
||||
# Add extracted AppImage with correct usr structure
|
||||
extracted_usr_paths = glob.glob(os.path.expanduser("~/squashfs-root/usr/share/cursor/resources/app"))
|
||||
|
||||
paths_map["Linux"]["bases"].extend(extracted_usr_paths)
|
||||
|
||||
if system not in paths_map:
|
||||
raise OSError(translator.get('reset.unsupported_os', system=system) if translator else f"不支持的操作系统: {system}")
|
||||
|
||||
if system == "Linux":
|
||||
for base in paths_map["Linux"]["bases"]:
|
||||
main_path = os.path.join(base, paths_map["Linux"]["main"])
|
||||
print(f"{Fore.CYAN}{EMOJI['INFO']} Checking path: {main_path}{Style.RESET_ALL}")
|
||||
if os.path.exists(main_path):
|
||||
return main_path
|
||||
|
||||
if system == "Windows":
|
||||
base_path = config.get('WindowsPaths', 'cursor_path')
|
||||
elif system == "Darwin":
|
||||
base_path = paths_map[system]["base"]
|
||||
else: # Linux
|
||||
# For Linux, we've already checked all bases in the loop above
|
||||
# If we're here, it means none of the bases worked, so we'll use the first one
|
||||
base_path = paths_map[system]["bases"][0]
|
||||
|
||||
main_path = os.path.join(base_path, paths_map[system]["main"])
|
||||
|
||||
if not os.path.exists(main_path):
|
||||
raise OSError(translator.get('reset.file_not_found', path=main_path) if translator else f"未找到 Cursor main.js 文件: {main_path}")
|
||||
|
||||
return main_path
|
||||
|
||||
|
||||
def modify_workbench_js(file_path: str, translator=None) -> bool:
|
||||
"""
|
||||
Modify file content
|
||||
"""
|
||||
try:
|
||||
# Save original file permissions
|
||||
original_stat = os.stat(file_path)
|
||||
original_mode = original_stat.st_mode
|
||||
original_uid = original_stat.st_uid
|
||||
original_gid = original_stat.st_gid
|
||||
|
||||
# Create temporary file
|
||||
with tempfile.NamedTemporaryFile(mode="w", encoding="utf-8", errors="ignore", delete=False) as tmp_file:
|
||||
# Read original content
|
||||
with open(file_path, "r", encoding="utf-8", errors="ignore") as main_file:
|
||||
content = main_file.read()
|
||||
|
||||
patterns = {
|
||||
# 通用按钮替换模式
|
||||
r'B(k,D(Ln,{title:"Upgrade to Pro",size:"small",get codicon(){return A.rocket},get onClick(){return t.pay}}),null)': r'B(k,D(Ln,{title:"yeongpin GitHub",size:"small",get codicon(){return A.github},get onClick(){return function(){window.open("https://github.com/yeongpin/cursor-free-vip","_blank")}}}),null)',
|
||||
|
||||
# Windows/Linux/Mac 通用按钮替换模式
|
||||
r'M(x,I(as,{title:"Upgrade to Pro",size:"small",get codicon(){return $.rocket},get onClick(){return t.pay}}),null)': r'M(x,I(as,{title:"yeongpin GitHub",size:"small",get codicon(){return $.rocket},get onClick(){return function(){window.open("https://github.com/yeongpin/cursor-free-vip","_blank")}}}),null)',
|
||||
|
||||
# Badge 替换
|
||||
r'<div>Pro Trial': r'<div>Pro',
|
||||
|
||||
r'py-1">Auto-select': r'py-1">Bypass-Version-Pin',
|
||||
|
||||
#
|
||||
r'async getEffectiveTokenLimit(e){const n=e.modelName;if(!n)return 2e5;':r'async getEffectiveTokenLimit(e){return 9000000;const n=e.modelName;if(!n)return 9e5;',
|
||||
# Pro
|
||||
r'var DWr=ne("<div class=settings__item_description>You are currently signed in with <strong></strong>.");': r'var DWr=ne("<div class=settings__item_description>You are currently signed in with <strong></strong>. <h1>Pro</h1>");',
|
||||
|
||||
# Toast 替换
|
||||
r'notifications-toasts': r'notifications-toasts hidden'
|
||||
}
|
||||
|
||||
# 使用patterns进行替换
|
||||
for old_pattern, new_pattern in patterns.items():
|
||||
content = content.replace(old_pattern, new_pattern)
|
||||
|
||||
# Write to temporary file
|
||||
tmp_file.write(content)
|
||||
tmp_path = tmp_file.name
|
||||
|
||||
# Backup original file with timestamp
|
||||
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
||||
backup_path = f"{file_path}.backup.{timestamp}"
|
||||
shutil.copy2(file_path, backup_path)
|
||||
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} {translator.get('reset.backup_created', path=backup_path)}{Style.RESET_ALL}")
|
||||
|
||||
# Move temporary file to original position
|
||||
if os.path.exists(file_path):
|
||||
os.remove(file_path)
|
||||
shutil.move(tmp_path, file_path)
|
||||
|
||||
# Restore original permissions
|
||||
os.chmod(file_path, original_mode)
|
||||
if os.name != "nt": # Not Windows
|
||||
os.chown(file_path, original_uid, original_gid)
|
||||
|
||||
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} {translator.get('reset.file_modified')}{Style.RESET_ALL}")
|
||||
return True
|
||||
|
||||
except Exception as e:
|
||||
print(f"{Fore.RED}{EMOJI['ERROR']} {translator.get('reset.modify_file_failed', error=str(e))}{Style.RESET_ALL}")
|
||||
if "tmp_path" in locals():
|
||||
try:
|
||||
os.unlink(tmp_path)
|
||||
except:
|
||||
pass
|
||||
return False
|
||||
|
||||
def run(translator=None):
|
||||
config = get_config(translator)
|
||||
if not config:
|
||||
return False
|
||||
print(f"\n{Fore.CYAN}{'='*50}{Style.RESET_ALL}")
|
||||
print(f"{Fore.CYAN}{EMOJI['RESET']} {translator.get('bypass_token_limit.title')}{Style.RESET_ALL}")
|
||||
print(f"{Fore.CYAN}{'='*50}{Style.RESET_ALL}")
|
||||
|
||||
modify_workbench_js(get_workbench_cursor_path(translator), translator)
|
||||
|
||||
print(f"\n{Fore.CYAN}{'='*50}{Style.RESET_ALL}")
|
||||
input(f"{EMOJI['INFO']} {translator.get('bypass_token_limit.press_enter')}...")
|
||||
|
||||
if __name__ == "__main__":
|
||||
from main import translator as main_translator
|
||||
run(main_translator)
|
||||
158
bypass_version.py
Normal file
158
bypass_version.py
Normal file
@@ -0,0 +1,158 @@
|
||||
import os
|
||||
import json
|
||||
import shutil
|
||||
import platform
|
||||
import configparser
|
||||
import time
|
||||
from colorama import Fore, Style, init
|
||||
import sys
|
||||
import traceback
|
||||
from utils import get_user_documents_path
|
||||
|
||||
# Initialize colorama
|
||||
init()
|
||||
|
||||
# Define emoji constants
|
||||
EMOJI = {
|
||||
'INFO': 'ℹ️',
|
||||
'SUCCESS': '✅',
|
||||
'ERROR': '❌',
|
||||
'WARNING': '⚠️',
|
||||
'FILE': '📄',
|
||||
'BACKUP': '💾',
|
||||
'RESET': '🔄',
|
||||
'VERSION': '🏷️'
|
||||
}
|
||||
|
||||
def get_product_json_path(translator=None):
|
||||
"""Get Cursor product.json path"""
|
||||
system = platform.system()
|
||||
|
||||
# Read configuration
|
||||
config_dir = os.path.join(get_user_documents_path(), ".cursor-free-vip")
|
||||
config_file = os.path.join(config_dir, "config.ini")
|
||||
config = configparser.ConfigParser()
|
||||
|
||||
if os.path.exists(config_file):
|
||||
config.read(config_file)
|
||||
|
||||
if system == "Windows":
|
||||
localappdata = os.environ.get("LOCALAPPDATA")
|
||||
if not localappdata:
|
||||
raise OSError(translator.get('bypass.localappdata_not_found') if translator else "LOCALAPPDATA environment variable not found")
|
||||
|
||||
product_json_path = os.path.join(localappdata, "Programs", "Cursor", "resources", "app", "product.json")
|
||||
|
||||
# Check if path exists in config
|
||||
if 'WindowsPaths' in config and 'cursor_path' in config['WindowsPaths']:
|
||||
cursor_path = config.get('WindowsPaths', 'cursor_path')
|
||||
product_json_path = os.path.join(cursor_path, "product.json")
|
||||
|
||||
elif system == "Darwin": # macOS
|
||||
product_json_path = "/Applications/Cursor.app/Contents/Resources/app/product.json"
|
||||
|
||||
elif system == "Linux":
|
||||
# Try multiple common paths
|
||||
possible_paths = [
|
||||
"/opt/Cursor/resources/app/product.json",
|
||||
"/usr/share/cursor/resources/app/product.json",
|
||||
"/usr/lib/cursor/app/product.json"
|
||||
]
|
||||
|
||||
# Add extracted AppImage paths
|
||||
extracted_usr_paths = os.path.expanduser("~/squashfs-root/usr/share/cursor/resources/app/product.json")
|
||||
if os.path.exists(extracted_usr_paths):
|
||||
possible_paths.append(extracted_usr_paths)
|
||||
|
||||
for path in possible_paths:
|
||||
if os.path.exists(path):
|
||||
product_json_path = path
|
||||
break
|
||||
else:
|
||||
raise OSError(translator.get('bypass.product_json_not_found') if translator else "product.json not found in common Linux paths")
|
||||
|
||||
else:
|
||||
raise OSError(translator.get('bypass.unsupported_os', system=system) if translator else f"Unsupported operating system: {system}")
|
||||
|
||||
if not os.path.exists(product_json_path):
|
||||
raise OSError(translator.get('bypass.file_not_found', path=product_json_path) if translator else f"File not found: {product_json_path}")
|
||||
|
||||
return product_json_path
|
||||
|
||||
def compare_versions(version1, version2):
|
||||
"""Compare two version strings"""
|
||||
v1_parts = [int(x) for x in version1.split('.')]
|
||||
v2_parts = [int(x) for x in version2.split('.')]
|
||||
|
||||
for i in range(max(len(v1_parts), len(v2_parts))):
|
||||
v1 = v1_parts[i] if i < len(v1_parts) else 0
|
||||
v2 = v2_parts[i] if i < len(v2_parts) else 0
|
||||
if v1 < v2:
|
||||
return -1
|
||||
elif v1 > v2:
|
||||
return 1
|
||||
|
||||
return 0
|
||||
|
||||
def bypass_version(translator=None):
|
||||
"""Bypass Cursor version check by modifying product.json"""
|
||||
try:
|
||||
print(f"\n{Fore.CYAN}{EMOJI['INFO']} {translator.get('bypass.starting') if translator else 'Starting Cursor version bypass...'}{Style.RESET_ALL}")
|
||||
|
||||
# Get product.json path
|
||||
product_json_path = get_product_json_path(translator)
|
||||
print(f"{Fore.CYAN}{EMOJI['FILE']} {translator.get('bypass.found_product_json', path=product_json_path) if translator else f'Found product.json: {product_json_path}'}{Style.RESET_ALL}")
|
||||
|
||||
# Check file permissions
|
||||
if not os.access(product_json_path, os.W_OK):
|
||||
print(f"{Fore.RED}{EMOJI['ERROR']} {translator.get('bypass.no_write_permission', path=product_json_path) if translator else f'No write permission for file: {product_json_path}'}{Style.RESET_ALL}")
|
||||
return False
|
||||
|
||||
# Read product.json
|
||||
try:
|
||||
with open(product_json_path, "r", encoding="utf-8") as f:
|
||||
product_data = json.load(f)
|
||||
except Exception as e:
|
||||
print(f"{Fore.RED}{EMOJI['ERROR']} {translator.get('bypass.read_failed', error=str(e)) if translator else f'Failed to read product.json: {str(e)}'}{Style.RESET_ALL}")
|
||||
return False
|
||||
|
||||
# Get current version
|
||||
current_version = product_data.get("version", "0.0.0")
|
||||
print(f"{Fore.CYAN}{EMOJI['VERSION']} {translator.get('bypass.current_version', version=current_version) if translator else f'Current version: {current_version}'}{Style.RESET_ALL}")
|
||||
|
||||
# Check if version needs to be modified
|
||||
if compare_versions(current_version, "0.46.0") < 0:
|
||||
# Create backup
|
||||
timestamp = time.strftime("%Y%m%d%H%M%S")
|
||||
backup_path = f"{product_json_path}.{timestamp}"
|
||||
shutil.copy2(product_json_path, backup_path)
|
||||
print(f"{Fore.GREEN}{EMOJI['BACKUP']} {translator.get('bypass.backup_created', path=backup_path) if translator else f'Backup created: {backup_path}'}{Style.RESET_ALL}")
|
||||
|
||||
# Modify version
|
||||
new_version = "0.48.7"
|
||||
product_data["version"] = new_version
|
||||
|
||||
# Save modified product.json
|
||||
try:
|
||||
with open(product_json_path, "w", encoding="utf-8") as f:
|
||||
json.dump(product_data, f, indent=2)
|
||||
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} {translator.get('bypass.version_updated', old=current_version, new=new_version) if translator else f'Version updated from {current_version} to {new_version}'}{Style.RESET_ALL}")
|
||||
return True
|
||||
except Exception as e:
|
||||
print(f"{Fore.RED}{EMOJI['ERROR']} {translator.get('bypass.write_failed', error=str(e)) if translator else f'Failed to write product.json: {str(e)}'}{Style.RESET_ALL}")
|
||||
return False
|
||||
else:
|
||||
print(f"{Fore.YELLOW}{EMOJI['INFO']} {translator.get('bypass.no_update_needed', version=current_version) if translator else f'No update needed. Current version {current_version} is already >= 0.46.0'}{Style.RESET_ALL}")
|
||||
return True
|
||||
|
||||
except Exception as e:
|
||||
print(f"{Fore.RED}{EMOJI['ERROR']} {translator.get('bypass.bypass_failed', error=str(e)) if translator else f'Version bypass failed: {str(e)}'}{Style.RESET_ALL}")
|
||||
print(f"{Fore.YELLOW}{EMOJI['INFO']} {translator.get('bypass.stack_trace') if translator else 'Stack trace'}: {traceback.format_exc()}{Style.RESET_ALL}")
|
||||
return False
|
||||
|
||||
def main(translator=None):
|
||||
"""Main function"""
|
||||
return bypass_version(translator)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
214
check_user_authorized.py
Normal file
214
check_user_authorized.py
Normal file
@@ -0,0 +1,214 @@
|
||||
import os
|
||||
import requests
|
||||
import time
|
||||
import hashlib
|
||||
import base64
|
||||
import struct
|
||||
from colorama import Fore, Style, init
|
||||
|
||||
# Initialize colorama
|
||||
init()
|
||||
|
||||
# Define emoji constants
|
||||
EMOJI = {
|
||||
"SUCCESS": "✅",
|
||||
"ERROR": "❌",
|
||||
"INFO": "ℹ️",
|
||||
"WARNING": "⚠️",
|
||||
"KEY": "🔑",
|
||||
"CHECK": "🔍"
|
||||
}
|
||||
|
||||
def generate_hashed64_hex(input_str: str, salt: str = '') -> str:
|
||||
"""Generate a SHA-256 hash of input + salt and return as hex"""
|
||||
hash_obj = hashlib.sha256()
|
||||
hash_obj.update((input_str + salt).encode('utf-8'))
|
||||
return hash_obj.hexdigest()
|
||||
|
||||
def obfuscate_bytes(byte_array: bytearray) -> bytearray:
|
||||
"""Obfuscate bytes using the algorithm from utils.js"""
|
||||
t = 165
|
||||
for r in range(len(byte_array)):
|
||||
byte_array[r] = ((byte_array[r] ^ t) + (r % 256)) & 0xFF
|
||||
t = byte_array[r]
|
||||
return byte_array
|
||||
|
||||
def generate_cursor_checksum(token: str, translator=None) -> str:
|
||||
"""Generate Cursor checksum from token using the algorithm"""
|
||||
try:
|
||||
# Clean the token
|
||||
clean_token = token.strip()
|
||||
|
||||
# Generate machineId and macMachineId
|
||||
machine_id = generate_hashed64_hex(clean_token, 'machineId')
|
||||
mac_machine_id = generate_hashed64_hex(clean_token, 'macMachineId')
|
||||
|
||||
# Get timestamp and convert to byte array
|
||||
timestamp = int(time.time() * 1000) // 1000000
|
||||
byte_array = bytearray(struct.pack('>Q', timestamp)[-6:]) # Take last 6 bytes
|
||||
|
||||
# Obfuscate bytes and encode as base64
|
||||
obfuscated_bytes = obfuscate_bytes(byte_array)
|
||||
encoded_checksum = base64.b64encode(obfuscated_bytes).decode('utf-8')
|
||||
|
||||
# Combine final checksum
|
||||
return f"{encoded_checksum}{machine_id}/{mac_machine_id}"
|
||||
except Exception as e:
|
||||
print(f"{Fore.RED}{EMOJI['ERROR']} {translator.get('auth_check.error_generating_checksum', error=str(e)) if translator else f'Error generating checksum: {str(e)}'}{Style.RESET_ALL}")
|
||||
return ""
|
||||
|
||||
def check_user_authorized(token: str, translator=None) -> bool:
|
||||
"""
|
||||
Check if the user is authorized with the given token
|
||||
|
||||
Args:
|
||||
token (str): The authorization token
|
||||
translator: Optional translator for internationalization
|
||||
|
||||
Returns:
|
||||
bool: True if authorized, False otherwise
|
||||
"""
|
||||
try:
|
||||
print(f"{Fore.CYAN}{EMOJI['CHECK']} {translator.get('auth_check.checking_authorization') if translator else 'Checking authorization...'}{Style.RESET_ALL}")
|
||||
|
||||
# Clean the token
|
||||
if token and '%3A%3A' in token:
|
||||
token = token.split('%3A%3A')[1]
|
||||
elif token and '::' in token:
|
||||
token = token.split('::')[1]
|
||||
|
||||
# Remove any whitespace
|
||||
token = token.strip()
|
||||
|
||||
if not token or len(token) < 10: # Add a basic validation for token length
|
||||
print(f"{Fore.RED}{EMOJI['ERROR']} {translator.get('auth_check.invalid_token') if translator else 'Invalid token'}{Style.RESET_ALL}")
|
||||
return False
|
||||
|
||||
print(f"{Fore.CYAN}{EMOJI['INFO']} {translator.get('auth_check.token_length', length=len(token)) if translator else f'Token length: {len(token)} characters'}{Style.RESET_ALL}")
|
||||
|
||||
# Try to get usage info using the DashboardService API
|
||||
try:
|
||||
# Generate checksum
|
||||
checksum = generate_cursor_checksum(token, translator)
|
||||
|
||||
# Create request headers
|
||||
headers = {
|
||||
'accept-encoding': 'gzip',
|
||||
'authorization': f'Bearer {token}',
|
||||
'connect-protocol-version': '1',
|
||||
'content-type': 'application/proto',
|
||||
'user-agent': 'connect-es/1.6.1',
|
||||
'x-cursor-checksum': checksum,
|
||||
'x-cursor-client-version': '0.48.7',
|
||||
'x-cursor-timezone': 'Asia/Shanghai',
|
||||
'x-ghost-mode': 'false',
|
||||
'Host': 'api2.cursor.sh'
|
||||
}
|
||||
|
||||
print(f"{Fore.CYAN}{EMOJI['INFO']} {translator.get('auth_check.checking_usage_information') if translator else 'Checking usage information...'}{Style.RESET_ALL}")
|
||||
|
||||
# Make the request - this endpoint doesn't need a request body
|
||||
usage_response = requests.post(
|
||||
'https://api2.cursor.sh/aiserver.v1.DashboardService/GetUsageBasedPremiumRequests',
|
||||
headers=headers,
|
||||
data=b'', # Empty body
|
||||
timeout=10
|
||||
)
|
||||
|
||||
print(f"{Fore.CYAN}{EMOJI['INFO']} {translator.get('auth_check.usage_response', response=usage_response.status_code) if translator else f'Usage response status: {usage_response.status_code}'}{Style.RESET_ALL}")
|
||||
|
||||
if usage_response.status_code == 200:
|
||||
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} {translator.get('auth_check.user_authorized') if translator else 'User is authorized'}{Style.RESET_ALL}")
|
||||
return True
|
||||
elif usage_response.status_code == 401 or usage_response.status_code == 403:
|
||||
print(f"{Fore.RED}{EMOJI['ERROR']} {translator.get('auth_check.user_unauthorized') if translator else 'User is unauthorized'}{Style.RESET_ALL}")
|
||||
return False
|
||||
else:
|
||||
print(f"{Fore.YELLOW}{EMOJI['WARNING']} {translator.get('auth_check.unexpected_status_code', code=usage_response.status_code) if translator else f'Unexpected status code: {usage_response.status_code}'}{Style.RESET_ALL}")
|
||||
|
||||
# If the token at least looks like a valid JWT, consider it valid
|
||||
if token.startswith('eyJ') and '.' in token and len(token) > 100:
|
||||
print(f"{Fore.YELLOW}{EMOJI['WARNING']} {translator.get('auth_check.jwt_token_warning') if translator else 'Token appears to be in JWT format, but API check returned an unexpected status code. The token might be valid but API access is restricted.'}{Style.RESET_ALL}")
|
||||
return True
|
||||
|
||||
return False
|
||||
except Exception as e:
|
||||
print(f"{Fore.YELLOW}{EMOJI['WARNING']} Error checking usage: {str(e)}{Style.RESET_ALL}")
|
||||
|
||||
# If the token at least looks like a valid JWT, consider it valid even if the API check fails
|
||||
if token.startswith('eyJ') and '.' in token and len(token) > 100:
|
||||
print(f"{Fore.YELLOW}{EMOJI['WARNING']} {translator.get('auth_check.jwt_token_warning') if translator else 'Token appears to be in JWT format, but API check failed. The token might be valid but API access is restricted.'}{Style.RESET_ALL}")
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
except requests.exceptions.Timeout:
|
||||
print(f"{Fore.RED}{EMOJI['ERROR']} {translator.get('auth_check.request_timeout') if translator else 'Request timed out'}{Style.RESET_ALL}")
|
||||
return False
|
||||
except requests.exceptions.ConnectionError:
|
||||
print(f"{Fore.RED}{EMOJI['ERROR']} {translator.get('auth_check.connection_error') if translator else 'Connection error'}{Style.RESET_ALL}")
|
||||
return False
|
||||
except Exception as e:
|
||||
print(f"{Fore.RED}{EMOJI['ERROR']} {translator.get('auth_check.check_error', error=str(e)) if translator else f'Error checking authorization: {str(e)}'}{Style.RESET_ALL}")
|
||||
return False
|
||||
|
||||
def run(translator=None):
|
||||
"""Run function to be called from main.py"""
|
||||
try:
|
||||
# Ask user if they want to get token from database or input manually
|
||||
choice = input(f"{Fore.CYAN}{EMOJI['INFO']} {translator.get('auth_check.token_source') if translator else 'Get token from database or input manually? (d/m, default: d): '}{Style.RESET_ALL}").strip().lower()
|
||||
|
||||
token = None
|
||||
|
||||
# If user chooses database or default
|
||||
if not choice or choice == 'd':
|
||||
print(f"{Fore.CYAN}{EMOJI['INFO']} {translator.get('auth_check.getting_token_from_db') if translator else 'Getting token from database...'}{Style.RESET_ALL}")
|
||||
|
||||
try:
|
||||
# Import functions from cursor_acc_info.py
|
||||
from cursor_acc_info import get_token
|
||||
|
||||
# Get token using the get_token function
|
||||
token = get_token()
|
||||
|
||||
if token:
|
||||
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} {translator.get('auth_check.token_found_in_db') if translator else 'Token found in database'}{Style.RESET_ALL}")
|
||||
else:
|
||||
print(f"{Fore.YELLOW}{EMOJI['WARNING']} {translator.get('auth_check.token_not_found_in_db') if translator else 'Token not found in database'}{Style.RESET_ALL}")
|
||||
except ImportError:
|
||||
print(f"{Fore.YELLOW}{EMOJI['WARNING']} {translator.get('auth_check.cursor_acc_info_not_found') if translator else 'cursor_acc_info.py not found'}{Style.RESET_ALL}")
|
||||
except Exception as e:
|
||||
print(f"{Fore.YELLOW}{EMOJI['WARNING']} {translator.get('auth_check.error_getting_token_from_db', error=str(e)) if translator else f'Error getting token from database: {str(e)}'}{Style.RESET_ALL}")
|
||||
|
||||
# If token not found in database or user chooses manual input
|
||||
if not token:
|
||||
# Try to get token from environment
|
||||
token = os.environ.get('CURSOR_TOKEN')
|
||||
|
||||
# If not in environment, ask user to input
|
||||
if not token:
|
||||
token = input(f"{Fore.CYAN}{EMOJI['KEY']} {translator.get('auth_check.enter_token') if translator else 'Enter your Cursor token: '}{Style.RESET_ALL}")
|
||||
|
||||
# Check authorization
|
||||
is_authorized = check_user_authorized(token, translator)
|
||||
|
||||
if is_authorized:
|
||||
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} {translator.get('auth_check.authorization_successful') if translator else 'Authorization successful!'}{Style.RESET_ALL}")
|
||||
else:
|
||||
print(f"{Fore.RED}{EMOJI['ERROR']} {translator.get('auth_check.authorization_failed') if translator else 'Authorization failed!'}{Style.RESET_ALL}")
|
||||
|
||||
return is_authorized
|
||||
|
||||
except KeyboardInterrupt:
|
||||
print(f"\n{Fore.YELLOW}{EMOJI['WARNING']} {translator.get('auth_check.operation_cancelled') if translator else 'Operation cancelled by user'}{Style.RESET_ALL}")
|
||||
return False
|
||||
except Exception as e:
|
||||
print(f"{Fore.RED}{EMOJI['ERROR']} {translator.get('auth_check.unexpected_error', error=str(e)) if translator else f'Unexpected error: {str(e)}'}{Style.RESET_ALL}")
|
||||
return False
|
||||
|
||||
def main(translator=None):
|
||||
"""Main function to check user authorization"""
|
||||
return run(translator)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
127
config.py
127
config.py
@@ -2,7 +2,9 @@ import os
|
||||
import sys
|
||||
import configparser
|
||||
from colorama import Fore, Style
|
||||
from utils import get_user_documents_path, get_default_chrome_path, get_linux_cursor_path
|
||||
from utils import get_user_documents_path, get_linux_cursor_path, get_default_driver_path, get_default_browser_path
|
||||
import shutil
|
||||
import datetime
|
||||
|
||||
EMOJI = {
|
||||
"INFO": "ℹ️",
|
||||
@@ -16,19 +18,60 @@ EMOJI = {
|
||||
"SETTINGS": "⚙️"
|
||||
}
|
||||
|
||||
# global config cache
|
||||
_config_cache = None
|
||||
|
||||
def setup_config(translator=None):
|
||||
"""Setup configuration file and return config object"""
|
||||
try:
|
||||
config_dir = os.path.join(get_user_documents_path(), ".cursor-free-vip")
|
||||
config_file = os.path.join(config_dir, "config.ini")
|
||||
os.makedirs(config_dir, exist_ok=True)
|
||||
# get documents path
|
||||
docs_path = get_user_documents_path()
|
||||
if not docs_path or not os.path.exists(docs_path):
|
||||
# if documents path not found, use current directory
|
||||
print(f"{Fore.YELLOW}{EMOJI['WARNING']} {translator.get('config.documents_path_not_found', fallback='Documents path not found, using current directory') if translator else 'Documents path not found, using current directory'}{Style.RESET_ALL}")
|
||||
docs_path = os.path.abspath('.')
|
||||
|
||||
# normalize path
|
||||
config_dir = os.path.normpath(os.path.join(docs_path, ".cursor-free-vip"))
|
||||
config_file = os.path.normpath(os.path.join(config_dir, "config.ini"))
|
||||
|
||||
# create config directory, only print message when directory not exists
|
||||
dir_exists = os.path.exists(config_dir)
|
||||
try:
|
||||
os.makedirs(config_dir, exist_ok=True)
|
||||
if not dir_exists: # only print message when directory not exists
|
||||
print(f"{Fore.CYAN}{EMOJI['INFO']} {translator.get('config.config_dir_created', path=config_dir) if translator else f'Config directory created: {config_dir}'}{Style.RESET_ALL}")
|
||||
except Exception as e:
|
||||
# if cannot create directory, use temporary directory
|
||||
import tempfile
|
||||
temp_dir = os.path.normpath(os.path.join(tempfile.gettempdir(), ".cursor-free-vip"))
|
||||
temp_exists = os.path.exists(temp_dir)
|
||||
config_dir = temp_dir
|
||||
config_file = os.path.normpath(os.path.join(config_dir, "config.ini"))
|
||||
os.makedirs(config_dir, exist_ok=True)
|
||||
if not temp_exists: # only print message when temporary directory not exists
|
||||
print(f"{Fore.YELLOW}{EMOJI['WARNING']} {translator.get('config.using_temp_dir', path=config_dir, error=str(e)) if translator else f'Using temporary directory due to error: {config_dir} (Error: {str(e)})'}{Style.RESET_ALL}")
|
||||
|
||||
# create config object
|
||||
config = configparser.ConfigParser()
|
||||
|
||||
# Default configuration
|
||||
default_config = {
|
||||
'Browser': {
|
||||
'default_browser': 'chrome',
|
||||
'chrome_path': get_default_browser_path('chrome'),
|
||||
'edge_path': get_default_browser_path('edge'),
|
||||
'firefox_path': get_default_browser_path('firefox'),
|
||||
'brave_path': get_default_browser_path('brave'),
|
||||
'chrome_driver_path': get_default_driver_path('chrome'),
|
||||
'edge_driver_path': get_default_driver_path('edge'),
|
||||
'firefox_driver_path': get_default_driver_path('firefox'),
|
||||
'brave_driver_path': get_default_driver_path('brave'),
|
||||
'opera_path': get_default_browser_path('opera'),
|
||||
'opera_driver_path': get_default_driver_path('opera')
|
||||
},
|
||||
'Chrome': {
|
||||
'chromepath': get_default_chrome_path()
|
||||
'chromepath': get_default_browser_path('chrome')
|
||||
},
|
||||
'Turnstile': {
|
||||
'handle_turnstile_time': '2',
|
||||
@@ -52,7 +95,17 @@ def setup_config(translator=None):
|
||||
},
|
||||
'Utils': {
|
||||
'enabled_update_check': 'True',
|
||||
'enabled_force_update': 'False',
|
||||
'enabled_account_info': 'True'
|
||||
},
|
||||
'OAuth': {
|
||||
'show_selection_alert': False, # 默认不显示选择提示弹窗
|
||||
'timeout': 120,
|
||||
'max_attempts': 3
|
||||
},
|
||||
'Token': {
|
||||
'refresh_server': 'https://token.cursorpro.com.cn',
|
||||
'enable_refresh': True
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +119,8 @@ def setup_config(translator=None):
|
||||
'machine_id_path': os.path.join(appdata, "Cursor", "machineId"),
|
||||
'cursor_path': os.path.join(localappdata, "Programs", "Cursor", "resources", "app"),
|
||||
'updater_path': os.path.join(localappdata, "cursor-updater"),
|
||||
'update_yml_path': os.path.join(localappdata, "Programs", "Cursor", "resources", "app-update.yml")
|
||||
'update_yml_path': os.path.join(localappdata, "Programs", "Cursor", "resources", "app-update.yml"),
|
||||
'product_json_path': os.path.join(localappdata, "Programs", "Cursor", "resources", "app", "product.json")
|
||||
}
|
||||
# Create storage directory
|
||||
os.makedirs(os.path.dirname(default_config['WindowsPaths']['storage_path']), exist_ok=True)
|
||||
@@ -78,7 +132,8 @@ def setup_config(translator=None):
|
||||
'machine_id_path': os.path.expanduser("~/Library/Application Support/Cursor/machineId"),
|
||||
'cursor_path': "/Applications/Cursor.app/Contents/Resources/app",
|
||||
'updater_path': os.path.expanduser("~/Library/Application Support/cursor-updater"),
|
||||
'update_yml_path': "/Applications/Cursor.app/Contents/Resources/app-update.yml"
|
||||
'update_yml_path': "/Applications/Cursor.app/Contents/Resources/app-update.yml",
|
||||
'product_json_path': "/Applications/Cursor.app/Contents/Resources/app/product.json"
|
||||
}
|
||||
# Create storage directory
|
||||
os.makedirs(os.path.dirname(default_config['MacPaths']['storage_path']), exist_ok=True)
|
||||
@@ -185,7 +240,8 @@ def setup_config(translator=None):
|
||||
'machine_id_path': os.path.join(cursor_dir, "machineid") if cursor_dir else "",
|
||||
'cursor_path': get_linux_cursor_path(),
|
||||
'updater_path': os.path.join(config_base, "cursor-updater"),
|
||||
'update_yml_path': os.path.join(cursor_dir, "resources/app-update.yml") if cursor_dir else ""
|
||||
'update_yml_path': os.path.join(cursor_dir, "resources/app-update.yml") if cursor_dir else "",
|
||||
'product_json_path': os.path.join(cursor_dir, "resources/app/product.json") if cursor_dir else ""
|
||||
}
|
||||
|
||||
# Read existing configuration and merge
|
||||
@@ -254,6 +310,59 @@ def print_config(config, translator=None):
|
||||
|
||||
print()
|
||||
|
||||
def force_update_config(translator=None):
|
||||
"""
|
||||
Force update configuration file with latest defaults if update check is enabled.
|
||||
Args:
|
||||
translator: Translator instance
|
||||
Returns:
|
||||
ConfigParser instance or None if failed
|
||||
"""
|
||||
try:
|
||||
config_dir = os.path.join(get_user_documents_path(), ".cursor-free-vip")
|
||||
config_file = os.path.join(config_dir, "config.ini")
|
||||
current_time = datetime.datetime.now()
|
||||
|
||||
# If the config file exists, check if forced update is enabled
|
||||
if os.path.exists(config_file):
|
||||
# First, read the existing configuration
|
||||
existing_config = configparser.ConfigParser()
|
||||
existing_config.read(config_file, encoding='utf-8')
|
||||
# Check if "enabled_update_check" is True
|
||||
update_enabled = True # Default to True if not set
|
||||
if existing_config.has_section('Utils') and existing_config.has_option('Utils', 'enabled_force_update'):
|
||||
update_enabled = existing_config.get('Utils', 'enabled_force_update').strip().lower() in ('true', 'yes', '1', 'on')
|
||||
|
||||
if update_enabled:
|
||||
try:
|
||||
# Create a backup
|
||||
backup_file = f"{config_file}.bak.{current_time.strftime('%Y%m%d_%H%M%S')}"
|
||||
shutil.copy2(config_file, backup_file)
|
||||
if translator:
|
||||
print(f"\n{Fore.CYAN}{EMOJI['INFO']} {translator.get('config.backup_created', path=backup_file) if translator else f'Backup created: {backup_file}'}{Style.RESET_ALL}")
|
||||
print(f"\n{Fore.CYAN}{EMOJI['INFO']} {translator.get('config.config_force_update_enabled') if translator else 'Config file force update enabled'}{Style.RESET_ALL}")
|
||||
# Delete the original config file (forced update)
|
||||
os.remove(config_file)
|
||||
if translator:
|
||||
print(f"{Fore.CYAN}{EMOJI['INFO']} {translator.get('config.config_removed') if translator else 'Config file removed for forced update'}{Style.RESET_ALL}")
|
||||
except Exception as e:
|
||||
if translator:
|
||||
print(f"{Fore.RED}{EMOJI['ERROR']} {translator.get('config.backup_failed', error=str(e)) if translator else f'Failed to backup config: {str(e)}'}{Style.RESET_ALL}")
|
||||
else:
|
||||
if translator:
|
||||
print(f"\n{Fore.CYAN}{EMOJI['INFO']} {translator.get('config.config_force_update_disabled', fallback='Config file force update disabled by configuration. Keeping existing config file.') if translator else 'Config file force update disabled by configuration. Keeping existing config file.'}{Style.RESET_ALL}")
|
||||
|
||||
# Generate a new (or updated) configuration if needed
|
||||
return setup_config(translator)
|
||||
|
||||
except Exception as e:
|
||||
if translator:
|
||||
print(f"{Fore.RED}{EMOJI['ERROR']} {translator.get('config.force_update_failed', error=str(e)) if translator else f'Force update config failed: {str(e)}'}{Style.RESET_ALL}")
|
||||
return None
|
||||
|
||||
def get_config(translator=None):
|
||||
"""Get existing config or create new one"""
|
||||
return setup_config(translator)
|
||||
global _config_cache
|
||||
if _config_cache is None:
|
||||
_config_cache = setup_config(translator)
|
||||
return _config_cache
|
||||
@@ -4,6 +4,7 @@ import time
|
||||
import random
|
||||
from cursor_auth import CursorAuth
|
||||
from reset_machine_manual import MachineIDResetter
|
||||
from get_user_token import get_token_from_cookie
|
||||
|
||||
os.environ["PYTHONVERBOSE"] = "0"
|
||||
os.environ["PYINSTALLER_VERBOSE"] = "0"
|
||||
@@ -168,7 +169,7 @@ class CursorRegistration:
|
||||
cookies = self.signup_tab.cookies()
|
||||
for cookie in cookies:
|
||||
if cookie.get("name") == "WorkosCursorSessionToken":
|
||||
token = cookie["value"].split("%3A%3A")[1]
|
||||
token = get_token_from_cookie(cookie["value"], self.translator)
|
||||
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} {self.translator.get('register.token_success')}{Style.RESET_ALL}")
|
||||
self._save_account_info(token, total_usage)
|
||||
return True
|
||||
|
||||
@@ -4,6 +4,7 @@ import time
|
||||
import random
|
||||
from cursor_auth import CursorAuth
|
||||
from reset_machine_manual import MachineIDResetter
|
||||
from get_user_token import get_token_from_cookie
|
||||
|
||||
os.environ["PYTHONVERBOSE"] = "0"
|
||||
os.environ["PYINSTALLER_VERBOSE"] = "0"
|
||||
@@ -175,7 +176,7 @@ class CursorRegistration:
|
||||
cookies = self.signup_tab.cookies()
|
||||
for cookie in cookies:
|
||||
if cookie.get("name") == "WorkosCursorSessionToken":
|
||||
token = cookie["value"].split("%3A%3A")[1]
|
||||
token = get_token_from_cookie(cookie["value"], self.translator)
|
||||
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} {self.translator.get('register.token_success')}{Style.RESET_ALL}")
|
||||
self._save_account_info(token, total_usage)
|
||||
return True
|
||||
|
||||
386
delete_cursor_google.py
Normal file
386
delete_cursor_google.py
Normal file
@@ -0,0 +1,386 @@
|
||||
from oauth_auth import OAuthHandler
|
||||
import time
|
||||
from colorama import Fore, Style, init
|
||||
import sys
|
||||
|
||||
# Initialize colorama
|
||||
init()
|
||||
|
||||
# Define emoji constants
|
||||
EMOJI = {
|
||||
'START': '🚀',
|
||||
'DELETE': '🗑️',
|
||||
'SUCCESS': '✅',
|
||||
'ERROR': '❌',
|
||||
'WAIT': '⏳',
|
||||
'INFO': 'ℹ️',
|
||||
'WARNING': '⚠️'
|
||||
}
|
||||
|
||||
class CursorGoogleAccountDeleter(OAuthHandler):
|
||||
def __init__(self, translator=None):
|
||||
super().__init__(translator, auth_type='google')
|
||||
|
||||
def delete_google_account(self):
|
||||
"""Delete Cursor account using Google OAuth"""
|
||||
try:
|
||||
# Setup browser and select profile
|
||||
if not self.setup_browser():
|
||||
return False
|
||||
|
||||
print(f"{Fore.CYAN}{EMOJI['INFO']} {self.translator.get('account_delete.starting_process') if self.translator else 'Starting account deletion process...'}{Style.RESET_ALL}")
|
||||
|
||||
# Navigate to Cursor auth page - using the same URL as in registration
|
||||
self.browser.get("https://authenticator.cursor.sh/sign-up")
|
||||
time.sleep(2)
|
||||
|
||||
# Click Google auth button using same selectors as in registration
|
||||
selectors = [
|
||||
"//a[contains(@href,'GoogleOAuth')]",
|
||||
"//a[contains(@class,'auth-method-button') and contains(@href,'GoogleOAuth')]",
|
||||
"(//a[contains(@class,'auth-method-button')])[1]" # First auth button as fallback
|
||||
]
|
||||
|
||||
auth_btn = None
|
||||
for selector in selectors:
|
||||
try:
|
||||
auth_btn = self.browser.ele(f"xpath:{selector}", timeout=2)
|
||||
if auth_btn:
|
||||
break
|
||||
except:
|
||||
continue
|
||||
|
||||
if not auth_btn:
|
||||
raise Exception(self.translator.get('account_delete.google_button_not_found') if self.translator else "Google login button not found")
|
||||
|
||||
print(f"{Fore.CYAN}{EMOJI['INFO']} {self.translator.get('account_delete.logging_in') if self.translator else 'Logging in with Google...'}{Style.RESET_ALL}")
|
||||
auth_btn.click()
|
||||
|
||||
# Wait for authentication to complete using a more robust method
|
||||
print(f"{Fore.CYAN}{EMOJI['WAIT']} {self.translator.get('account_delete.waiting_for_auth', fallback='Waiting for Google authentication...')}{Style.RESET_ALL}")
|
||||
|
||||
# Dynamic wait for authentication
|
||||
max_wait_time = 120 # Increase maximum wait time to 120 seconds
|
||||
start_time = time.time()
|
||||
check_interval = 3 # Check every 3 seconds
|
||||
google_account_alert_shown = False # Track if we've shown the alert already
|
||||
|
||||
while time.time() - start_time < max_wait_time:
|
||||
current_url = self.browser.url
|
||||
|
||||
# If we're already on the settings or dashboard page, we're successful
|
||||
if "/dashboard" in current_url or "/settings" in current_url or "cursor.com" in current_url:
|
||||
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} {self.translator.get('account_delete.login_successful') if self.translator else 'Login successful'}{Style.RESET_ALL}")
|
||||
break
|
||||
|
||||
# If we're on Google accounts page or accounts.google.com, wait for user selection
|
||||
if "accounts.google.com" in current_url:
|
||||
# Only show the alert once to avoid spamming
|
||||
if not google_account_alert_shown:
|
||||
print(f"{Fore.CYAN}{EMOJI['INFO']} {self.translator.get('account_delete.select_google_account', fallback='Please select your Google account...')}{Style.RESET_ALL}")
|
||||
# Alert to indicate user action needed
|
||||
try:
|
||||
self.browser.run_js("""
|
||||
alert('Please select your Google account to continue with Cursor authentication');
|
||||
""")
|
||||
google_account_alert_shown = True # Mark that we've shown the alert
|
||||
except:
|
||||
pass # Alert is optional
|
||||
|
||||
# Sleep before checking again
|
||||
time.sleep(check_interval)
|
||||
else:
|
||||
# If the loop completed without breaking, it means we hit the timeout
|
||||
print(f"{Fore.YELLOW}{EMOJI['WARNING']} {self.translator.get('account_delete.auth_timeout', fallback='Authentication timeout, continuing anyway...')}{Style.RESET_ALL}")
|
||||
|
||||
# Check current URL to determine next steps
|
||||
current_url = self.browser.url
|
||||
|
||||
# If we're already on the settings page, no need to navigate
|
||||
if "/settings" in current_url and "cursor.com" in current_url:
|
||||
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} {self.translator.get('account_delete.already_on_settings', fallback='Already on settings page')}{Style.RESET_ALL}")
|
||||
# If we're on the dashboard or any Cursor page but not settings, navigate to settings
|
||||
elif "cursor.com" in current_url or "authenticator.cursor.sh" in current_url:
|
||||
print(f"{Fore.CYAN}{EMOJI['INFO']} {self.translator.get('account_delete.navigating_to_settings', fallback='Navigating to settings page...')}{Style.RESET_ALL}")
|
||||
self.browser.get("https://www.cursor.com/settings")
|
||||
# If we're still on Google auth or somewhere else, try directly going to settings
|
||||
else:
|
||||
print(f"{Fore.YELLOW}{EMOJI['WARNING']} {self.translator.get('account_delete.login_redirect_failed', fallback='Login redirection failed, trying direct navigation...')}{Style.RESET_ALL}")
|
||||
self.browser.get("https://www.cursor.com/settings")
|
||||
|
||||
# Wait for the settings page to load
|
||||
time.sleep(3) # Reduced from 5 seconds
|
||||
|
||||
# First look for the email element to confirm we're logged in
|
||||
try:
|
||||
email_element = self.browser.ele("css:div[class='flex w-full flex-col gap-2'] div:nth-child(2) p:nth-child(2)")
|
||||
if email_element:
|
||||
email = email_element.text
|
||||
print(f"{Fore.CYAN}{EMOJI['INFO']} {self.translator.get('account_delete.found_email', email=email, fallback=f'Found email: {email}')}{Style.RESET_ALL}")
|
||||
except Exception as e:
|
||||
print(f"{Fore.YELLOW}{EMOJI['WARNING']} {self.translator.get('account_delete.email_not_found', error=str(e), fallback=f'Email not found: {str(e)}')}{Style.RESET_ALL}")
|
||||
|
||||
# Click on "Advanced" tab or dropdown - keep only the successful approach
|
||||
advanced_found = False
|
||||
|
||||
# Direct JavaScript querySelector approach that worked according to logs
|
||||
try:
|
||||
advanced_element_js = self.browser.run_js("""
|
||||
// Try to find the Advanced dropdown using querySelector with the exact classes
|
||||
let advancedElement = document.querySelector('div.mb-0.flex.cursor-pointer.items-center.text-xs:not([style*="display: none"])');
|
||||
|
||||
// If not found, try a more general approach
|
||||
if (!advancedElement) {
|
||||
const allDivs = document.querySelectorAll('div');
|
||||
for (const div of allDivs) {
|
||||
if (div.textContent.includes('Advanced') &&
|
||||
div.className.includes('mb-0') &&
|
||||
div.className.includes('flex') &&
|
||||
div.className.includes('cursor-pointer')) {
|
||||
advancedElement = div;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Click the element if found
|
||||
if (advancedElement) {
|
||||
advancedElement.click();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
""")
|
||||
|
||||
if advanced_element_js:
|
||||
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} {self.translator.get('account_delete.advanced_tab_clicked', fallback='Found and clicked Advanced using direct JavaScript selector')}{Style.RESET_ALL}")
|
||||
advanced_found = True
|
||||
time.sleep(1) # Reduced from 2 seconds
|
||||
except Exception as e:
|
||||
print(f"{Fore.YELLOW}{EMOJI['WARNING']} {self.translator.get('account_delete.advanced_tab_error', error=str(e), fallback='JavaScript querySelector approach failed: {str(e)}')}{Style.RESET_ALL}")
|
||||
|
||||
if not advanced_found:
|
||||
# Fallback to direct URL navigation which is faster and more reliable
|
||||
try:
|
||||
self.browser.get("https://www.cursor.com/settings?tab=advanced")
|
||||
print(f"{Fore.YELLOW}{EMOJI['INFO']} {self.translator.get('account_delete.direct_advanced_navigation', fallback='Trying direct navigation to advanced tab')}{Style.RESET_ALL}")
|
||||
advanced_found = True
|
||||
except:
|
||||
raise Exception(self.translator.get('account_delete.advanced_tab_not_found') if self.translator else "Advanced option not found after multiple attempts")
|
||||
|
||||
# Wait for dropdown/tab content to load
|
||||
time.sleep(2) # Reduced from 4 seconds
|
||||
|
||||
# Find and click the "Delete Account" button
|
||||
delete_button_found = False
|
||||
|
||||
# Simplified approach for delete button based on what worked
|
||||
delete_button_selectors = [
|
||||
'xpath://button[contains(., "Delete Account")]',
|
||||
'xpath://button[text()="Delete Account"]',
|
||||
'xpath://div[contains(text(), "Delete Account")]',
|
||||
'xpath://button[contains(text(), "Delete") and contains(text(), "Account")]'
|
||||
]
|
||||
|
||||
for selector in delete_button_selectors:
|
||||
try:
|
||||
delete_button = self.browser.ele(selector, timeout=2)
|
||||
if delete_button:
|
||||
delete_button.click()
|
||||
print(f"{Fore.CYAN}{EMOJI['INFO']} {self.translator.get('account_delete.delete_button_clicked') if self.translator else 'Clicked on Delete Account button'}{Style.RESET_ALL}")
|
||||
delete_button_found = True
|
||||
break
|
||||
except:
|
||||
continue
|
||||
|
||||
if not delete_button_found:
|
||||
raise Exception(self.translator.get('account_delete.delete_button_not_found') if self.translator else "Delete Account button not found")
|
||||
|
||||
# Wait for confirmation dialog to appear
|
||||
time.sleep(2)
|
||||
|
||||
# Check if we need to input "Delete" at all - some modals might not require it
|
||||
input_required = True
|
||||
try:
|
||||
# Try detecting if the DELETE button is already enabled
|
||||
delete_button_enabled = self.browser.run_js("""
|
||||
const buttons = Array.from(document.querySelectorAll('button'));
|
||||
const deleteButtons = buttons.filter(btn =>
|
||||
btn.textContent.trim() === 'DELETE' ||
|
||||
btn.textContent.trim() === 'Delete'
|
||||
);
|
||||
|
||||
if (deleteButtons.length > 0) {
|
||||
return !deleteButtons.some(btn => btn.disabled);
|
||||
}
|
||||
return false;
|
||||
""")
|
||||
|
||||
if delete_button_enabled:
|
||||
print(f"{Fore.CYAN}{EMOJI['INFO']} DELETE button appears to be enabled already. Input may not be required.{Style.RESET_ALL}")
|
||||
input_required = False
|
||||
except:
|
||||
pass
|
||||
|
||||
# Type "Delete" in the confirmation input - only if required
|
||||
delete_input_found = False
|
||||
|
||||
if input_required:
|
||||
# Try common selectors for the input field
|
||||
delete_input_selectors = [
|
||||
'xpath://input[@placeholder="Delete"]',
|
||||
'xpath://div[contains(@class, "modal")]//input',
|
||||
'xpath://input',
|
||||
'css:input'
|
||||
]
|
||||
|
||||
for selector in delete_input_selectors:
|
||||
try:
|
||||
delete_input = self.browser.ele(selector, timeout=3)
|
||||
if delete_input:
|
||||
delete_input.clear()
|
||||
delete_input.input("Delete")
|
||||
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} {self.translator.get('account_delete.typed_delete', fallback='Typed \"Delete\" in confirmation box')}{Style.RESET_ALL}")
|
||||
delete_input_found = True
|
||||
time.sleep(2)
|
||||
break
|
||||
except:
|
||||
# Try direct JavaScript input as fallback
|
||||
try:
|
||||
self.browser.run_js(f"""
|
||||
arguments[0].value = "Delete";
|
||||
const event = new Event('input', {{ bubbles: true }});
|
||||
arguments[0].dispatchEvent(event);
|
||||
const changeEvent = new Event('change', {{ bubbles: true }});
|
||||
arguments[0].dispatchEvent(changeEvent);
|
||||
""", delete_input)
|
||||
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} {self.translator.get('account_delete.typed_delete_js', fallback='Typed \"Delete\" using JavaScript')}{Style.RESET_ALL}")
|
||||
delete_input_found = True
|
||||
time.sleep(2)
|
||||
break
|
||||
except:
|
||||
continue
|
||||
|
||||
if not delete_input_found:
|
||||
print(f"{Fore.YELLOW}{EMOJI['WARNING']} {self.translator.get('account_delete.delete_input_not_found', fallback='Delete confirmation input not found, continuing anyway')}{Style.RESET_ALL}")
|
||||
time.sleep(2)
|
||||
|
||||
# Wait before clicking the final DELETE button
|
||||
time.sleep(2)
|
||||
|
||||
# Click on the final DELETE button
|
||||
confirm_button_found = False
|
||||
|
||||
# Use JavaScript approach for the DELETE button
|
||||
try:
|
||||
delete_button_js = self.browser.run_js("""
|
||||
// Try to find the DELETE button by exact text content
|
||||
const buttons = Array.from(document.querySelectorAll('button'));
|
||||
const deleteButton = buttons.find(btn =>
|
||||
btn.textContent.trim() === 'DELETE' ||
|
||||
btn.textContent.trim() === 'Delete'
|
||||
);
|
||||
|
||||
if (deleteButton) {
|
||||
console.log("Found DELETE button with JavaScript");
|
||||
deleteButton.click();
|
||||
return true;
|
||||
}
|
||||
|
||||
// If not found by text, try to find right-most button in the modal
|
||||
const modalButtons = Array.from(document.querySelectorAll('.relative button, [role="dialog"] button, .modal button, [aria-modal="true"] button'));
|
||||
|
||||
if (modalButtons.length > 1) {
|
||||
modalButtons.sort((a, b) => {
|
||||
const rectA = a.getBoundingClientRect();
|
||||
const rectB = b.getBoundingClientRect();
|
||||
return rectB.right - rectA.right;
|
||||
});
|
||||
|
||||
console.log("Clicking right-most button in modal");
|
||||
modalButtons[0].click();
|
||||
return true;
|
||||
} else if (modalButtons.length === 1) {
|
||||
console.log("Clicking single button found in modal");
|
||||
modalButtons[0].click();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
""")
|
||||
|
||||
if delete_button_js:
|
||||
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} {self.translator.get('account_delete.delete_button_clicked', fallback='Clicked DELETE button')}{Style.RESET_ALL}")
|
||||
confirm_button_found = True
|
||||
except:
|
||||
pass
|
||||
|
||||
if not confirm_button_found:
|
||||
# Fallback to simple selectors
|
||||
delete_button_selectors = [
|
||||
'xpath://button[text()="DELETE"]',
|
||||
'xpath://div[contains(@class, "modal")]//button[last()]'
|
||||
]
|
||||
|
||||
for selector in delete_button_selectors:
|
||||
try:
|
||||
delete_button = self.browser.ele(selector, timeout=2)
|
||||
if delete_button:
|
||||
delete_button.click()
|
||||
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} {self.translator.get('account_delete.delete_button_clicked', fallback='Account deleted successfully!')}{Style.RESET_ALL}")
|
||||
confirm_button_found = True
|
||||
break
|
||||
except:
|
||||
continue
|
||||
|
||||
if not confirm_button_found:
|
||||
raise Exception(self.translator.get('account_delete.confirm_button_not_found') if self.translator else "Confirm button not found")
|
||||
|
||||
# Wait a moment to see the confirmation
|
||||
time.sleep(2)
|
||||
|
||||
return True
|
||||
|
||||
except Exception as e:
|
||||
print(f"{Fore.RED}{EMOJI['ERROR']} {self.translator.get('account_delete.error', error=str(e)) if self.translator else f'Error during account deletion: {str(e)}'}{Style.RESET_ALL}")
|
||||
return False
|
||||
finally:
|
||||
# Clean up browser
|
||||
if self.browser:
|
||||
try:
|
||||
self.browser.quit()
|
||||
except:
|
||||
pass
|
||||
|
||||
def main(translator=None):
|
||||
"""Main function to handle Google account deletion"""
|
||||
print(f"\n{Fore.CYAN}{EMOJI['START']} {translator.get('account_delete.title') if translator else 'Cursor Google Account Deletion Tool'}{Style.RESET_ALL}")
|
||||
print(f"{Fore.YELLOW}{'─' * 50}{Style.RESET_ALL}")
|
||||
|
||||
deleter = CursorGoogleAccountDeleter(translator)
|
||||
|
||||
try:
|
||||
# Ask for confirmation
|
||||
print(f"{Fore.RED}{EMOJI['WARNING']} {translator.get('account_delete.warning') if translator else 'WARNING: This will permanently delete your Cursor account. This action cannot be undone.'}{Style.RESET_ALL}")
|
||||
confirm = input(f"{Fore.RED} {translator.get('account_delete.confirm_prompt') if translator else 'Are you sure you want to proceed? (y/N): '}{Style.RESET_ALL}").lower()
|
||||
|
||||
if confirm != 'y':
|
||||
print(f"{Fore.YELLOW}{EMOJI['INFO']} {translator.get('account_delete.cancelled') if translator else 'Account deletion cancelled.'}{Style.RESET_ALL}")
|
||||
return
|
||||
|
||||
success = deleter.delete_google_account()
|
||||
|
||||
if success:
|
||||
print(f"\n{Fore.GREEN}{EMOJI['SUCCESS']} {translator.get('account_delete.success') if translator else 'Your Cursor account has been successfully deleted!'}{Style.RESET_ALL}")
|
||||
else:
|
||||
print(f"\n{Fore.RED}{EMOJI['ERROR']} {translator.get('account_delete.failed') if translator else 'Account deletion process failed or was cancelled.'}{Style.RESET_ALL}")
|
||||
|
||||
except KeyboardInterrupt:
|
||||
print(f"\n{Fore.YELLOW}{EMOJI['INFO']} {translator.get('account_delete.interrupted') if translator else 'Account deletion process interrupted by user.'}{Style.RESET_ALL}")
|
||||
except Exception as e:
|
||||
print(f"{Fore.RED}{EMOJI['ERROR']} {translator.get('account_delete.unexpected_error', error=str(e)) if translator else f'Unexpected error: {str(e)}'}{Style.RESET_ALL}")
|
||||
finally:
|
||||
print(f"{Fore.YELLOW}{'─' * 50}{Style.RESET_ALL}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -34,12 +34,15 @@ class AutoUpdateDisabler:
|
||||
if self.system == "Windows":
|
||||
self.updater_path = config.get('WindowsPaths', 'updater_path', fallback=os.path.join(os.getenv("LOCALAPPDATA", ""), "cursor-updater"))
|
||||
self.update_yml_path = config.get('WindowsPaths', 'update_yml_path', fallback=os.path.join(os.getenv("LOCALAPPDATA", ""), "Programs", "Cursor", "resources", "app", "update.yml"))
|
||||
self.product_json_path = config.get('WindowsPaths', 'product_json_path', fallback=os.path.join(os.getenv("LOCALAPPDATA", ""), "Programs", "Cursor", "resources", "app", "product.json"))
|
||||
elif self.system == "Darwin":
|
||||
self.updater_path = config.get('MacPaths', 'updater_path', fallback=os.path.expanduser("~/Library/Application Support/cursor-updater"))
|
||||
self.update_yml_path = config.get('MacPaths', 'update_yml_path', fallback="/Applications/Cursor.app/Contents/Resources/app-update.yml")
|
||||
self.product_json_path = config.get('MacPaths', 'product_json_path', fallback="/Applications/Cursor.app/Contents/Resources/app/product.json")
|
||||
elif self.system == "Linux":
|
||||
self.updater_path = config.get('LinuxPaths', 'updater_path', fallback=os.path.expanduser("~/.config/cursor-updater"))
|
||||
self.update_yml_path = config.get('LinuxPaths', 'update_yml_path', fallback=os.path.expanduser("~/.config/cursor/resources/app-update.yml"))
|
||||
self.product_json_path = config.get('LinuxPaths', 'product_json_path', fallback=os.path.expanduser("~/.config/cursor/resources/app/product.json"))
|
||||
else:
|
||||
# If configuration loading fails, use default paths
|
||||
self.updater_paths = {
|
||||
@@ -56,21 +59,29 @@ class AutoUpdateDisabler:
|
||||
}
|
||||
self.update_yml_path = self.update_yml_paths.get(self.system)
|
||||
|
||||
def _change_main_js(self):
|
||||
"""Change main.js"""
|
||||
self.product_json_paths = {
|
||||
"Windows": os.path.join(os.getenv("LOCALAPPDATA", ""), "Programs", "Cursor", "resources", "app", "product.json"),
|
||||
"Darwin": "/Applications/Cursor.app/Contents/Resources/app/product.json",
|
||||
"Linux": os.path.expanduser("~/.config/cursor/resources/app/product.json")
|
||||
}
|
||||
self.product_json_path = self.product_json_paths.get(self.system)
|
||||
|
||||
def _remove_update_url(self):
|
||||
"""Remove update URL"""
|
||||
try:
|
||||
main_path = get_config(self.translator).get('main_js_path', fallback=os.path.expanduser("~/.config/cursor/resources/app/main.js"))
|
||||
original_stat = os.stat(main_path)
|
||||
original_stat = os.stat(self.product_json_path)
|
||||
original_mode = original_stat.st_mode
|
||||
original_uid = original_stat.st_uid
|
||||
original_gid = original_stat.st_gid
|
||||
|
||||
with tempfile.NamedTemporaryFile(mode="w", delete=False) as tmp_file:
|
||||
with open(main_path, "r", encoding="utf-8") as main_file:
|
||||
content = main_file.read()
|
||||
with open(self.product_json_path, "r", encoding="utf-8") as product_json_file:
|
||||
content = product_json_file.read()
|
||||
|
||||
patterns = {
|
||||
r"https://api2.cursor.sh/aiserver.v1.AuthService/DownloadUpdate": r"",
|
||||
r"https://api2.cursor.sh/updates": r"",
|
||||
r"http://cursorapi.com/updates": r"",
|
||||
}
|
||||
|
||||
for pattern, replacement in patterns.items():
|
||||
@@ -79,12 +90,12 @@ class AutoUpdateDisabler:
|
||||
tmp_file.write(content)
|
||||
tmp_path = tmp_file.name
|
||||
|
||||
shutil.copy2(main_path, main_path + ".old")
|
||||
shutil.move(tmp_path, main_path)
|
||||
shutil.copy2(self.product_json_path, self.product_json_path + ".old")
|
||||
shutil.move(tmp_path, self.product_json_path)
|
||||
|
||||
os.chmod(main_path, original_mode)
|
||||
os.chmod(self.product_json_path, original_mode)
|
||||
if os.name != "nt":
|
||||
os.chown(main_path, original_uid, original_gid)
|
||||
os.chown(self.product_json_path, original_uid, original_gid)
|
||||
|
||||
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} {self.translator.get('reset.file_modified')}{Style.RESET_ALL}")
|
||||
return True
|
||||
@@ -122,17 +133,18 @@ class AutoUpdateDisabler:
|
||||
print(f"{Fore.CYAN}{EMOJI['FOLDER']} {self.translator.get('update.removing_directory') if self.translator else '正在删除更新程序目录...'}{Style.RESET_ALL}")
|
||||
|
||||
if os.path.exists(updater_path):
|
||||
if os.path.isdir(updater_path):
|
||||
shutil.rmtree(updater_path)
|
||||
else:
|
||||
os.remove(updater_path)
|
||||
|
||||
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} {self.translator.get('update.directory_removed') if self.translator else '更新程序目录已删除'}{Style.RESET_ALL}")
|
||||
try:
|
||||
if os.path.isdir(updater_path):
|
||||
shutil.rmtree(updater_path)
|
||||
else:
|
||||
os.remove(updater_path)
|
||||
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} {self.translator.get('update.directory_removed') if self.translator else '更新程序目录已删除'}{Style.RESET_ALL}")
|
||||
except PermissionError:
|
||||
print(f"{Fore.YELLOW}{EMOJI['INFO']} {self.translator.get('update.directory_locked', path=updater_path) if self.translator else f'更新程序目录已被锁定,跳过删除: {updater_path}'}{Style.RESET_ALL}")
|
||||
return True
|
||||
|
||||
except Exception as e:
|
||||
print(f"{Fore.RED}{EMOJI['ERROR']} {self.translator.get('update.remove_directory_failed', error=str(e)) if self.translator else f'删除目录失败: {e}'}{Style.RESET_ALL}")
|
||||
# 即使删除失败,也返回 True,继续执行下一步
|
||||
return True
|
||||
|
||||
def _clear_update_yml_file(self):
|
||||
@@ -145,15 +157,15 @@ class AutoUpdateDisabler:
|
||||
print(f"{Fore.CYAN}{EMOJI['FILE']} {self.translator.get('update.clearing_update_yml') if self.translator else '正在清空更新配置文件...'}{Style.RESET_ALL}")
|
||||
|
||||
if os.path.exists(update_yml_path):
|
||||
# 清空文件内容
|
||||
with open(update_yml_path, 'w') as f:
|
||||
f.write('')
|
||||
|
||||
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} {self.translator.get('update.update_yml_cleared') if self.translator else '更新配置文件已清空'}{Style.RESET_ALL}")
|
||||
return True
|
||||
try:
|
||||
with open(update_yml_path, 'w') as f:
|
||||
f.write('')
|
||||
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} {self.translator.get('update.update_yml_cleared') if self.translator else '更新配置文件已清空'}{Style.RESET_ALL}")
|
||||
except PermissionError:
|
||||
print(f"{Fore.YELLOW}{EMOJI['INFO']} {self.translator.get('update.yml_locked') if self.translator else '更新配置文件已被锁定,跳过清空'}{Style.RESET_ALL}")
|
||||
else:
|
||||
print(f"{Fore.YELLOW}{EMOJI['INFO']} {self.translator.get('update.update_yml_not_found') if self.translator else '更新配置文件不存在'}{Style.RESET_ALL}")
|
||||
return True
|
||||
return True
|
||||
|
||||
except Exception as e:
|
||||
print(f"{Fore.RED}{EMOJI['ERROR']} {self.translator.get('update.clear_update_yml_failed', error=str(e)) if self.translator else f'清空更新配置文件失败: {e}'}{Style.RESET_ALL}")
|
||||
@@ -170,37 +182,43 @@ class AutoUpdateDisabler:
|
||||
print(f"{Fore.CYAN}{EMOJI['FILE']} {self.translator.get('update.creating_block_file') if self.translator else '正在创建阻止文件...'}{Style.RESET_ALL}")
|
||||
|
||||
# 创建 updater_path 阻止文件
|
||||
os.makedirs(os.path.dirname(updater_path), exist_ok=True)
|
||||
open(updater_path, 'w').close()
|
||||
|
||||
# 设置 updater_path 为只读
|
||||
if self.system == "Windows":
|
||||
os.system(f'attrib +r "{updater_path}"')
|
||||
else:
|
||||
os.chmod(updater_path, 0o444) # 设置为只读
|
||||
|
||||
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} {self.translator.get('update.block_file_created') if self.translator else '阻止文件已创建'}: {updater_path}{Style.RESET_ALL}")
|
||||
try:
|
||||
os.makedirs(os.path.dirname(updater_path), exist_ok=True)
|
||||
open(updater_path, 'w').close()
|
||||
|
||||
# 设置 updater_path 为只读
|
||||
if self.system == "Windows":
|
||||
os.system(f'attrib +r "{updater_path}"')
|
||||
else:
|
||||
os.chmod(updater_path, 0o444) # 设置为只读
|
||||
|
||||
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} {self.translator.get('update.block_file_created') if self.translator else '阻止文件已创建'}: {updater_path}{Style.RESET_ALL}")
|
||||
except PermissionError:
|
||||
print(f"{Fore.YELLOW}{EMOJI['INFO']} {self.translator.get('update.block_file_locked') if self.translator else '阻止文件已被锁定,跳过创建'}{Style.RESET_ALL}")
|
||||
|
||||
# 检查 update_yml_path
|
||||
update_yml_path = self.update_yml_path
|
||||
if update_yml_path and os.path.exists(os.path.dirname(update_yml_path)):
|
||||
# 创建 update_yml_path 阻止文件
|
||||
with open(update_yml_path, 'w') as f:
|
||||
f.write('# This file is locked to prevent auto-updates\nversion: 0.0.0\n')
|
||||
|
||||
# 设置 update_yml_path 为只读
|
||||
if self.system == "Windows":
|
||||
os.system(f'attrib +r "{update_yml_path}"')
|
||||
else:
|
||||
os.chmod(update_yml_path, 0o444) # 设置为只读
|
||||
|
||||
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} {self.translator.get('update.yml_locked') if self.translator else '更新配置文件已锁定'}: {update_yml_path}{Style.RESET_ALL}")
|
||||
try:
|
||||
# 创建 update_yml_path 阻止文件
|
||||
with open(update_yml_path, 'w') as f:
|
||||
f.write('# This file is locked to prevent auto-updates\nversion: 0.0.0\n')
|
||||
|
||||
# 设置 update_yml_path 为只读
|
||||
if self.system == "Windows":
|
||||
os.system(f'attrib +r "{update_yml_path}"')
|
||||
else:
|
||||
os.chmod(update_yml_path, 0o444) # 设置为只读
|
||||
|
||||
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} {self.translator.get('update.yml_locked') if self.translator else '更新配置文件已锁定'}: {update_yml_path}{Style.RESET_ALL}")
|
||||
except PermissionError:
|
||||
print(f"{Fore.YELLOW}{EMOJI['INFO']} {self.translator.get('update.yml_already_locked') if self.translator else '更新配置文件已被锁定,跳过修改'}{Style.RESET_ALL}")
|
||||
|
||||
return True
|
||||
|
||||
except Exception as e:
|
||||
print(f"{Fore.RED}{EMOJI['ERROR']} {self.translator.get('update.create_block_file_failed', error=str(e)) if self.translator else f'创建阻止文件失败: {e}'}{Style.RESET_ALL}")
|
||||
return False
|
||||
return True # 返回 True 以继续执行后续步骤
|
||||
|
||||
def disable_auto_update(self):
|
||||
"""Disable auto update"""
|
||||
@@ -222,8 +240,8 @@ class AutoUpdateDisabler:
|
||||
if not self._create_blocking_file():
|
||||
return False
|
||||
|
||||
# 5. Change main.js
|
||||
if not self._change_main_js():
|
||||
# 5. Remove update URL from product.json
|
||||
if not self._remove_update_url():
|
||||
return False
|
||||
|
||||
print(f"{Fore.GREEN}{EMOJI['CHECK']} {self.translator.get('update.disable_success') if self.translator else '自动更新已禁用'}{Style.RESET_ALL}")
|
||||
|
||||
112
get_user_token.py
Normal file
112
get_user_token.py
Normal file
@@ -0,0 +1,112 @@
|
||||
import requests
|
||||
import json
|
||||
import time
|
||||
from colorama import Fore, Style
|
||||
import os
|
||||
from config import get_config
|
||||
|
||||
# Define emoji constants
|
||||
EMOJI = {
|
||||
'START': '🚀',
|
||||
'OAUTH': '🔑',
|
||||
'SUCCESS': '✅',
|
||||
'ERROR': '❌',
|
||||
'WAIT': '⏳',
|
||||
'INFO': 'ℹ️',
|
||||
'WARNING': '⚠️'
|
||||
}
|
||||
|
||||
def refresh_token(token, translator=None):
|
||||
"""Refresh the token using the Chinese server API
|
||||
|
||||
Args:
|
||||
token (str): The full WorkosCursorSessionToken cookie value
|
||||
translator: Optional translator object
|
||||
|
||||
Returns:
|
||||
str: The refreshed access token or original token if refresh fails
|
||||
"""
|
||||
try:
|
||||
config = get_config(translator)
|
||||
# Get refresh_server URL from config or use default
|
||||
refresh_server = config.get('Token', 'refresh_server', fallback='https://token.cursorpro.com.cn')
|
||||
|
||||
# Ensure the token is URL encoded properly
|
||||
if '%3A%3A' not in token and '::' in token:
|
||||
# Replace :: with URL encoded version if needed
|
||||
token = token.replace('::', '%3A%3A')
|
||||
|
||||
# Make the request to the refresh server
|
||||
url = f"{refresh_server}/reftoken?token={token}"
|
||||
|
||||
print(f"{Fore.CYAN}{EMOJI['INFO']} {translator.get('token.refreshing') if translator else 'Refreshing token...'}{Style.RESET_ALL}")
|
||||
|
||||
response = requests.get(url, timeout=30)
|
||||
|
||||
if response.status_code == 200:
|
||||
try:
|
||||
data = response.json()
|
||||
|
||||
if data.get('code') == 0 and data.get('msg') == "获取成功":
|
||||
access_token = data.get('data', {}).get('accessToken')
|
||||
days_left = data.get('data', {}).get('days_left', 0)
|
||||
expire_time = data.get('data', {}).get('expire_time', 'Unknown')
|
||||
|
||||
if access_token:
|
||||
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} {translator.get('token.refresh_success', days=days_left, expire=expire_time) if translator else f'Token refreshed successfully! Valid for {days_left} days (expires: {expire_time})'}{Style.RESET_ALL}")
|
||||
return access_token
|
||||
else:
|
||||
print(f"{Fore.YELLOW}{EMOJI['WARNING']} {translator.get('token.no_access_token') if translator else 'No access token in response'}{Style.RESET_ALL}")
|
||||
else:
|
||||
error_msg = data.get('msg', 'Unknown error')
|
||||
print(f"{Fore.RED}{EMOJI['ERROR']} {translator.get('token.refresh_failed', error=error_msg) if translator else f'Token refresh failed: {error_msg}'}{Style.RESET_ALL}")
|
||||
except json.JSONDecodeError:
|
||||
print(f"{Fore.RED}{EMOJI['ERROR']} {translator.get('token.invalid_response') if translator else 'Invalid JSON response from refresh server'}{Style.RESET_ALL}")
|
||||
else:
|
||||
print(f"{Fore.RED}{EMOJI['ERROR']} {translator.get('token.server_error', status=response.status_code) if translator else f'Refresh server error: HTTP {response.status_code}'}{Style.RESET_ALL}")
|
||||
|
||||
except requests.exceptions.Timeout:
|
||||
print(f"{Fore.RED}{EMOJI['ERROR']} {translator.get('token.request_timeout') if translator else 'Request to refresh server timed out'}{Style.RESET_ALL}")
|
||||
except requests.exceptions.ConnectionError:
|
||||
print(f"{Fore.RED}{EMOJI['ERROR']} {translator.get('token.connection_error') if translator else 'Connection error to refresh server'}{Style.RESET_ALL}")
|
||||
except Exception as e:
|
||||
print(f"{Fore.RED}{EMOJI['ERROR']} {translator.get('token.unexpected_error', error=str(e)) if translator else f'Unexpected error during token refresh: {str(e)}'}{Style.RESET_ALL}")
|
||||
|
||||
# Return original token if refresh fails
|
||||
return token.split('%3A%3A')[-1] if '%3A%3A' in token else token.split('::')[-1] if '::' in token else token
|
||||
|
||||
def get_token_from_cookie(cookie_value, translator=None):
|
||||
"""Extract and process token from cookie value
|
||||
|
||||
Args:
|
||||
cookie_value (str): The WorkosCursorSessionToken cookie value
|
||||
translator: Optional translator object
|
||||
|
||||
Returns:
|
||||
str: The processed token
|
||||
"""
|
||||
try:
|
||||
# Try to refresh the token with the API first
|
||||
refreshed_token = refresh_token(cookie_value, translator)
|
||||
|
||||
# If refresh succeeded and returned a different token, use it
|
||||
if refreshed_token and refreshed_token != cookie_value:
|
||||
return refreshed_token
|
||||
|
||||
# If refresh failed or returned same token, use traditional extraction method
|
||||
if '%3A%3A' in cookie_value:
|
||||
return cookie_value.split('%3A%3A')[-1]
|
||||
elif '::' in cookie_value:
|
||||
return cookie_value.split('::')[-1]
|
||||
else:
|
||||
return cookie_value
|
||||
|
||||
except Exception as e:
|
||||
print(f"{Fore.RED}{EMOJI['ERROR']} {translator.get('token.extraction_error', error=str(e)) if translator else f'Error extracting token: {str(e)}'}{Style.RESET_ALL}")
|
||||
# Fall back to original behavior
|
||||
if '%3A%3A' in cookie_value:
|
||||
return cookie_value.split('%3A%3A')[-1]
|
||||
elif '::' in cookie_value:
|
||||
return cookie_value.split('::')[-1]
|
||||
else:
|
||||
return cookie_value
|
||||
BIN
images/pro_2025-04-05_18-47-56.png
Normal file
BIN
images/pro_2025-04-05_18-47-56.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 76 KiB |
@@ -388,5 +388,17 @@
|
||||
"electron_localstorage_files_removed": "Electron localStorage файлове бяха премахнати",
|
||||
"electron_localstorage_files_removal_error": "Грешка при премахване на Electron localStorage файлове: {error}",
|
||||
"removing_electron_localstorage_files_completed": "Премахването на Electron localStorage файлове беше завършено"
|
||||
},
|
||||
"chrome_profile": {
|
||||
"title": "Избор на Chrome Профил",
|
||||
"select_profile": "Изберете Chrome профил за използване:",
|
||||
"profile_list": "Налични профили:",
|
||||
"default_profile": "Профил по Подразбиране",
|
||||
"profile": "Профил {number}",
|
||||
"no_profiles": "Не са намерени Chrome профили",
|
||||
"error_loading": "Грешка при зареждане на Chrome профили: {error}",
|
||||
"profile_selected": "Избран профил: {profile}",
|
||||
"invalid_selection": "Невалиден избор. Моля, опитайте отново",
|
||||
"warning_chrome_close": "Предупреждение: Това ще затвори всички работещи Chrome процеси"
|
||||
}
|
||||
}
|
||||
@@ -6,10 +6,11 @@
|
||||
"register": "Neues Cursor-Konto Registrieren",
|
||||
"register_google": "Mit Google-Konto Registrieren",
|
||||
"register_github": "Mit GitHub-Konto Registrieren",
|
||||
"register_manual": "Cursor mit Benutzerdefinierter E-Mail Registrieren",
|
||||
"register_manual": "Cursor Mit Benutzerdefinierter E-Mail Registrieren",
|
||||
"quit": "Cursor-Anwendung Schließen",
|
||||
"select_language": "Sprache Ändern",
|
||||
"input_choice": "Bitte Auswahl eingeben ({choices})",
|
||||
"select_chrome_profile": "Chrome-Profil Auswählen",
|
||||
"input_choice": "Bitte geben Sie Ihre Auswahl ein ({choices})",
|
||||
"invalid_choice": "Ungültige Auswahl. Bitte eine Nummer von {choices} eingeben",
|
||||
"program_terminated": "Programm wurde vom Benutzer beendet",
|
||||
"error_occurred": "Ein Fehler ist aufgetreten: {error}. Bitte erneut versuchen",
|
||||
@@ -376,5 +377,17 @@
|
||||
"electron_localstorage_files_removed": "Electron localStorage-Dateien entfernt",
|
||||
"electron_localstorage_files_removal_error": "Fehler beim Entfernen von Electron localStorage-Dateien: {error}",
|
||||
"removing_electron_localstorage_files_completed": "Entfernen von Electron localStorage-Dateien abgeschlossen"
|
||||
},
|
||||
"chrome_profile": {
|
||||
"title": "Chrome-Profil Auswahl",
|
||||
"select_profile": "Wählen Sie ein Chrome-Profil zum Verwenden:",
|
||||
"profile_list": "Verfügbare Profile:",
|
||||
"default_profile": "Standard-Profil",
|
||||
"profile": "Profil {number}",
|
||||
"no_profiles": "Keine Chrome-Profile gefunden",
|
||||
"error_loading": "Fehler beim Laden der Chrome-Profile: {error}",
|
||||
"profile_selected": "Ausgewähltes Profil: {profile}",
|
||||
"invalid_selection": "Ungültige Auswahl. Bitte versuchen Sie es erneut",
|
||||
"warning_chrome_close": "Warnung: Dies wird alle laufenden Chrome-Prozesse beenden"
|
||||
}
|
||||
}
|
||||
201
locales/en.json
201
locales/en.json
@@ -9,6 +9,7 @@
|
||||
"register_manual": "Register Cursor with Custom Email",
|
||||
"quit": "Close Cursor Application",
|
||||
"select_language": "Change Language",
|
||||
"select_chrome_profile": "Select Chrome Profile",
|
||||
"input_choice": "Please enter your choice ({choices})",
|
||||
"invalid_choice": "Invalid selection. Please enter a number from {choices}",
|
||||
"program_terminated": "Program was terminated by user",
|
||||
@@ -24,7 +25,14 @@
|
||||
"coming_soon": "Coming Soon",
|
||||
"fixed_soon": "Fixed Soon",
|
||||
"contribute": "Contribute to the Project",
|
||||
"config": "Show Config"
|
||||
"config": "Show Config",
|
||||
"delete_google_account": "Delete Cursor Google Account",
|
||||
"continue_prompt": "Continue? (y/N): ",
|
||||
"operation_cancelled_by_user": "Operation cancelled by user",
|
||||
"exiting": "Exiting ……",
|
||||
"bypass_version_check": "Bypass Cursor Version Check",
|
||||
"check_user_authorized": "Check User Authorized",
|
||||
"bypass_token_limit": "Bypass Token Limit"
|
||||
},
|
||||
"languages": {
|
||||
"en": "English",
|
||||
@@ -111,7 +119,8 @@
|
||||
"modify_file_failed": "Modify File Failed: {error}",
|
||||
"windows_machine_id_updated": "Windows Machine ID Updated Successfully",
|
||||
"update_windows_machine_id_failed": "Update Windows Machine ID Failed: {error}",
|
||||
"update_windows_machine_guid_failed": "Update Windows Machine GUID Failed: {error}"
|
||||
"update_windows_machine_guid_failed": "Update Windows Machine GUID Failed: {error}",
|
||||
"file_not_found": "File Not Found: {path}"
|
||||
},
|
||||
"register": {
|
||||
"title": "Cursor Registration Tool",
|
||||
@@ -190,7 +199,15 @@
|
||||
"setting_on_password": "Setting Password",
|
||||
"getting_code": "Getting Verification Code, Will Try in 60s",
|
||||
"human_verify_error": "Can't verify the user is human. Retrying...",
|
||||
"max_retries_reached": "Maximum retry attempts reached. Registration failed."
|
||||
"max_retries_reached": "Maximum retry attempts reached. Registration failed.",
|
||||
"browser_path_invalid": "{browser} path is invalid, using default path",
|
||||
"using_browser": "Using {browser} browser: {path}",
|
||||
"using_browser_profile": "Using {browser} profile from: {user_data_dir}",
|
||||
"make_sure_browser_is_properly_installed": "Make sure {browser} is properly installed",
|
||||
"try_install_browser": "Try installing the browser with your package manager",
|
||||
"tracking_processes": "Tracking {count} {browser} processes",
|
||||
"no_new_processes_detected": "No new {browser} processes detected to track",
|
||||
"could_not_track_processes": "Could not track {browser} processes: {error}"
|
||||
},
|
||||
"auth": {
|
||||
"title": "Cursor Auth Manager",
|
||||
@@ -306,7 +323,16 @@
|
||||
"clear_update_yml_failed": "Failed to clear update.yml file: {error}",
|
||||
"unsupported_os": "Unsupported OS: {system}",
|
||||
"remove_directory_failed": "Failed to remove directory: {error}",
|
||||
"create_block_file_failed": "Failed to create block file: {error}"
|
||||
"create_block_file_failed": "Failed to create block file: {error}",
|
||||
"directory_locked": "Directory is locked: {path}",
|
||||
"yml_locked": "update.yml file is locked",
|
||||
"block_file_locked": "block file is locked",
|
||||
"yml_already_locked": "update.yml file is already locked",
|
||||
"block_file_already_locked": "block file is already locked",
|
||||
"block_file_locked_error": "Block file locked error: {error}",
|
||||
"yml_locked_error": "update.yml file locked error: {error}",
|
||||
"block_file_already_locked_error": "Block file already locked error: {error}",
|
||||
"yml_already_locked_error": "update.yml file already locked error: {error}"
|
||||
},
|
||||
"updater": {
|
||||
"checking": "Checking for updates...",
|
||||
@@ -432,7 +458,24 @@
|
||||
"cursor_reset_completed": "Cursor AI Editor has been fully reset and trial detection bypassed!",
|
||||
"cursor_reset_failed": "Cursor AI Editor reset failed: {error}",
|
||||
"cursor_reset_cancelled": "Cursor AI Editor reset cancelled. Exiting without making any changes.",
|
||||
"operation_cancelled": "Operation cancelled. Exiting without making any changes."
|
||||
"operation_cancelled": "Operation cancelled. Exiting without making any changes.",
|
||||
"navigating_to_settings": "Navigating to settings page...",
|
||||
"already_on_settings": "Already on settings page",
|
||||
"login_redirect_failed": "Login redirection failed, trying direct navigation...",
|
||||
"advanced_tab_not_found": "Advanced tab not found after multiple attempts",
|
||||
"advanced_tab_retry": "Advanced tab not found, attempt {attempt}/{max_attempts}",
|
||||
"advanced_tab_error": "Error finding Advanced tab: {error}",
|
||||
"advanced_tab_clicked": "Clicked on Advanced tab",
|
||||
"direct_advanced_navigation": "Trying direct navigation to advanced tab",
|
||||
"delete_button_not_found": "Delete Account button not found after multiple attempts",
|
||||
"delete_button_retry": "Delete button not found, attempt {attempt}/{max_attempts}",
|
||||
"delete_button_error": "Error finding Delete button: {error}",
|
||||
"delete_button_clicked": "Clicked on Delete Account button",
|
||||
"found_danger_zone": "Found Danger Zone section",
|
||||
"delete_input_not_found": "Delete confirmation input not found after multiple attempts",
|
||||
"delete_input_retry": "Delete input not found, attempt {attempt}/{max_attempts}",
|
||||
"delete_input_error": "Error finding Delete input: {error}",
|
||||
"delete_input_not_found_continuing": "Delete confirmation input not found, trying to continue anyway"
|
||||
},
|
||||
"github_register": {
|
||||
"title": "GitHub + Cursor AI Registration Automation",
|
||||
@@ -492,7 +535,8 @@
|
||||
"premium_usage": "Premium Usage",
|
||||
"basic_usage": "Basic Usage",
|
||||
"usage_not_found": "Usage not found",
|
||||
"lifetime_access_enabled": "Lifetime Access Enabled"
|
||||
"lifetime_access_enabled": "Lifetime Access Enabled",
|
||||
"token_not_found": "Token not found"
|
||||
},
|
||||
"config": {
|
||||
"config_not_available": "Configuration not available",
|
||||
@@ -522,7 +566,16 @@
|
||||
"config_setup_error": "Error setting up config: {error}",
|
||||
"storage_file_is_valid_and_contains_data": "Storage file is valid and contains data",
|
||||
"error_reading_storage_file": "Error reading storage file: {error}",
|
||||
"also_checked": "Also checked {path}"
|
||||
"also_checked": "Also checked {path}",
|
||||
"backup_created": "Backup created: {path}",
|
||||
"config_removed": "Config file removed for forced update",
|
||||
"backup_failed": "Failed to backup config: {error}",
|
||||
"force_update_failed": "Force update config failed: {error}",
|
||||
"config_force_update_disabled": "Config file force update disabled , skipping forced update",
|
||||
"config_force_update_enabled": "Config file force update enabled , performing forced update",
|
||||
"documents_path_not_found": "Documents path not found, using current directory",
|
||||
"config_dir_created": "Config directory created: {path}",
|
||||
"using_temp_dir": "Using temporary directory due to error: {path} (Error: {error})"
|
||||
},
|
||||
"oauth": {
|
||||
"authentication_button_not_found": "Authentication button not found",
|
||||
@@ -580,6 +633,136 @@
|
||||
"authentication_successful_getting_account_info": "Authentication successful, getting account info...",
|
||||
"warning_could_not_kill_existing_browser_processes": "Warning: Could not kill existing browser processes: {error}",
|
||||
"browser_failed_to_start": "Browser failed to start: {error}",
|
||||
"browser_failed": "Browser failed to start: {error}"
|
||||
"browser_failed": "Browser failed to start: {error}",
|
||||
"browser_failed_to_start_fallback": "Browser failed to start: {error}",
|
||||
"user_data_dir_not_found": "{browser} user data directory not found at {path}, will try Chrome instead",
|
||||
"error_getting_user_data_directory": "Error getting user data directory: {error}",
|
||||
"warning_browser_close": "Warning: This will close all running {browser} processes",
|
||||
"killing_browser_processes": "Killing {browser} processes...",
|
||||
"profile_selection_error": "Error during profile selection: {error}",
|
||||
"using_configured_browser_path": "Using configured {browser} path: {path}",
|
||||
"browser_not_found_trying_chrome": "Could not find {browser}, trying Chrome instead",
|
||||
"found_chrome_at": "Found Chrome at: {path}",
|
||||
"found_browser_user_data_dir": "Found {browser} user data directory: {path}"
|
||||
},
|
||||
"browser_profile": {
|
||||
"title": "Browser Profile Selection",
|
||||
"select_profile": "Select {browser} profile to use:",
|
||||
"profile_list": "Available {browser} profiles:",
|
||||
"default_profile": "Default profile",
|
||||
"profile": "Profile {number}",
|
||||
"no_profiles": "No {browser} profiles found",
|
||||
"error_loading": "Error loading {browser} profiles: {error}",
|
||||
"profile_selected": "Selected profile: {profile}",
|
||||
"invalid_selection": "Invalid selection. Please try again."
|
||||
},
|
||||
"account_delete": {
|
||||
"title": "Cursor Google Account Deletion Tool",
|
||||
"warning": "WARNING: This will permanently delete your Cursor account. This action cannot be undone.",
|
||||
"cancelled": "Account deletion cancelled.",
|
||||
"starting_process": "Starting account deletion process...",
|
||||
"google_button_not_found": "Google login button not found",
|
||||
"logging_in": "Logging in with Google...",
|
||||
"waiting_for_auth": "Waiting for Google authentication...",
|
||||
"login_successful": "Login successful",
|
||||
"unexpected_page": "Unexpected page after login: {url}",
|
||||
"trying_settings": "Trying to navigate to settings page...",
|
||||
"select_google_account": "Please select your Google account...",
|
||||
"auth_timeout": "Authentication timeout, continuing anyway...",
|
||||
"navigating_to_settings": "Navigating to settings page...",
|
||||
"already_on_settings": "Already on settings page",
|
||||
"login_redirect_failed": "Login redirection failed, trying direct navigation...",
|
||||
"advanced_tab_not_found": "Advanced tab not found after multiple attempts",
|
||||
"advanced_tab_retry": "Advanced tab not found, attempt {attempt}/{max_attempts}",
|
||||
"advanced_tab_error": "Error finding Advanced tab: {error}",
|
||||
"advanced_tab_clicked": "Clicked on Advanced tab",
|
||||
"direct_advanced_navigation": "Trying direct navigation to advanced tab",
|
||||
"delete_button_not_found": "Delete Account button not found after multiple attempts",
|
||||
"delete_button_retry": "Delete button not found, attempt {attempt}/{max_attempts}",
|
||||
"delete_button_error": "Error finding Delete button: {error}",
|
||||
"delete_button_clicked": "Clicked on Delete Account button",
|
||||
"found_danger_zone": "Found Danger Zone section",
|
||||
"delete_input_not_found": "Delete confirmation input not found after multiple attempts",
|
||||
"delete_input_retry": "Delete input not found, attempt {attempt}/{max_attempts}",
|
||||
"delete_input_error": "Error finding Delete input: {error}",
|
||||
"delete_input_not_found_continuing": "Delete confirmation input not found, trying to continue anyway",
|
||||
"typed_delete": "Typed \"Delete\" in confirmation box",
|
||||
"confirm_button_not_found": "Confirm button not found after multiple attempts",
|
||||
"confirm_button_retry": "Confirm button not found, attempt {attempt}/{max_attempts}",
|
||||
"confirm_button_error": "Error finding Confirm button: {error}",
|
||||
"account_deleted": "Account deleted successfully!",
|
||||
"error": "Error during account deletion: {error}",
|
||||
"success": "Your Cursor account has been successfully deleted!",
|
||||
"failed": "Account deletion process failed or was cancelled.",
|
||||
"interrupted": "Account deletion process interrupted by user.",
|
||||
"unexpected_error": "Unexpected error: {error}",
|
||||
"found_email": "Found email: {email}",
|
||||
"email_not_found": "Email not found: {error}",
|
||||
"confirm_prompt": "Are you sure you want to proceed? (y/N): "
|
||||
},
|
||||
"bypass": {
|
||||
"starting": "Starting Cursor version bypass...",
|
||||
"found_product_json": "Found product.json: {path}",
|
||||
"no_write_permission": "No write permission for file: {path}",
|
||||
"read_failed": "Failed to read product.json: {error}",
|
||||
"current_version": "Current version: {version}",
|
||||
"backup_created": "Backup created: {path}",
|
||||
"version_updated": "Version updated from {old} to {new}",
|
||||
"write_failed": "Failed to write product.json: {error}",
|
||||
"no_update_needed": "No update needed. Current version {version} is already >= 0.46.0",
|
||||
"bypass_failed": "Version bypass failed: {error}",
|
||||
"stack_trace": "Stack trace",
|
||||
"localappdata_not_found": "LOCALAPPDATA environment variable not found",
|
||||
"product_json_not_found": "product.json not found in common Linux paths",
|
||||
"unsupported_os": "Unsupported operating system: {system}",
|
||||
"file_not_found": "File not found: {path}",
|
||||
"title": "Cursor Version Bypass Tool",
|
||||
"description": "This tool modifies Cursor's product.json to bypass version restrictions",
|
||||
"menu_option": "Bypass Cursor Version Check"
|
||||
},
|
||||
"auth_check": {
|
||||
"checking_authorization": "Checking authorization...",
|
||||
"token_source": "Get token from database or input manually? (d/m, default: d)",
|
||||
"getting_token_from_db": "Getting token from database...",
|
||||
"token_found_in_db": "Token found in database",
|
||||
"token_not_found_in_db": "Token not found in database",
|
||||
"cursor_acc_info_not_found": "cursor_acc_info.py not found",
|
||||
"error_getting_token_from_db": "Error getting token from database: {error}",
|
||||
"enter_token": "Enter your Cursor token: ",
|
||||
"token_length": "Token length: {length} characters",
|
||||
"usage_response_status": "Usage response status: {response}",
|
||||
"unexpected_status_code": "Unexpected status code: {code}",
|
||||
"jwt_token_warning": "Token appears to be in JWT format, but API check returned an unexpected status code. The token might be valid but API access is restricted.",
|
||||
"invalid_token": "Invalid token",
|
||||
"user_authorized": "User is authorized",
|
||||
"user_unauthorized": "User is unauthorized",
|
||||
"request_timeout": "Request timed out",
|
||||
"connection_error": "Connection error",
|
||||
"check_error": "Error checking authorization: {error}",
|
||||
"authorization_successful": "Authorization successful!",
|
||||
"authorization_failed": "Authorization failed!",
|
||||
"operation_cancelled": "Operation cancelled by user",
|
||||
"unexpected_error": "Unexpected error: {error}",
|
||||
"error_generating_checksum": "Error generating checksum: {error}",
|
||||
"checking_usage_information": "Checking usage information...",
|
||||
"check_usage_response": "Check usage response: {response}",
|
||||
"usage_response": "Usage response: {response}"
|
||||
},
|
||||
"bypass_token_limit": {
|
||||
"title": "Bypass Token Limit Tool",
|
||||
"description": "This tool modifies the workbench.desktop.main.js file to bypass the token limit",
|
||||
"press_enter": "Press Enter to continue..."
|
||||
},
|
||||
"token": {
|
||||
"refreshing": "Refreshing token...",
|
||||
"refresh_success": "Token refreshed successfully! Valid for {days} days (expires: {expire})",
|
||||
"no_access_token": "No access token in response",
|
||||
"refresh_failed": "Token refresh failed: {error}",
|
||||
"invalid_response": "Invalid JSON response from refresh server",
|
||||
"server_error": "Refresh server error: HTTP {status}",
|
||||
"request_timeout": "Request to refresh server timed out",
|
||||
"connection_error": "Connection error to refresh server",
|
||||
"unexpected_error": "Unexpected error during token refresh: {error}",
|
||||
"extraction_error": "Error extracting token: {error}"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -439,5 +439,17 @@
|
||||
"completed_successfully": "¡Registro de GitHub + Cursor completado exitosamente!",
|
||||
"registration_encountered_issues": "El registro de GitHub + Cursor encontró problemas.",
|
||||
"check_browser_windows_for_manual_intervention_or_try_again_later": "Revise las ventanas del navegador para intervención manual o intente nuevamente más tarde."
|
||||
}
|
||||
},
|
||||
"chrome_profile": {
|
||||
"title": "Selección de Perfil de Chrome",
|
||||
"select_profile": "Seleccione un perfil de Chrome para usar:",
|
||||
"profile_list": "Perfiles disponibles:",
|
||||
"default_profile": "Perfil Predeterminado",
|
||||
"profile": "Perfil {number}",
|
||||
"no_profiles": "No se encontraron perfiles de Chrome",
|
||||
"error_loading": "Error al cargar perfiles de Chrome: {error}",
|
||||
"profile_selected": "Perfil seleccionado: {profile}",
|
||||
"invalid_selection": "Selección inválida. Por favor, intente de nuevo",
|
||||
"warning_chrome_close": "Advertencia: Esto cerrará todos los procesos de Chrome en ejecución"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -374,5 +374,17 @@
|
||||
"electron_localstorage_files_removed": "Fichiers localStorage Electron supprimés",
|
||||
"electron_localstorage_files_removal_error": "Erreur de suppression des fichiers localStorage Electron: {error}",
|
||||
"removing_electron_localstorage_files_completed": "Suppression des fichiers localStorage Electron terminée"
|
||||
},
|
||||
"chrome_profile": {
|
||||
"title": "Sélection du Profil Chrome",
|
||||
"select_profile": "Sélectionnez un profil Chrome à utiliser :",
|
||||
"profile_list": "Profils disponibles :",
|
||||
"default_profile": "Profil par Défaut",
|
||||
"profile": "Profil {number}",
|
||||
"no_profiles": "Aucun profil Chrome trouvé",
|
||||
"error_loading": "Erreur lors du chargement des profils Chrome : {error}",
|
||||
"profile_selected": "Profil sélectionné : {profile}",
|
||||
"invalid_selection": "Sélection invalide. Veuillez réessayer",
|
||||
"warning_chrome_close": "Attention : Cela fermera tous les processus Chrome en cours d'exécution"
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,16 @@
|
||||
{
|
||||
"menu": {
|
||||
"title": "Beschikbare opties",
|
||||
"exit": "Programma afsluiten",
|
||||
"reset": "Machine-ID resetten",
|
||||
"register": "Nieuw Cursor-account registreren",
|
||||
"register_google": "Registreren met Google-account",
|
||||
"register_github": "Registreren met GitHub-account",
|
||||
"register_manual": "Cursor registreren met aangepast e-mailadres",
|
||||
"quit": "Cursor-applicatie sluiten",
|
||||
"select_language": "Taal wijzigen",
|
||||
"input_choice": "Voer uw keuze in: {choices}",
|
||||
"title": "Beschikbare Opties",
|
||||
"exit": "Programma Afsluiten",
|
||||
"reset": "Machine ID Resetten",
|
||||
"register": "Nieuw Cursor Account Registreren",
|
||||
"register_google": "Registreren met Google Account",
|
||||
"register_github": "Registreren met GitHub Account",
|
||||
"register_manual": "Cursor Registreren met Aangepaste E-mail",
|
||||
"quit": "Cursor Toepassing Sluiten",
|
||||
"select_language": "Taal Wijzigen",
|
||||
"select_chrome_profile": "Chrome Profiel Selecteren",
|
||||
"input_choice": "Voer uw keuze in ({choices})",
|
||||
"invalid_choice": "Ongeldige selectie. Voer een nummer in uit {choices}.",
|
||||
"program_terminated": "Programma is beëindigd door de gebruiker",
|
||||
"error_occurred": "Er is een fout opgetreden: {error}. Probeer het opnieuw.",
|
||||
@@ -374,5 +375,17 @@
|
||||
"electron_localstorage_files_removed": "Electron localStorage-bestanden verwijderd",
|
||||
"electron_localstorage_files_removal_error": "Fout bij het verwijderen van Electron localStorage-bestanden: {error}",
|
||||
"removing_electron_localstorage_files_completed": "Electron localStorage-bestanden verwijderd"
|
||||
},
|
||||
"chrome_profile": {
|
||||
"title": "Chrome Profiel Selectie",
|
||||
"select_profile": "Selecteer een Chrome profiel om te gebruiken:",
|
||||
"profile_list": "Beschikbare profielen:",
|
||||
"default_profile": "Standaard Profiel",
|
||||
"profile": "Profiel {number}",
|
||||
"no_profiles": "Geen Chrome profielen gevonden",
|
||||
"error_loading": "Fout bij laden van Chrome profielen: {error}",
|
||||
"profile_selected": "Geselecteerd profiel: {profile}",
|
||||
"invalid_selection": "Ongeldige selectie. Probeer het opnieuw",
|
||||
"warning_chrome_close": "Waarschuwing: Dit zal alle actieve Chrome processen sluiten"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -383,5 +383,17 @@
|
||||
"electron_localstorage_files_removed": "Arquivos localStorage do Electron removidos",
|
||||
"electron_localstorage_files_removal_error": "Erro ao remover arquivos localStorage do Electron: {error}",
|
||||
"removing_electron_localstorage_files_completed": "Remoção dos arquivos localStorage do Electron concluída"
|
||||
},
|
||||
"chrome_profile": {
|
||||
"title": "Seleção de Perfil do Chrome",
|
||||
"select_profile": "Selecione um perfil do Chrome para usar:",
|
||||
"profile_list": "Perfis disponíveis:",
|
||||
"default_profile": "Perfil Padrão",
|
||||
"profile": "Perfil {number}",
|
||||
"no_profiles": "Nenhum perfil do Chrome encontrado",
|
||||
"error_loading": "Erro ao carregar perfis do Chrome: {error}",
|
||||
"profile_selected": "Perfil selecionado: {profile}",
|
||||
"invalid_selection": "Seleção inválida. Por favor, tente novamente",
|
||||
"warning_chrome_close": "Aviso: Isso fechará todos os processos do Chrome em execução"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -383,5 +383,17 @@
|
||||
"electron_localstorage_files_removed": "Файлы localStorage Electron удалены",
|
||||
"electron_localstorage_files_removal_error": "Ошибка удаления файлов localStorage Electron: {error}",
|
||||
"removing_electron_localstorage_files_completed": "Удаление файлов localStorage Electron завершено"
|
||||
},
|
||||
"chrome_profile": {
|
||||
"title": "Выбор Профиля Chrome",
|
||||
"select_profile": "Выберите профиль Chrome для использования:",
|
||||
"profile_list": "Доступные профили:",
|
||||
"default_profile": "Профиль по умолчанию",
|
||||
"profile": "Профиль {number}",
|
||||
"no_profiles": "Профили Chrome не найдены",
|
||||
"error_loading": "Ошибка загрузки профилей Chrome: {error}",
|
||||
"profile_selected": "Выбран профиль: {profile}",
|
||||
"invalid_selection": "Неверный выбор. Пожалуйста, попробуйте снова",
|
||||
"warning_chrome_close": "Предупреждение: Это закроет все запущенные процессы Chrome"
|
||||
}
|
||||
}
|
||||
@@ -386,5 +386,17 @@
|
||||
"electron_localstorage_files_removed": "Electron localStorage dosyaları kaldırıldı",
|
||||
"electron_localstorage_files_removal_error": "Electron localStorage dosyaları kaldırılırken hata: {error}",
|
||||
"removing_electron_localstorage_files_completed": "Electron localStorage dosyaları kaldırma işlemi tamamlandı"
|
||||
},
|
||||
"chrome_profile": {
|
||||
"title": "Chrome Profil Seçimi",
|
||||
"select_profile": "Kullanılacak Chrome profilini seçin:",
|
||||
"profile_list": "Mevcut profiller:",
|
||||
"default_profile": "Varsayılan Profil",
|
||||
"profile": "Profil {number}",
|
||||
"no_profiles": "Chrome profili bulunamadı",
|
||||
"error_loading": "Chrome profilleri yüklenirken hata: {error}",
|
||||
"profile_selected": "Seçilen profil: {profile}",
|
||||
"invalid_selection": "Geçersiz seçim. Lütfen tekrar deneyin",
|
||||
"warning_chrome_close": "Uyarı: Bu işlem tüm çalışan Chrome işlemlerini kapatacaktır"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
{
|
||||
"menu": {
|
||||
"title": "Các Tùy Chọn Khả Dụng",
|
||||
"title": "Các Tùy Chọn",
|
||||
"exit": "Thoát Chương Trình",
|
||||
"reset": "Đặt Lại ID Máy",
|
||||
"register": "Đăng Ký Tài Khoản Cursor Mới",
|
||||
"register_google": "Đăng Ký Bằng Tài Khoản Google",
|
||||
"register_github": "Đăng Ký Bằng Tài Khoản GitHub",
|
||||
"register_manual": "Đăng Ký Cursor Với Email Tùy Chỉnh",
|
||||
"quit": "Đóng Ứng Dụng Cursor",
|
||||
"select_language": "Thay Đổi Ngôn Ngữ",
|
||||
"select_chrome_profile": "Chọn Hồ Sơ Chrome",
|
||||
"input_choice": "Vui lòng nhập lựa chọn của bạn ({choices})",
|
||||
"invalid_choice": "Lựa chọn không hợp lệ. Vui lòng nhập một số từ {choices}",
|
||||
"program_terminated": "Chương trình đã bị người dùng chấm dứt",
|
||||
@@ -381,5 +384,17 @@
|
||||
"electron_localstorage_files_removed": "Đã xóa các tệp Electron localStorage",
|
||||
"electron_localstorage_files_removal_error": "Lỗi khi xóa các tệp Electron localStorage: {error}",
|
||||
"removing_electron_localstorage_files_completed": "Đã hoàn tất việc xóa các tệp Electron localStorage"
|
||||
},
|
||||
"chrome_profile": {
|
||||
"title": "Chọn Hồ Sơ Chrome",
|
||||
"select_profile": "Chọn hồ sơ Chrome để sử dụng:",
|
||||
"profile_list": "Các hồ sơ có sẵn:",
|
||||
"default_profile": "Hồ Sơ Mặc Định",
|
||||
"profile": "Hồ Sơ {number}",
|
||||
"no_profiles": "Không tìm thấy hồ sơ Chrome",
|
||||
"error_loading": "Lỗi khi tải hồ sơ Chrome: {error}",
|
||||
"profile_selected": "Đã chọn hồ sơ: {profile}",
|
||||
"invalid_selection": "Lựa chọn không hợp lệ. Vui lòng thử lại",
|
||||
"warning_chrome_close": "Cảnh báo: Điều này sẽ đóng tất cả các tiến trình Chrome đang chạy"
|
||||
}
|
||||
}
|
||||
@@ -2,13 +2,14 @@
|
||||
"menu": {
|
||||
"title": "可用选项",
|
||||
"exit": "退出程序",
|
||||
"reset": "重置机器标识",
|
||||
"register": "注册新 Cursor 账号",
|
||||
"register_google": "使用 Google 账号注册",
|
||||
"register_github": "使用 GitHub 账号注册",
|
||||
"register_manual": "使用自定义邮箱注册",
|
||||
"quit": "关闭 Cursor 应用",
|
||||
"reset": "重置机器ID",
|
||||
"register": "注册新的Cursor账户",
|
||||
"register_google": "使用Google账户注册",
|
||||
"register_github": "使用GitHub账户注册",
|
||||
"register_manual": "使用自定义邮箱注册Cursor",
|
||||
"quit": "关闭Cursor应用",
|
||||
"select_language": "更改语言",
|
||||
"select_chrome_profile": "选择Chrome配置文件",
|
||||
"input_choice": "请输入您的选择 ({choices})",
|
||||
"invalid_choice": "选择无效,请输入 {choices} 范围内的数字",
|
||||
"program_terminated": "程序已被用户终止",
|
||||
@@ -24,7 +25,14 @@
|
||||
"coming_soon": "即将推出",
|
||||
"fixed_soon": "即将修复",
|
||||
"contribute": "贡献项目",
|
||||
"config": "显示配置"
|
||||
"config": "显示配置",
|
||||
"delete_google_account": "删除 Cursor Google 账号",
|
||||
"continue_prompt": "继续?(y/N): ",
|
||||
"operation_cancelled_by_user": "操作被用户取消",
|
||||
"exiting": "退出中 ……",
|
||||
"bypass_version_check": "绕过 Cursor 版本检查",
|
||||
"check_user_authorized": "检查用户授权",
|
||||
"bypass_token_limit": "绕过 Token 限制"
|
||||
},
|
||||
"languages": {
|
||||
"en": "英语",
|
||||
@@ -111,7 +119,8 @@
|
||||
"modify_file_failed": "修改文件失败: {error}",
|
||||
"windows_machine_id_updated": "Windows机器ID更新成功",
|
||||
"update_windows_machine_id_failed": "更新Windows机器ID失败: {error}",
|
||||
"update_windows_machine_guid_failed": "更新Windows机器GUID失败: {error}"
|
||||
"update_windows_machine_guid_failed": "更新Windows机器GUID失败: {error}",
|
||||
"file_not_found": "文件未找到: {path}"
|
||||
},
|
||||
"register": {
|
||||
"title": "Cursor 注册工具",
|
||||
@@ -188,7 +197,15 @@
|
||||
"password_submitted": "密码已提交",
|
||||
"total_usage": "总使用量: {usage}",
|
||||
"setting_on_password": "设置密码",
|
||||
"getting_code": "获取验证码,将在60秒内尝试..."
|
||||
"getting_code": "获取验证码,将在60秒内尝试...",
|
||||
"browser_path_invalid": "{browser} 路径无效,使用默认路径",
|
||||
"using_browser": "正在使用 {browser} 浏览器: {path}",
|
||||
"using_browser_profile": "使用 {browser} 配置文件: {user_data_dir}",
|
||||
"make_sure_browser_is_properly_installed": "确保 {browser} 已正确安装",
|
||||
"try_install_browser": "尝试使用包管理器安装浏览器",
|
||||
"tracking_processes": "正在跟踪 {count} 个 {browser} 进程",
|
||||
"no_new_processes_detected": "未检测到新的 {browser} 进程",
|
||||
"could_not_track_processes": "无法跟踪 {browser} 进程: {error}"
|
||||
},
|
||||
"auth": {
|
||||
"title": "Cursor 认证管理器",
|
||||
@@ -301,7 +318,16 @@
|
||||
"clear_update_yml_failed": "清空 update.yml 文件失败: {error}",
|
||||
"unsupported_os": "不支持的操作系统: {system}",
|
||||
"remove_directory_failed": "删除目录失败: {error}",
|
||||
"create_block_file_failed": "创建阻止文件失败: {error}"
|
||||
"create_block_file_failed": "创建阻止文件失败: {error}",
|
||||
"directory_locked": "目录被锁定: {path}",
|
||||
"yml_locked": "update.yml 文件被锁定",
|
||||
"block_file_locked": "阻止文件被锁定",
|
||||
"yml_already_locked": "update.yml 文件已锁定",
|
||||
"block_file_already_locked": "阻止文件已锁定",
|
||||
"block_file_locked_error": "阻止文件锁定错误: {error}",
|
||||
"yml_locked_error": "update.yml 文件锁定错误: {error}",
|
||||
"block_file_already_locked_error": "阻止文件已锁定错误: {error}",
|
||||
"yml_already_locked_error": "update.yml 文件已锁定错误: {error}"
|
||||
},
|
||||
"updater": {
|
||||
"checking": "检查更新...",
|
||||
@@ -487,7 +513,8 @@
|
||||
"premium_usage": "高级使用量",
|
||||
"basic_usage": "基础使用量",
|
||||
"usage_not_found": "使用量未找到",
|
||||
"lifetime_access_enabled": "永久访问已启用"
|
||||
"lifetime_access_enabled": "永久访问已启用",
|
||||
"token_not_found": "Token 未找到"
|
||||
},
|
||||
"config": {
|
||||
"config_not_available": "配置未找到。",
|
||||
@@ -517,7 +544,16 @@
|
||||
"config_setup_error": "配置设置错误",
|
||||
"storage_file_is_valid_and_contains_data": "存储文件有效且包含数据",
|
||||
"error_reading_storage_file": "读取存储文件时出错",
|
||||
"also_checked": "也检查了 {path}"
|
||||
"also_checked": "也检查了 {path}",
|
||||
"backup_created": "备份创建: {path}",
|
||||
"config_removed": "配置文件已删除用于强制更新",
|
||||
"backup_failed": "备份失败: {error}",
|
||||
"force_update_failed": "强制更新配置失败: {error}",
|
||||
"config_force_update_disabled": "配置文件强制更新已禁用,跳过强制更新",
|
||||
"config_force_update_enabled": "配置文件强制更新已启用,正在执行强制更新",
|
||||
"documents_path_not_found": "找不到文档路径,使用当前目录",
|
||||
"config_dir_created": "已创建配置目录: {path}",
|
||||
"using_temp_dir": "由于错误使用临时目录: {path} (错误: {error})"
|
||||
},
|
||||
"oauth": {
|
||||
"authentication_button_not_found": "未找到认证按钮",
|
||||
@@ -575,7 +611,136 @@
|
||||
"authentication_successful_getting_account_info": "认证成功, 获取账户信息...",
|
||||
"warning_could_not_kill_existing_browser_processes": "警告: 无法杀死现有浏览器进程: {error}",
|
||||
"browser_failed_to_start": "浏览器启动失败: {error}",
|
||||
"browser_failed": "浏览器启动失败: {error}"
|
||||
"browser_failed": "浏览器启动失败: {error}",
|
||||
"browser_failed_to_start_fallback": "浏览器启动失败: {error}",
|
||||
"user_data_dir_not_found": "{browser} 用户数据目录未找到:{path},将尝试使用 Chrome",
|
||||
"error_getting_user_data_directory": "获取用户数据目录出错:{error}",
|
||||
"warning_browser_close": "警告:这将关闭所有正在运行的 {browser} 进程",
|
||||
"killing_browser_processes": "正在关闭 {browser} 进程...",
|
||||
"profile_selection_error": "配置文件选择过程中出错: {error}",
|
||||
"using_configured_browser_path": "使用配置的 {browser} 路径: {path}",
|
||||
"browser_not_found_trying_chrome": "未找到 {browser},尝试使用 Chrome 代替",
|
||||
"found_chrome_at": "找到 Chrome: {path}",
|
||||
"found_browser_user_data_dir": "找到 {browser} 用户数据目录: {path}"
|
||||
},
|
||||
"browser_profile": {
|
||||
"title": "浏览器配置文件选择",
|
||||
"select_profile": "选择要使用的{browser}配置文件:",
|
||||
"profile_list": "可用{browser}配置文件:",
|
||||
"default_profile": "默认配置文件",
|
||||
"profile": "配置文件 {number}",
|
||||
"no_profiles": "未找到{browser}配置文件",
|
||||
"error_loading": "加载{browser}配置文件时出错:{error}",
|
||||
"profile_selected": "已选择配置文件:{profile}",
|
||||
"invalid_selection": "选择无效。请重试"
|
||||
},
|
||||
"account_delete": {
|
||||
"title": "Cursor Google 账号删除工具",
|
||||
"warning": "警告:这将永久删除您的 Cursor 账号。此操作无法撤销。",
|
||||
"cancelled": "账号删除已取消。",
|
||||
"starting_process": "开始账号删除过程...",
|
||||
"google_button_not_found": "未找到 Google 登录按钮",
|
||||
"logging_in": "正在使用 Google 登录...",
|
||||
"waiting_for_auth": "等待 Google 验证...",
|
||||
"login_successful": "登录成功",
|
||||
"unexpected_page": "登录后页面异常:{url}",
|
||||
"trying_settings": "尝试导航到设置页面...",
|
||||
"select_google_account": "请选择您的 Google 账号...",
|
||||
"auth_timeout": "认证超时,继续执行...",
|
||||
"navigating_to_settings": "正在导航到设置页面...",
|
||||
"already_on_settings": "已在设置页面",
|
||||
"login_redirect_failed": "登录重定向失败,尝试直接导航...",
|
||||
"advanced_tab_not_found": "多次尝试后未找到高级选项卡",
|
||||
"advanced_tab_retry": "未找到高级选项卡,尝试 {attempt}/{max_attempts}",
|
||||
"advanced_tab_error": "查找高级选项卡时出错:{error}",
|
||||
"advanced_tab_clicked": "已点击高级选项卡",
|
||||
"direct_advanced_navigation": "尝试直接导航到高级选项卡",
|
||||
"delete_button_not_found": "多次尝试后未找到删除账号按钮",
|
||||
"delete_button_retry": "未找到删除按钮,尝试 {attempt}/{max_attempts}",
|
||||
"delete_button_error": "查找删除按钮时出错:{error}",
|
||||
"delete_button_clicked": "已点击删除账号按钮",
|
||||
"delete_input_not_found": "多次尝试后未找到删除确认输入框",
|
||||
"delete_input_retry": "未找到删除输入框,尝试 {attempt}/{max_attempts}",
|
||||
"delete_input_error": "查找删除输入框时出错:{error}",
|
||||
"delete_input_not_found_continuing": "未找到删除确认输入框,尝试继续执行...",
|
||||
"typed_delete": "已在确认框中输入\"Delete\"",
|
||||
"confirm_button_not_found": "多次尝试后未找到确认按钮",
|
||||
"confirm_button_retry": "未找到确认按钮,尝试 {attempt}/{max_attempts}",
|
||||
"confirm_button_error": "查找确认按钮时出错:{error}",
|
||||
"account_deleted": "账号删除成功!",
|
||||
"error": "账号删除过程中出错:{error}",
|
||||
"success": "您的 Cursor 账号已成功删除!",
|
||||
"failed": "账号删除过程失败或已取消。",
|
||||
"interrupted": "账号删除过程被用户中断。",
|
||||
"unexpected_error": "意外错误:{error}",
|
||||
"found_email": "找到邮箱:{email}",
|
||||
"email_not_found": "未找到邮箱: {error}",
|
||||
"found_danger_zone": "已找到危险区域部分",
|
||||
"confirm_prompt": "您确定要继续吗?(y/N): "
|
||||
},
|
||||
"bypass": {
|
||||
"starting": "开始绕过 Cursor 版本限制...",
|
||||
"found_product_json": "找到 product.json: {path}",
|
||||
"no_write_permission": "没有写入权限: {path}",
|
||||
"read_failed": "读取 product.json 失败: {error}",
|
||||
"current_version": "当前版本: {version}",
|
||||
"backup_created": "备份创建: {path}",
|
||||
"version_updated": "版本从 {old} 更新到 {new}",
|
||||
"write_failed": "写入 product.json 失败: {error}",
|
||||
"no_update_needed": "不需要更新。当前版本 {version} 已 >= 0.46.0",
|
||||
"bypass_failed": "绕过版本限制失败: {error}",
|
||||
"stack_trace": "堆栈跟踪",
|
||||
"localappdata_not_found": "LOCALAPPDATA 环境变量未找到",
|
||||
"product_json_not_found": "product.json 未在常见 Linux 路径中找到",
|
||||
"unsupported_os": "不支持的操作系统: {system}",
|
||||
"file_not_found": "文件未找到: {path}",
|
||||
"title": "Cursor 版本绕过工具",
|
||||
"description": "此工具修改 Cursor 的 product.json 以绕过版本限制",
|
||||
"menu_option": "绕过 Cursor 版本检查"
|
||||
},
|
||||
"auth_check": {
|
||||
"checking_authorization": "检查授权...",
|
||||
"token_source": "从数据库获取 token 或手动输入?(d/m, 默认: d)",
|
||||
"getting_token_from_db": "从数据库获取 token...",
|
||||
"token_found_in_db": "在数据库中找到 token",
|
||||
"token_not_found_in_db": "在数据库中未找到 token",
|
||||
"cursor_acc_info_not_found": "cursor_acc_info.py 未找到",
|
||||
"error_getting_token_from_db": "从数据库获取 token 时出错: {error}",
|
||||
"enter_token": "请输入您的 Cursor token: ",
|
||||
"token_length": "token 长度: {length}",
|
||||
"usage_response_status": "使用情况响应状态: {response}",
|
||||
"unexpected_status_code": "意外状态码: {code}",
|
||||
"jwt_token_warning": "token 似乎是 JWT 格式,但 API 检查返回意外状态码。token 可能有效但 API 访问受限。",
|
||||
"invalid_token": "无效的 token",
|
||||
"user_authorized": "用户已授权",
|
||||
"user_unauthorized": "用户未授权",
|
||||
"request_timeout": "请求超时",
|
||||
"connection_error": "连接错误",
|
||||
"check_error": "检查授权时出错: {error}",
|
||||
"authorization_successful": "授权成功",
|
||||
"authorization_failed": "授权失败",
|
||||
"operation_cancelled": "操作已取消",
|
||||
"unexpected_error": "意外错误: {error}",
|
||||
"error_generating_checksum": "生成校验和时出错: {error}",
|
||||
"checking_usage_information": "检查使用情况...",
|
||||
"check_usage_response": "检查使用情况响应: {response}",
|
||||
"usage_response": "使用情况响应: {response}"
|
||||
},
|
||||
"bypass_token_limit": {
|
||||
"title": "绕过 Token 限制工具",
|
||||
"description": "此工具修改 workbench.desktop.main.js 文件以绕过 token 限制",
|
||||
"press_enter": "按回车键继续..."
|
||||
},
|
||||
"token": {
|
||||
"refreshing": "正在刷新令牌...",
|
||||
"refresh_success": "令牌刷新成功!有效期 {days} 天(到期时间: {expire})",
|
||||
"no_access_token": "响应中没有访问令牌",
|
||||
"refresh_failed": "令牌刷新失败: {error}",
|
||||
"invalid_response": "刷新服务器返回无效的 JSON 响应",
|
||||
"server_error": "刷新服务器错误: HTTP {status}",
|
||||
"request_timeout": "刷新服务器请求超时",
|
||||
"connection_error": "连接刷新服务器错误",
|
||||
"unexpected_error": "令牌刷新过程中出现意外错误: {error}",
|
||||
"extraction_error": "提取令牌时出错: {error}"
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,11 +2,14 @@
|
||||
"menu": {
|
||||
"title": "可用選項",
|
||||
"exit": "退出程式",
|
||||
"reset": "重置機器識別碼",
|
||||
"register": "註冊新 Cursor 帳號",
|
||||
"register_manual": "使用自訂郵箱註冊",
|
||||
"quit": "關閉 Cursor 應用程式",
|
||||
"select_language": "變更語言",
|
||||
"reset": "重置機器ID",
|
||||
"register": "註冊新的Cursor帳戶",
|
||||
"register_google": "使用Google帳戶註冊",
|
||||
"register_github": "使用GitHub帳戶註冊",
|
||||
"register_manual": "使用自定義郵箱註冊Cursor",
|
||||
"quit": "關閉Cursor應用",
|
||||
"select_language": "更改語言",
|
||||
"select_chrome_profile": "選擇Chrome配置檔案",
|
||||
"input_choice": "請輸入您的選擇 ({choices})",
|
||||
"invalid_choice": "選擇無效,請輸入 {choices} 範圍內的數字",
|
||||
"program_terminated": "程式已被使用者終止",
|
||||
@@ -22,7 +25,14 @@
|
||||
"coming_soon": "即將推出",
|
||||
"fixed_soon": "即將修復",
|
||||
"contribute": "貢獻項目",
|
||||
"config": "顯示配置"
|
||||
"config": "顯示配置",
|
||||
"delete_google_account": "刪除 Cursor Google 帳號",
|
||||
"continue_prompt": "繼續?(y/N): ",
|
||||
"operation_cancelled_by_user": "操作被使用者取消",
|
||||
"exiting": "退出中 ……",
|
||||
"bypass_version_check": "繞過 Cursor 版本檢查",
|
||||
"check_user_authorized": "檢查用戶授權",
|
||||
"bypass_token_limit": "繞過 Token 限制"
|
||||
},
|
||||
"languages": {
|
||||
"en": "英文",
|
||||
@@ -109,7 +119,8 @@
|
||||
"modify_file_failed": "修改文件失敗: {error}",
|
||||
"windows_machine_id_updated": "Windows機器ID更新成功",
|
||||
"update_windows_machine_id_failed": "更新Windows機器ID失敗: {error}",
|
||||
"update_windows_machine_guid_failed": "更新Windows機器GUID失敗: {error}"
|
||||
"update_windows_machine_guid_failed": "更新Windows機器GUID失敗: {error}",
|
||||
"file_not_found": "文件未找到: {path}"
|
||||
},
|
||||
|
||||
"register": {
|
||||
@@ -281,7 +292,16 @@
|
||||
"clear_update_yml_failed": "清空 update.yml 文件失败: {error}",
|
||||
"unsupported_os": "不支持的操作系统: {system}",
|
||||
"remove_directory_failed": "刪除目錄失败: {error}",
|
||||
"create_block_file_failed": "創建阻止文件失败: {error}"
|
||||
"create_block_file_failed": "創建阻止文件失败: {error}",
|
||||
"directory_locked": "目錄被鎖定: {path}",
|
||||
"yml_locked": "update.yml 文件被鎖定",
|
||||
"block_file_locked": "阻止文件被鎖定",
|
||||
"yml_already_locked": "update.yml 文件已鎖定",
|
||||
"block_file_already_locked": "阻止文件已鎖定",
|
||||
"block_file_locked_error": "阻止文件锁定错误: {error}",
|
||||
"yml_locked_error": "update.yml 文件锁定错误: {error}",
|
||||
"block_file_already_locked_error": "阻止文件已锁定错误: {error}",
|
||||
"yml_already_locked_error": "update.yml 文件已锁定错误: {error}"
|
||||
},
|
||||
"updater": {
|
||||
"checking": "檢查更新...",
|
||||
@@ -467,7 +487,8 @@
|
||||
"premium_usage": "高級使用量",
|
||||
"basic_usage": "基礎使用量",
|
||||
"usage_not_found": "使用量未找到",
|
||||
"lifetime_access_enabled": "永久訪問已啟用"
|
||||
"lifetime_access_enabled": "永久訪問已啟用",
|
||||
"token_not_found": "Token 未找到"
|
||||
},
|
||||
"config": {
|
||||
"config_not_available": "配置未找到。",
|
||||
@@ -497,8 +518,13 @@
|
||||
"config_setup_error": "配置設置錯誤",
|
||||
"storage_file_is_valid_and_contains_data": "儲存文件有效且包含數據",
|
||||
"error_reading_storage_file": "讀取儲存文件時出錯",
|
||||
"also_checked": "也檢查了 {path}"
|
||||
|
||||
"also_checked": "也檢查了 {path}",
|
||||
"backup_created": "備份已創建: {path}",
|
||||
"config_removed": "配置文件已刪除用於強制更新",
|
||||
"backup_failed": "備份失敗: {error}",
|
||||
"force_update_failed": "強制更新配置失敗: {error}",
|
||||
"config_force_update_disabled": "配置文件強制更新已禁用,跳過強制更新",
|
||||
"config_force_update_enabled": "配置文件強制更新已啟用,正在執行強制更新"
|
||||
},
|
||||
"oauth": {
|
||||
"authentication_button_not_found": "未找到認證按鈕",
|
||||
@@ -555,6 +581,117 @@
|
||||
"authentication_successful_getting_account_info": "認證成功, 獲取帳戶信息...",
|
||||
"warning_could_not_kill_existing_browser_processes": "警告: 無法殺死現有瀏覽器進程: {error}",
|
||||
"browser_failed_to_start": "瀏覽器啟動失敗: {error}",
|
||||
"browser_failed": "瀏覽器啟動失敗: {error}"
|
||||
"browser_failed": "瀏覽器啟動失敗: {error}",
|
||||
"browser_failed_to_start_fallback": "瀏覽器啟動失敗: {error}"
|
||||
},
|
||||
"chrome_profile": {
|
||||
"title": "Chrome配置檔案選擇",
|
||||
"select_profile": "選擇要使用的Chrome配置檔案:",
|
||||
"profile_list": "可用配置檔案:",
|
||||
"default_profile": "預設配置檔案",
|
||||
"profile": "配置檔案 {number}",
|
||||
"no_profiles": "未找到Chrome配置檔案",
|
||||
"error_loading": "載入Chrome配置檔案時出錯:{error}",
|
||||
"profile_selected": "已選擇配置檔案:{profile}",
|
||||
"invalid_selection": "選擇無效。請重試",
|
||||
"warning_chrome_close": "警告:這將關閉所有正在執行的Chrome程序"
|
||||
},
|
||||
"account_delete": {
|
||||
"title": "Cursor Google 帳號刪除工具",
|
||||
"warning": "警告:這將永久刪除您的 Cursor 帳號。此操作無法撤銷。",
|
||||
"cancelled": "帳號刪除已取消。",
|
||||
"starting_process": "開始帳號刪除過程...",
|
||||
"google_button_not_found": "未找到 Google 登錄按鈕",
|
||||
"logging_in": "正在使用 Google 登錄...",
|
||||
"waiting_for_auth": "等待 Google 驗證...",
|
||||
"login_successful": "登錄成功",
|
||||
"unexpected_page": "登錄後頁面異常:{url}",
|
||||
"trying_settings": "嘗試導航到設置頁面...",
|
||||
"select_google_account": "請選擇您的 Google 帳號...",
|
||||
"auth_timeout": "認證超時,繼續執行...",
|
||||
"navigating_to_settings": "正在導航到設置頁面...",
|
||||
"already_on_settings": "已在設置頁面",
|
||||
"login_redirect_failed": "登錄重定向失敗,嘗試直接導航...",
|
||||
"advanced_tab_not_found": "多次嘗試後未找到高級選項卡",
|
||||
"advanced_tab_retry": "未找到高級選項卡,嘗試 {attempt}/{max_attempts}",
|
||||
"advanced_tab_error": "查找高級選項卡時出錯:{error}",
|
||||
"advanced_tab_clicked": "已點擊高級選項卡",
|
||||
"direct_advanced_navigation": "嘗試直接導航到高級選項卡",
|
||||
"delete_button_not_found": "多次嘗試後未找到刪除帳號按鈕",
|
||||
"delete_button_retry": "未找到刪除按鈕,嘗試 {attempt}/{max_attempts}",
|
||||
"delete_button_error": "查找刪除按鈕時出錯:{error}",
|
||||
"delete_button_clicked": "已點擊刪除帳號按鈕",
|
||||
"delete_input_not_found": "多次嘗試後未找到刪除確認輸入框",
|
||||
"delete_input_retry": "未找到刪除輸入框,嘗試 {attempt}/{max_attempts}",
|
||||
"delete_input_error": "查找刪除輸入框時出錯:{error}",
|
||||
"delete_input_not_found_continuing": "未找到刪除確認輸入框,嘗試繼續執行...",
|
||||
"typed_delete": "已在確認框中輸入\"Delete\"",
|
||||
"confirm_button_not_found": "多次嘗試後未找到確認按鈕",
|
||||
"confirm_button_retry": "未找到確認按鈕,嘗試 {attempt}/{max_attempts}",
|
||||
"confirm_button_error": "查找確認按鈕時出錯:{error}",
|
||||
"account_deleted": "帳號刪除成功!",
|
||||
"error": "帳號刪除過程中出錯:{error}",
|
||||
"success": "您的 Cursor 帳號已成功刪除!",
|
||||
"failed": "帳號刪除過程失敗或已取消。",
|
||||
"interrupted": "帳號刪除過程被用戶中斷。",
|
||||
"unexpected_error": "意外錯誤:{error}",
|
||||
"found_email": "找到郵箱:{email}",
|
||||
"email_not_found": "未找到郵箱: {error}",
|
||||
"found_danger_zone": "已找到危險區域部分",
|
||||
"confirm_prompt": "您確定要繼續嗎?(y/N): ",
|
||||
"typed_delete_js": "已使用 JavaScript 輸入\"Delete\""
|
||||
},
|
||||
"bypass": {
|
||||
"starting": "開始繞過 Cursor 版本限制...",
|
||||
"found_product_json": "找到 product.json: {path}",
|
||||
"no_write_permission": "沒有寫入權限: {path}",
|
||||
"read_failed": "讀取 product.json 失敗: {error}",
|
||||
"current_version": "當前版本: {version}",
|
||||
"backup_created": "備份已創建: {path}",
|
||||
"version_updated": "版本從 {old} 更新到 {new}",
|
||||
"write_failed": "寫入 product.json 失敗: {error}",
|
||||
"no_update_needed": "不需要更新。當前版本 {version} 已 >= 0.46.0",
|
||||
"bypass_failed": "繞過版本限制失敗: {error}",
|
||||
"stack_trace": "堆疊跟踪",
|
||||
"localappdata_not_found": "LOCALAPPDATA 環境變量未找到",
|
||||
"product_json_not_found": "product.json 未在常見 Linux 路徑中找到",
|
||||
"unsupported_os": "不支持的操作系統: {system}",
|
||||
"file_not_found": "文件未找到: {path}",
|
||||
"title": "Cursor 版本繞過工具",
|
||||
"description": "此工具修改 Cursor 的 product.json 以繞過版本限制",
|
||||
"menu_option": "繞過 Cursor 版本檢查"
|
||||
},
|
||||
"auth_check": {
|
||||
"checking_authorization": "檢查授權...",
|
||||
"token_source": "從資料庫獲取 token 或手動輸入?(d/m, 預設: d)",
|
||||
"getting_token_from_db": "從資料庫獲取 token...",
|
||||
"token_found_in_db": "在資料庫中找到 token",
|
||||
"token_not_found_in_db": "在資料庫中未找到 token",
|
||||
"cursor_acc_info_not_found": "cursor_acc_info.py 未找到",
|
||||
"usage_response_status": "使用情況響應狀態: {response}",
|
||||
"unexpected_status_code": "意外狀態碼: {code}",
|
||||
"jwt_token_warning": "token 似乎是 JWT 格式,但 API 檢查返回意外狀態碼。token 可能有效但 API 訪問受限。",
|
||||
"error_getting_token_from_db": "從資料庫獲取 token 時出錯: {error}",
|
||||
"enter_token": "請輸入您的 Cursor token: ",
|
||||
"token_length": "token 長度: {length}",
|
||||
"invalid_token": "無效的 token",
|
||||
"user_authorized": "用戶已授權",
|
||||
"user_unauthorized": "用戶未授權",
|
||||
"request_timeout": "請求超時",
|
||||
"connection_error": "連接錯誤",
|
||||
"check_error": "檢查授權時出錯: {error}",
|
||||
"authorization_successful": "授權成功",
|
||||
"authorization_failed": "授權失敗",
|
||||
"operation_cancelled": "操作已取消",
|
||||
"unexpected_error": "意外錯誤: {error}",
|
||||
"error_generating_checksum": "生成校驗和時出錯: {error}",
|
||||
"checking_usage_information": "檢查使用情況...",
|
||||
"check_usage_response": "檢查使用情況響應: {response}",
|
||||
"usage_response": "使用情況響應: {response}"
|
||||
},
|
||||
"bypass_token_limit": {
|
||||
"title": "繞過 Token 限制工具",
|
||||
"description": "此工具修改 workbench.desktop.main.js 文件以繞過 token 限制",
|
||||
"press_enter": "按回車鍵繼續..."
|
||||
}
|
||||
}
|
||||
2
logo.py
2
logo.py
@@ -79,7 +79,7 @@ Contributors:
|
||||
BasaiCorp aliensb handwerk2016 Nigel1992
|
||||
UntaDotMy RenjiYuusei imbajin ahmed98Osama
|
||||
bingoohuang mALIk-sHAHId MFaiqKhan httpmerak
|
||||
muhammedfurkan plamkatawe
|
||||
muhammedfurkan plamkatawe Lucaszmv
|
||||
"""
|
||||
OTHER_INFO_TEXT = f"""{Fore.YELLOW}
|
||||
Github: https://github.com/yeongpin/cursor-free-vip{Fore.RED}
|
||||
|
||||
35
main.py
35
main.py
@@ -9,7 +9,7 @@ import locale
|
||||
import platform
|
||||
import requests
|
||||
import subprocess
|
||||
from config import get_config
|
||||
from config import get_config, force_update_config
|
||||
import shutil
|
||||
import re
|
||||
|
||||
@@ -284,7 +284,12 @@ def print_menu():
|
||||
9: f"{Fore.GREEN}9{Style.RESET_ALL}. {EMOJI['UPDATE']} {translator.get('menu.disable_auto_update')}",
|
||||
10: f"{Fore.GREEN}10{Style.RESET_ALL}. {EMOJI['RESET']} {translator.get('menu.totally_reset')}",
|
||||
11: f"{Fore.GREEN}11{Style.RESET_ALL}. {EMOJI['CONTRIBUTE']} {translator.get('menu.contribute')}",
|
||||
12: f"{Fore.GREEN}12{Style.RESET_ALL}. {EMOJI['SETTINGS']} {translator.get('menu.config')}"
|
||||
12: f"{Fore.GREEN}12{Style.RESET_ALL}. {EMOJI['SETTINGS']} {translator.get('menu.config')}",
|
||||
13: f"{Fore.GREEN}13{Style.RESET_ALL}. {EMOJI['SETTINGS']} {translator.get('menu.select_chrome_profile')}",
|
||||
14: f"{Fore.GREEN}14{Style.RESET_ALL}. {EMOJI['ERROR']} {translator.get('menu.delete_google_account', fallback='Delete Cursor Google Account')}",
|
||||
15: f"{Fore.GREEN}15{Style.RESET_ALL}. {EMOJI['UPDATE']} {translator.get('menu.bypass_version_check', fallback='Bypass Cursor Version Check')}",
|
||||
16: f"{Fore.GREEN}16{Style.RESET_ALL}. {EMOJI['UPDATE']} {translator.get('menu.check_user_authorized', fallback='Check User Authorized')}",
|
||||
17: f"{Fore.GREEN}17{Style.RESET_ALL}. {EMOJI['UPDATE']} {translator.get('menu.bypass_token_limit', fallback='Bypass Token Limit')}"
|
||||
}
|
||||
|
||||
# Automatically calculate the number of menu items in the left and right columns
|
||||
@@ -549,14 +554,15 @@ def main():
|
||||
if not config:
|
||||
print(f"{Fore.RED}{EMOJI['ERROR']} {translator.get('menu.config_init_failed')}{Style.RESET_ALL}")
|
||||
return
|
||||
|
||||
force_update_config(translator)
|
||||
|
||||
if config.getboolean('Utils', 'enabled_update_check'):
|
||||
check_latest_version() # Add version check before showing menu
|
||||
print_menu()
|
||||
|
||||
while True:
|
||||
try:
|
||||
choice_num = 12
|
||||
choice_num = 17
|
||||
choice = input(f"\n{EMOJI['ARROW']} {Fore.CYAN}{translator.get('menu.input_choice', choices=f'0-{choice_num}')}: {Style.RESET_ALL}")
|
||||
|
||||
if choice == "0":
|
||||
@@ -613,6 +619,27 @@ def main():
|
||||
from config import print_config
|
||||
print_config(get_config(), translator)
|
||||
print_menu()
|
||||
elif choice == "13":
|
||||
from oauth_auth import OAuthHandler
|
||||
oauth = OAuthHandler(translator)
|
||||
oauth._select_profile()
|
||||
print_menu()
|
||||
elif choice == "14":
|
||||
import delete_cursor_google
|
||||
delete_cursor_google.main(translator)
|
||||
print_menu()
|
||||
elif choice == "15":
|
||||
import bypass_version
|
||||
bypass_version.main(translator)
|
||||
print_menu()
|
||||
elif choice == "16":
|
||||
import check_user_authorized
|
||||
check_user_authorized.main(translator)
|
||||
print_menu()
|
||||
elif choice == "17":
|
||||
import bypass_token_limit
|
||||
bypass_token_limit.run(translator)
|
||||
print_menu()
|
||||
else:
|
||||
print(f"{Fore.RED}{EMOJI['ERROR']} {translator.get('menu.invalid_choice')}{Style.RESET_ALL}")
|
||||
print_menu()
|
||||
|
||||
@@ -8,6 +8,7 @@ import configparser
|
||||
from pathlib import Path
|
||||
import sys
|
||||
from config import get_config
|
||||
from utils import get_default_browser_path as utils_get_default_browser_path
|
||||
|
||||
# Add global variable at the beginning of the file
|
||||
_translator = None
|
||||
@@ -112,29 +113,6 @@ def fill_signup_form(page, first_name, last_name, email, config, translator=None
|
||||
print(f"Error filling form: {e}")
|
||||
return False
|
||||
|
||||
def get_default_chrome_path():
|
||||
"""Get default Chrome path"""
|
||||
if sys.platform == "win32":
|
||||
paths = [
|
||||
os.path.join(os.environ.get('PROGRAMFILES', ''), 'Google/Chrome/Application/chrome.exe'),
|
||||
os.path.join(os.environ.get('PROGRAMFILES(X86)', ''), 'Google/Chrome/Application/chrome.exe'),
|
||||
os.path.join(os.environ.get('LOCALAPPDATA', ''), 'Google/Chrome/Application/chrome.exe')
|
||||
]
|
||||
elif sys.platform == "darwin":
|
||||
paths = [
|
||||
"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
|
||||
]
|
||||
else: # Linux
|
||||
paths = [
|
||||
"/usr/bin/google-chrome",
|
||||
"/usr/bin/google-chrome-stable"
|
||||
]
|
||||
|
||||
for path in paths:
|
||||
if os.path.exists(path):
|
||||
return path
|
||||
return ""
|
||||
|
||||
def get_user_documents_path():
|
||||
"""Get user Documents folder path"""
|
||||
if sys.platform == "win32":
|
||||
@@ -186,25 +164,32 @@ def setup_driver(translator=None):
|
||||
# Get config
|
||||
config = get_config(translator)
|
||||
|
||||
# Get Chrome path
|
||||
chrome_path = config.get('Chrome', 'chromepath', fallback=get_default_chrome_path())
|
||||
# Get browser type and path
|
||||
browser_type = config.get('Browser', 'default_browser', fallback='chrome')
|
||||
browser_path = config.get('Browser', f'{browser_type}_path', fallback=utils_get_default_browser_path(browser_type))
|
||||
|
||||
if not chrome_path or not os.path.exists(chrome_path):
|
||||
if not browser_path or not os.path.exists(browser_path):
|
||||
if translator:
|
||||
print(f"{Fore.YELLOW}⚠️ {translator.get('register.chrome_path_invalid') if translator else 'Chrome路径无效,使用默认路径'}{Style.RESET_ALL}")
|
||||
chrome_path = get_default_chrome_path()
|
||||
print(f"{Fore.YELLOW}⚠️ {browser_type} {translator.get('register.browser_path_invalid')}{Style.RESET_ALL}")
|
||||
browser_path = utils_get_default_browser_path(browser_type)
|
||||
|
||||
# For backward compatibility, also check Chrome path
|
||||
if browser_type == 'chrome':
|
||||
chrome_path = config.get('Chrome', 'chromepath', fallback=None)
|
||||
if chrome_path and os.path.exists(chrome_path):
|
||||
browser_path = chrome_path
|
||||
|
||||
# Set browser options
|
||||
co = ChromiumOptions()
|
||||
|
||||
# Set Chrome path
|
||||
co.set_browser_path(chrome_path)
|
||||
# Set browser path
|
||||
co.set_browser_path(browser_path)
|
||||
|
||||
# Use incognito mode
|
||||
co.set_argument("--incognito")
|
||||
|
||||
if sys.platform == "linux":
|
||||
# Set random port
|
||||
# Set Linux specific options
|
||||
co.set_argument("--no-sandbox")
|
||||
|
||||
# Set random port
|
||||
@@ -213,6 +198,10 @@ def setup_driver(translator=None):
|
||||
# Use headless mode (must be set to False, simulate human operation)
|
||||
co.headless(False)
|
||||
|
||||
# Log browser info
|
||||
if translator:
|
||||
print(f"{Fore.CYAN}🌐 {translator.get('register.using_browser')}: {browser_type} {browser_path}{Style.RESET_ALL}")
|
||||
|
||||
try:
|
||||
# Load extension
|
||||
extension_path = os.path.join(os.getcwd(), "turnstilePatch")
|
||||
@@ -234,30 +223,38 @@ def setup_driver(translator=None):
|
||||
before_pids = []
|
||||
try:
|
||||
import psutil
|
||||
before_pids = [p.pid for p in psutil.process_iter() if 'chrome' in p.name().lower()]
|
||||
browser_process_names = {
|
||||
'chrome': ['chrome', 'chromium'],
|
||||
'edge': ['msedge', 'edge'],
|
||||
'firefox': ['firefox'],
|
||||
'brave': ['brave', 'brave-browser']
|
||||
}
|
||||
process_names = browser_process_names.get(browser_type, ['chrome'])
|
||||
before_pids = [p.pid for p in psutil.process_iter() if any(name in p.name().lower() for name in process_names)]
|
||||
except:
|
||||
pass
|
||||
|
||||
# Launch browser
|
||||
page = ChromiumPage(co)
|
||||
|
||||
# Wait a moment for Chrome to fully launch
|
||||
# Wait a moment for browser to fully launch
|
||||
time.sleep(1)
|
||||
|
||||
# Record Chrome processes after launching and find new ones
|
||||
# Record browser processes after launching and find new ones
|
||||
try:
|
||||
import psutil
|
||||
after_pids = [p.pid for p in psutil.process_iter() if 'chrome' in p.name().lower()]
|
||||
# Find new Chrome processes
|
||||
process_names = browser_process_names.get(browser_type, ['chrome'])
|
||||
after_pids = [p.pid for p in psutil.process_iter() if any(name in p.name().lower() for name in process_names)]
|
||||
# Find new browser processes
|
||||
new_pids = [pid for pid in after_pids if pid not in before_pids]
|
||||
_chrome_process_ids.extend(new_pids)
|
||||
|
||||
if _chrome_process_ids:
|
||||
print(f"Tracking {len(_chrome_process_ids)} Chrome processes")
|
||||
print(f"{translator.get('register.tracking_processes', count=len(_chrome_process_ids), browser=browser_type)}")
|
||||
else:
|
||||
print(f"{Fore.YELLOW}Warning: No new Chrome processes detected to track{Style.RESET_ALL}")
|
||||
print(f"{Fore.YELLOW}Warning: {translator.get('register.no_new_processes_detected', browser=browser_type)}{Style.RESET_ALL}")
|
||||
except Exception as e:
|
||||
print(f"Warning: Could not track Chrome processes: {e}")
|
||||
print(f"{translator.get('register.could_not_track_processes', browser=browser_type, error=str(e))}")
|
||||
|
||||
return config, page
|
||||
|
||||
|
||||
@@ -6,7 +6,8 @@ from colorama import Fore, Style, init
|
||||
import requests
|
||||
import random
|
||||
import string
|
||||
from utils import get_random_wait_time
|
||||
from config import get_config
|
||||
from utils import get_random_wait_time, get_default_browser_path as utils_get_default_browser_path
|
||||
|
||||
# Initialize colorama
|
||||
init()
|
||||
@@ -104,9 +105,34 @@ class NewTempEmail:
|
||||
else:
|
||||
print(f"{Fore.CYAN}ℹ️ 正在启动浏览器...{Style.RESET_ALL}")
|
||||
|
||||
# 获取配置
|
||||
config = get_config(self.translator)
|
||||
|
||||
# 获取浏览器类型和路径
|
||||
browser_type = config.get('Browser', 'default_browser', fallback='chrome')
|
||||
browser_path = config.get('Browser', f'{browser_type}_path', fallback=utils_get_default_browser_path(browser_type))
|
||||
|
||||
if not browser_path or not os.path.exists(browser_path):
|
||||
if self.translator:
|
||||
print(f"{Fore.YELLOW}⚠️ {self.translator.get('email.browser_path_invalid', browser=browser_type) if self.translator else f'{browser_type} 路径无效,使用默认路径'}{Style.RESET_ALL}")
|
||||
browser_path = utils_get_default_browser_path(browser_type)
|
||||
|
||||
# 为了向后兼容,也检查 Chrome 路径
|
||||
if browser_type == 'chrome':
|
||||
chrome_path = config.get('Chrome', 'chromepath', fallback=None)
|
||||
if chrome_path and os.path.exists(chrome_path):
|
||||
browser_path = chrome_path
|
||||
|
||||
# 创建浏览器选项
|
||||
co = ChromiumOptions()
|
||||
|
||||
# 设置浏览器路径
|
||||
co.set_browser_path(browser_path)
|
||||
|
||||
# 记录浏览器信息
|
||||
if self.translator:
|
||||
print(f"{Fore.CYAN}🌐 {self.translator.get('email.using_browser', browser=browser_type, path=browser_path) if self.translator else f'使用 {browser_type} 浏览器: {browser_path}'}{Style.RESET_ALL}")
|
||||
|
||||
# Only use headless for non-OAuth operations
|
||||
if not hasattr(self, 'auth_type') or self.auth_type != 'oauth':
|
||||
co.set_argument("--headless=new")
|
||||
@@ -122,22 +148,43 @@ class NewTempEmail:
|
||||
co.set_argument("--disable-dev-shm-usage")
|
||||
co.set_argument("--disable-gpu")
|
||||
|
||||
# If running as root, try to use actual user's Chrome profile
|
||||
# If running as root, try to use actual user's browser profile
|
||||
if os.geteuid() == 0:
|
||||
sudo_user = os.environ.get('SUDO_USER')
|
||||
if sudo_user:
|
||||
actual_home = f"/home/{sudo_user}"
|
||||
user_data_dir = os.path.join(actual_home, ".config", "google-chrome")
|
||||
|
||||
# 根据浏览器类型选择配置文件夹
|
||||
profile_dirs = {
|
||||
'chrome': os.path.join(actual_home, ".config", "google-chrome"),
|
||||
'brave': os.path.join(actual_home, ".config", "BraveSoftware", "Brave-Browser"),
|
||||
'edge': os.path.join(actual_home, ".config", "microsoft-edge"),
|
||||
'firefox': os.path.join(actual_home, ".mozilla", "firefox")
|
||||
}
|
||||
|
||||
user_data_dir = profile_dirs.get(browser_type, profile_dirs['chrome'])
|
||||
|
||||
if os.path.exists(user_data_dir):
|
||||
print(f"{Fore.CYAN}ℹ️ {self.translator.get('email.using_chrome_profile', user_data_dir=user_data_dir) if self.translator else f'Using Chrome profile from: {user_data_dir}'}{Style.RESET_ALL}")
|
||||
print(f"{Fore.CYAN}ℹ️ {self.translator.get('email.using_browser_profile', browser=browser_type, user_data_dir=user_data_dir) if self.translator else f'Using {browser_type} profile from: {user_data_dir}'}{Style.RESET_ALL}")
|
||||
co.set_argument(f"--user-data-dir={user_data_dir}")
|
||||
|
||||
co.auto_port() # 自动设置端口
|
||||
|
||||
# 根据浏览器类型设置扩展参数
|
||||
extension_args = {
|
||||
'chrome': "--allow-extensions-in-incognito",
|
||||
'brave': "--allow-extensions-in-brave-incognito", # Brave 可能使用不同的参数
|
||||
'edge': "--allow-extensions-in-incognito",
|
||||
'firefox': None # Firefox 可能使用不同的方式加载扩展
|
||||
}
|
||||
|
||||
extension_arg = extension_args.get(browser_type, "--allow-extensions-in-incognito")
|
||||
|
||||
# 加载 uBlock 插件
|
||||
try:
|
||||
extension_path = self.get_extension_block()
|
||||
co.set_argument("--allow-extensions-in-incognito")
|
||||
if extension_arg: # 如果有扩展参数
|
||||
co.set_argument(extension_arg)
|
||||
co.add_extension(extension_path)
|
||||
except Exception as e:
|
||||
if self.translator:
|
||||
@@ -154,8 +201,17 @@ class NewTempEmail:
|
||||
print(f"{Fore.RED}❌ 启动浏览器失败: {str(e)}{Style.RESET_ALL}")
|
||||
|
||||
if sys.platform == "linux":
|
||||
print(f"{Fore.YELLOW}ℹ️ {self.translator.get('email.make_sure_chrome_chromium_is_properly_installed') if self.translator else 'Make sure Chrome/Chromium is properly installed'}{Style.RESET_ALL}")
|
||||
print(f"{Fore.YELLOW}ℹ️ {self.translator.get('email.try_install_chromium') if self.translator else 'Try: sudo apt install chromium-browser'}{Style.RESET_ALL}")
|
||||
browser_install_suggestions = {
|
||||
'chrome': "sudo apt install chromium-browser 或 sudo apt install google-chrome-stable",
|
||||
'brave': "sudo apt install brave-browser",
|
||||
'edge': "sudo apt install microsoft-edge-stable",
|
||||
'firefox': "sudo apt install firefox"
|
||||
}
|
||||
|
||||
suggestion = browser_install_suggestions.get(browser_type, browser_install_suggestions['chrome'])
|
||||
|
||||
print(f"{Fore.YELLOW}ℹ️ {self.translator.get('email.make_sure_browser_is_properly_installed', browser=browser_type) if self.translator else f'Make sure {browser_type} is properly installed'}{Style.RESET_ALL}")
|
||||
print(f"{Fore.YELLOW}ℹ️ {self.translator.get('email.try_install_browser') if self.translator else f'Try: {suggestion}'}{Style.RESET_ALL}")
|
||||
return False
|
||||
|
||||
def create_email(self):
|
||||
|
||||
700
oauth_auth.py
700
oauth_auth.py
@@ -7,9 +7,10 @@ import sys
|
||||
import json
|
||||
from DrissionPage import ChromiumPage, ChromiumOptions
|
||||
from cursor_auth import CursorAuth
|
||||
from utils import get_random_wait_time, get_default_chrome_path
|
||||
from utils import get_random_wait_time, get_default_browser_path
|
||||
from config import get_config
|
||||
import platform
|
||||
from get_user_token import get_token_from_cookie
|
||||
|
||||
# Initialize colorama
|
||||
init()
|
||||
@@ -32,53 +33,133 @@ class OAuthHandler:
|
||||
self.auth_type = auth_type # make sure the auth_type is not None
|
||||
os.environ['BROWSER_HEADLESS'] = 'False'
|
||||
self.browser = None
|
||||
self.selected_profile = None
|
||||
|
||||
def _get_active_profile(self, user_data_dir):
|
||||
"""Find the existing default/active Chrome profile"""
|
||||
def _get_available_profiles(self, user_data_dir):
|
||||
"""Get list of available Chrome profiles with their names"""
|
||||
try:
|
||||
# List all profile directories
|
||||
profiles = []
|
||||
for item in os.listdir(user_data_dir):
|
||||
if item == 'Default' or (item.startswith('Profile ') and os.path.isdir(os.path.join(user_data_dir, item))):
|
||||
profiles.append(item)
|
||||
profile_names = {}
|
||||
|
||||
if not profiles:
|
||||
print(f"{Fore.YELLOW}{EMOJI['INFO']} {self.translator.get('oauth.no_chrome_profiles_found') if self.translator else 'No Chrome profiles found, using Default'}{Style.RESET_ALL}")
|
||||
return 'Default'
|
||||
|
||||
# First check if Default profile exists
|
||||
if 'Default' in profiles:
|
||||
print(f"{Fore.CYAN}{EMOJI['INFO']} {self.translator.get('oauth.found_default_chrome_profile') if self.translator else 'Found Default Chrome profile'}{Style.RESET_ALL}")
|
||||
return 'Default'
|
||||
|
||||
# If no Default profile, check Local State for last used profile
|
||||
# Read Local State file to get profile names
|
||||
local_state_path = os.path.join(user_data_dir, 'Local State')
|
||||
if os.path.exists(local_state_path):
|
||||
with open(local_state_path, 'r', encoding='utf-8') as f:
|
||||
local_state = json.load(f)
|
||||
|
||||
# Get info about last used profile
|
||||
profile_info = local_state.get('profile', {})
|
||||
last_used = profile_info.get('last_used', '')
|
||||
info_cache = profile_info.get('info_cache', {})
|
||||
|
||||
# Try to find an active profile
|
||||
for profile in profiles:
|
||||
profile_path = profile.replace('\\', '/')
|
||||
if profile_path in info_cache:
|
||||
#print(f"{Fore.CYAN}{EMOJI['INFO']} Using existing Chrome profile: {profile}{Style.RESET_ALL}")
|
||||
return profile
|
||||
info_cache = local_state.get('profile', {}).get('info_cache', {})
|
||||
for profile_dir, info in info_cache.items():
|
||||
profile_dir = profile_dir.replace('\\', '/')
|
||||
if profile_dir == 'Default':
|
||||
profile_names['Default'] = info.get('name', 'Default')
|
||||
elif profile_dir.startswith('Profile '):
|
||||
profile_names[profile_dir] = info.get('name', profile_dir)
|
||||
|
||||
# Get list of profile directories
|
||||
for item in os.listdir(user_data_dir):
|
||||
if item == 'Default' or (item.startswith('Profile ') and os.path.isdir(os.path.join(user_data_dir, item))):
|
||||
profiles.append((item, profile_names.get(item, item)))
|
||||
return sorted(profiles)
|
||||
except Exception as e:
|
||||
print(f"{Fore.RED}{EMOJI['ERROR']} {self.translator.get('chrome_profile.error_loading', error=str(e)) if self.translator else f'Error loading Chrome profiles: {e}'}{Style.RESET_ALL}")
|
||||
return []
|
||||
|
||||
def _select_profile(self):
|
||||
"""Allow user to select a browser profile to use"""
|
||||
try:
|
||||
# 从配置中获取浏览器类型
|
||||
config = get_config(self.translator)
|
||||
browser_type = config.get('Browser', 'default_browser', fallback='chrome')
|
||||
browser_type_display = browser_type.capitalize()
|
||||
|
||||
# If no profile found in Local State, use the first available profile
|
||||
print(f"{Fore.CYAN}{EMOJI['INFO']} {self.translator.get('oauth.using_first_available_chrome_profile', profile=profiles[0]) if self.translator else f'Using first available Chrome profile: {profiles[0]}'}{Style.RESET_ALL}")
|
||||
return profiles[0]
|
||||
if self.translator:
|
||||
# 动态使用浏览器类型
|
||||
print(f"{Fore.CYAN}{EMOJI['INFO']} {self.translator.get('browser_profile.select_profile', browser=browser_type_display)}{Style.RESET_ALL}")
|
||||
print(f"{Fore.CYAN}{self.translator.get('browser_profile.profile_list', browser=browser_type_display)}{Style.RESET_ALL}")
|
||||
else:
|
||||
print(f"{Fore.CYAN}{EMOJI['INFO']} Select {browser_type_display} profile to use:{Style.RESET_ALL}")
|
||||
print(f"Available {browser_type_display} profiles:")
|
||||
|
||||
# Get the user data directory for the browser type
|
||||
user_data_dir = self._get_user_data_directory()
|
||||
|
||||
# Load available profiles from the selected browser type
|
||||
try:
|
||||
local_state_file = os.path.join(user_data_dir, "Local State")
|
||||
if os.path.exists(local_state_file):
|
||||
with open(local_state_file, 'r', encoding='utf-8') as f:
|
||||
state_data = json.load(f)
|
||||
profiles_data = state_data.get('profile', {}).get('info_cache', {})
|
||||
|
||||
# Create a list of available profiles
|
||||
profiles = []
|
||||
for profile_id, profile_info in profiles_data.items():
|
||||
name = profile_info.get('name', profile_id)
|
||||
# Mark the default profile
|
||||
if profile_id.lower() == 'default':
|
||||
name = f"{name} (Default)"
|
||||
profiles.append((profile_id, name))
|
||||
|
||||
# Sort profiles by name
|
||||
profiles.sort(key=lambda x: x[1])
|
||||
|
||||
# Show available profiles
|
||||
if self.translator:
|
||||
print(f"{Fore.CYAN}0. {self.translator.get('menu.exit')}{Style.RESET_ALL}")
|
||||
else:
|
||||
print(f"{Fore.CYAN}0. Exit{Style.RESET_ALL}")
|
||||
|
||||
for i, (profile_id, name) in enumerate(profiles, 1):
|
||||
print(f"{Fore.CYAN}{i}. {name}{Style.RESET_ALL}")
|
||||
|
||||
# Get user's choice
|
||||
max_choice = len(profiles)
|
||||
choice_str = input(f"\n{Fore.CYAN}{self.translator.get('menu.input_choice', choices=f'0-{max_choice}') if self.translator else f'Please enter your choice (0-{max_choice})'}{Style.RESET_ALL}")
|
||||
|
||||
try:
|
||||
choice = int(choice_str)
|
||||
if choice == 0:
|
||||
return False
|
||||
elif 1 <= choice <= max_choice:
|
||||
selected_profile = profiles[choice-1][0]
|
||||
self.selected_profile = selected_profile
|
||||
|
||||
if self.translator:
|
||||
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} {self.translator.get('browser_profile.profile_selected', profile=selected_profile)}{Style.RESET_ALL}")
|
||||
else:
|
||||
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} Selected profile: {selected_profile}{Style.RESET_ALL}")
|
||||
return True
|
||||
else:
|
||||
if self.translator:
|
||||
print(f"{Fore.RED}{EMOJI['ERROR']} {self.translator.get('browser_profile.invalid_selection')}{Style.RESET_ALL}")
|
||||
else:
|
||||
print(f"{Fore.RED}{EMOJI['ERROR']} Invalid selection. Please try again.{Style.RESET_ALL}")
|
||||
return self._select_profile()
|
||||
except ValueError:
|
||||
if self.translator:
|
||||
print(f"{Fore.RED}{EMOJI['ERROR']} {self.translator.get('browser_profile.invalid_selection')}{Style.RESET_ALL}")
|
||||
else:
|
||||
print(f"{Fore.RED}{EMOJI['ERROR']} Invalid selection. Please try again.{Style.RESET_ALL}")
|
||||
return self._select_profile()
|
||||
else:
|
||||
# No Local State file, use Default profile
|
||||
print(f"{Fore.YELLOW}{EMOJI['WARNING']} {self.translator.get('browser_profile.no_profiles', browser=browser_type_display) if self.translator else f'No {browser_type_display} profiles found'}{Style.RESET_ALL}")
|
||||
self.selected_profile = "Default"
|
||||
return True
|
||||
|
||||
except Exception as e:
|
||||
# Error loading profiles, use Default profile
|
||||
print(f"{Fore.RED}{EMOJI['ERROR']} {self.translator.get('browser_profile.error_loading', error=str(e), browser=browser_type_display) if self.translator else f'Error loading {browser_type_display} profiles: {str(e)}'}{Style.RESET_ALL}")
|
||||
self.selected_profile = "Default"
|
||||
return True
|
||||
|
||||
except Exception as e:
|
||||
print(f"{Fore.YELLOW}{EMOJI['INFO']} {self.translator.get('oauth.error_finding_chrome_profile', error=str(e)) if self.translator else f'Error finding Chrome profile, using Default: {str(e)}'}{Style.RESET_ALL}")
|
||||
return 'Default'
|
||||
|
||||
# General error, use Default profile
|
||||
print(f"{Fore.RED}{EMOJI['ERROR']} {self.translator.get('oauth.profile_selection_error', error=str(e)) if self.translator else f'Error during profile selection: {str(e)}'}{Style.RESET_ALL}")
|
||||
self.selected_profile = "Default"
|
||||
return True
|
||||
|
||||
def setup_browser(self):
|
||||
"""Setup browser for OAuth flow using active profile"""
|
||||
"""Setup browser for OAuth flow using selected profile"""
|
||||
try:
|
||||
print(f"{Fore.CYAN}{EMOJI['INFO']} {self.translator.get('oauth.initializing_browser_setup') if self.translator else 'Initializing browser setup...'}{Style.RESET_ALL}")
|
||||
|
||||
@@ -86,74 +167,52 @@ class OAuthHandler:
|
||||
platform_name = platform.system().lower()
|
||||
print(f"{Fore.CYAN}{EMOJI['INFO']} {self.translator.get('oauth.detected_platform', platform=platform_name) if self.translator else f'Detected platform: {platform_name}'}{Style.RESET_ALL}")
|
||||
|
||||
# Linux-specific checks
|
||||
if platform_name == 'linux':
|
||||
# Check if DISPLAY is set
|
||||
display = os.environ.get('DISPLAY')
|
||||
if not display:
|
||||
print(f"{Fore.RED}{EMOJI['ERROR']} {self.translator.get('oauth.no_display_found') if self.translator else 'No display found. Make sure X server is running.'}{Style.RESET_ALL}")
|
||||
print(f"{Fore.YELLOW}{EMOJI['INFO']} {self.translator.get('oauth.try_export_display') if self.translator else 'Try: export DISPLAY=:0'}{Style.RESET_ALL}")
|
||||
return False
|
||||
|
||||
# Check if running as root
|
||||
if os.geteuid() == 0:
|
||||
print(f"{Fore.YELLOW}{EMOJI['WARNING']} {self.translator.get('oauth.running_as_root_warning') if self.translator else 'Running as root is not recommended for browser automation'}{Style.RESET_ALL}")
|
||||
print(f"{Fore.YELLOW}{EMOJI['INFO']} {self.translator.get('oauth.consider_running_without_sudo') if self.translator else 'Consider running the script without sudo'}{Style.RESET_ALL}")
|
||||
|
||||
# Kill existing browser processes
|
||||
self._kill_browser_processes()
|
||||
# 从配置中获取浏览器类型
|
||||
config = get_config(self.translator)
|
||||
browser_type = config.get('Browser', 'default_browser', fallback='chrome')
|
||||
|
||||
# Get browser paths and user data directory
|
||||
user_data_dir = self._get_user_data_directory()
|
||||
chrome_path = self._get_browser_path()
|
||||
browser_path = self._get_browser_path()
|
||||
|
||||
if not chrome_path:
|
||||
if not browser_path:
|
||||
raise Exception(f"{self.translator.get('oauth.no_compatible_browser_found') if self.translator else 'No compatible browser found. Please install Google Chrome or Chromium.'}\n{self.translator.get('oauth.supported_browsers', platform=platform_name)}\n" +
|
||||
"- Windows: Google Chrome, Chromium\n" +
|
||||
"- macOS: Google Chrome, Chromium\n" +
|
||||
"- Linux: Google Chrome, Chromium, chromium-browser")
|
||||
|
||||
# Get active profile
|
||||
active_profile = self._get_active_profile(user_data_dir)
|
||||
print(f"{Fore.CYAN}{EMOJI['INFO']} {self.translator.get('oauth.using_browser_profile', profile=active_profile) if self.translator else f'Using browser profile: {active_profile}'}{Style.RESET_ALL}")
|
||||
print(f"{Fore.CYAN}{EMOJI['INFO']} {self.translator.get('oauth.found_browser_data_directory', path=user_data_dir) if self.translator else f'Found browser data directory: {user_data_dir}'}{Style.RESET_ALL}")
|
||||
|
||||
# Show warning about closing browser first - 使用动态提示
|
||||
if self.translator:
|
||||
warning_msg = self.translator.get('oauth.warning_browser_close', browser=browser_type)
|
||||
else:
|
||||
warning_msg = f'Warning: This will close all running {browser_type} processes'
|
||||
|
||||
print(f"\n{Fore.YELLOW}{EMOJI['WARNING']} {warning_msg}{Style.RESET_ALL}")
|
||||
|
||||
choice = input(f"{Fore.YELLOW} {self.translator.get('menu.continue_prompt', choices='y/N')} {Style.RESET_ALL}").lower()
|
||||
if choice != 'y':
|
||||
print(f"{Fore.YELLOW}{EMOJI['INFO']} {self.translator.get('menu.operation_cancelled_by_user') if self.translator else 'Operation cancelled by user'}{Style.RESET_ALL}")
|
||||
return False
|
||||
|
||||
# Kill existing browser processes
|
||||
self._kill_browser_processes()
|
||||
|
||||
# Let user select a profile
|
||||
if not self._select_profile():
|
||||
print(f"{Fore.YELLOW}{EMOJI['INFO']} {self.translator.get('menu.operation_cancelled_by_user') if self.translator else 'Operation cancelled by user'}{Style.RESET_ALL}")
|
||||
return False
|
||||
|
||||
# Configure browser options
|
||||
co = ChromiumOptions()
|
||||
co = self._configure_browser_options(browser_path, user_data_dir, self.selected_profile)
|
||||
|
||||
# Never use headless mode for OAuth flows
|
||||
co.headless(False)
|
||||
|
||||
# Platform-specific options
|
||||
if os.name == 'linux':
|
||||
co.set_argument('--no-sandbox')
|
||||
co.set_argument('--disable-dev-shm-usage')
|
||||
co.set_argument('--disable-gpu')
|
||||
|
||||
# If running as root, try to use actual user's Chrome profile
|
||||
if os.geteuid() == 0:
|
||||
sudo_user = os.environ.get('SUDO_USER')
|
||||
if sudo_user:
|
||||
actual_home = f"/home/{sudo_user}"
|
||||
user_data_dir = os.path.join(actual_home, ".config", "google-chrome")
|
||||
if os.path.exists(user_data_dir):
|
||||
print(f"{Fore.CYAN}{EMOJI['INFO']} {self.translator.get('oauth.using_chrome_profile_from', user_data_dir=user_data_dir) if self.translator else f'Using Chrome profile from: {user_data_dir}'}{Style.RESET_ALL}")
|
||||
co.set_argument(f"--user-data-dir={user_data_dir}")
|
||||
|
||||
# Set paths and profile
|
||||
co.set_paths(browser_path=chrome_path, user_data_path=user_data_dir)
|
||||
co.set_argument(f'--profile-directory={active_profile}')
|
||||
|
||||
# Basic options
|
||||
co.set_argument('--no-first-run')
|
||||
co.set_argument('--no-default-browser-check')
|
||||
# co.auto_port()
|
||||
|
||||
print(f"{Fore.CYAN}{EMOJI['INFO']} {self.translator.get('oauth.starting_browser', path=chrome_path) if self.translator else f'Starting browser at: {chrome_path}'}{Style.RESET_ALL}")
|
||||
print(f"{Fore.CYAN}{EMOJI['INFO']} {self.translator.get('oauth.starting_browser', path=browser_path) if self.translator else f'Starting browser at: {browser_path}'}{Style.RESET_ALL}")
|
||||
self.browser = ChromiumPage(co)
|
||||
|
||||
# Verify browser launched successfully
|
||||
if not self.browser:
|
||||
raise Exception("Failed to initialize browser instance")
|
||||
raise Exception(f"{self.translator.get('oauth.browser_failed_to_start', error=str(e)) if self.translator else 'Failed to initialize browser instance'}")
|
||||
|
||||
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} {self.translator.get('oauth.browser_setup_completed') if self.translator else 'Browser setup completed successfully'}{Style.RESET_ALL}")
|
||||
return True
|
||||
@@ -169,14 +228,61 @@ class OAuthHandler:
|
||||
return False
|
||||
|
||||
def _kill_browser_processes(self):
|
||||
"""Kill existing browser processes based on platform"""
|
||||
"""Kill existing browser processes based on platform and browser type"""
|
||||
try:
|
||||
# 从配置中获取浏览器类型
|
||||
config = get_config(self.translator)
|
||||
browser_type = config.get('Browser', 'default_browser', fallback='chrome')
|
||||
browser_type = browser_type.lower()
|
||||
|
||||
# 根据浏览器类型和平台定义要关闭的进程
|
||||
browser_processes = {
|
||||
'chrome': {
|
||||
'win': ['chrome.exe', 'chromium.exe'],
|
||||
'linux': ['chrome', 'chromium', 'chromium-browser'],
|
||||
'mac': ['Chrome', 'Chromium']
|
||||
},
|
||||
'brave': {
|
||||
'win': ['brave.exe'],
|
||||
'linux': ['brave', 'brave-browser'],
|
||||
'mac': ['Brave Browser']
|
||||
},
|
||||
'edge': {
|
||||
'win': ['msedge.exe'],
|
||||
'linux': ['msedge'],
|
||||
'mac': ['Microsoft Edge']
|
||||
},
|
||||
'firefox': {
|
||||
'win': ['firefox.exe'],
|
||||
'linux': ['firefox'],
|
||||
'mac': ['Firefox']
|
||||
},
|
||||
'opera': {
|
||||
'win': ['opera.exe', 'launcher.exe'],
|
||||
'linux': ['opera'],
|
||||
'mac': ['Opera']
|
||||
}
|
||||
}
|
||||
|
||||
# 获取平台类型
|
||||
if os.name == 'nt':
|
||||
platform_type = 'win'
|
||||
elif sys.platform == 'darwin':
|
||||
platform_type = 'mac'
|
||||
else:
|
||||
platform_type = 'linux'
|
||||
|
||||
# 获取要关闭的进程列表
|
||||
processes = browser_processes.get(browser_type, browser_processes['chrome']).get(platform_type, [])
|
||||
|
||||
if self.translator:
|
||||
print(f"{Fore.CYAN}{EMOJI['INFO']} {self.translator.get('oauth.killing_browser_processes', browser=browser_type) if self.translator else f'Killing {browser_type} processes...'}{Style.RESET_ALL}")
|
||||
|
||||
# 根据平台关闭进程
|
||||
if os.name == 'nt': # Windows
|
||||
processes = ['chrome.exe', 'chromium.exe']
|
||||
for proc in processes:
|
||||
os.system(f'taskkill /f /im {proc} >nul 2>&1')
|
||||
else: # Linux/Mac
|
||||
processes = ['chrome', 'chromium', 'chromium-browser']
|
||||
for proc in processes:
|
||||
os.system(f'pkill -f {proc} >/dev/null 2>&1')
|
||||
|
||||
@@ -185,96 +291,182 @@ class OAuthHandler:
|
||||
print(f"{Fore.YELLOW}{EMOJI['INFO']} {self.translator.get('oauth.warning_could_not_kill_existing_browser_processes', error=str(e)) if self.translator else f'Warning: Could not kill existing browser processes: {e}'}{Style.RESET_ALL}")
|
||||
|
||||
def _get_user_data_directory(self):
|
||||
"""Get the appropriate user data directory based on platform"""
|
||||
"""Get the default user data directory based on browser type and platform"""
|
||||
try:
|
||||
# 从配置中获取浏览器类型
|
||||
config = get_config(self.translator)
|
||||
browser_type = config.get('Browser', 'default_browser', fallback='chrome')
|
||||
browser_type = browser_type.lower()
|
||||
|
||||
# 根据操作系统和浏览器类型获取用户数据目录
|
||||
if os.name == 'nt': # Windows
|
||||
possible_paths = [
|
||||
os.path.expandvars(r'%LOCALAPPDATA%\Google\Chrome\User Data'),
|
||||
os.path.expandvars(r'%LOCALAPPDATA%\Chromium\User Data')
|
||||
]
|
||||
user_data_dirs = {
|
||||
'chrome': os.path.join(os.environ.get('LOCALAPPDATA', ''), 'Google', 'Chrome', 'User Data'),
|
||||
'brave': os.path.join(os.environ.get('LOCALAPPDATA', ''), 'BraveSoftware', 'Brave-Browser', 'User Data'),
|
||||
'edge': os.path.join(os.environ.get('LOCALAPPDATA', ''), 'Microsoft', 'Edge', 'User Data'),
|
||||
'firefox': os.path.join(os.environ.get('APPDATA', ''), 'Mozilla', 'Firefox', 'Profiles'),
|
||||
'opera': os.path.join(os.environ.get('APPDATA', ''), 'Opera Software', 'Opera Stable')
|
||||
}
|
||||
elif sys.platform == 'darwin': # macOS
|
||||
possible_paths = [
|
||||
os.path.expanduser('~/Library/Application Support/Google/Chrome'),
|
||||
os.path.expanduser('~/Library/Application Support/Chromium')
|
||||
]
|
||||
user_data_dirs = {
|
||||
'chrome': os.path.expanduser('~/Library/Application Support/Google/Chrome'),
|
||||
'brave': os.path.expanduser('~/Library/Application Support/BraveSoftware/Brave-Browser'),
|
||||
'edge': os.path.expanduser('~/Library/Application Support/Microsoft Edge'),
|
||||
'firefox': os.path.expanduser('~/Library/Application Support/Firefox/Profiles'),
|
||||
'opera': os.path.expanduser('~/Library/Application Support/com.operasoftware.Opera')
|
||||
}
|
||||
else: # Linux
|
||||
possible_paths = [
|
||||
os.path.expanduser('~/.config/google-chrome'),
|
||||
os.path.expanduser('~/.config/chromium'),
|
||||
'/usr/bin/google-chrome',
|
||||
'/usr/bin/chromium-browser'
|
||||
]
|
||||
user_data_dirs = {
|
||||
'chrome': os.path.expanduser('~/.config/google-chrome'),
|
||||
'brave': os.path.expanduser('~/.config/BraveSoftware/Brave-Browser'),
|
||||
'edge': os.path.expanduser('~/.config/microsoft-edge'),
|
||||
'firefox': os.path.expanduser('~/.mozilla/firefox'),
|
||||
'opera': os.path.expanduser('~/.config/opera')
|
||||
}
|
||||
|
||||
# Try each possible path
|
||||
for path in possible_paths:
|
||||
if os.path.exists(path):
|
||||
print(f"{Fore.CYAN}{EMOJI['INFO']} {self.translator.get('oauth.found_browser_data_directory', path=path) if self.translator else f'Found browser data directory: {path}'}{Style.RESET_ALL}")
|
||||
return path
|
||||
# 获取选定浏览器的用户数据目录,如果找不到则使用 Chrome 的
|
||||
user_data_dir = user_data_dirs.get(browser_type)
|
||||
|
||||
# Create temporary profile if no existing profile found
|
||||
temp_profile = os.path.join(os.path.expanduser('~'), '.cursor_temp_profile')
|
||||
print(f"{Fore.YELLOW}{EMOJI['INFO']} {self.translator.get('oauth.creating_temporary_profile', path=temp_profile) if self.translator else f'Creating temporary profile at: {temp_profile}'}{Style.RESET_ALL}")
|
||||
os.makedirs(temp_profile, exist_ok=True)
|
||||
return temp_profile
|
||||
if user_data_dir and os.path.exists(user_data_dir):
|
||||
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} {self.translator.get('oauth.found_browser_user_data_dir', browser=browser_type, path=user_data_dir) if self.translator else f'Found {browser_type} user data directory: {user_data_dir}'}{Style.RESET_ALL}")
|
||||
return user_data_dir
|
||||
else:
|
||||
print(f"{Fore.YELLOW}{EMOJI['WARNING']} {self.translator.get('oauth.user_data_dir_not_found', browser=browser_type, path=user_data_dir) if self.translator else f'{browser_type} user data directory not found at {user_data_dir}, will try Chrome instead'}{Style.RESET_ALL}")
|
||||
return user_data_dirs['chrome'] # 回退到 Chrome 目录
|
||||
|
||||
except Exception as e:
|
||||
print(f"{Fore.RED}{EMOJI['ERROR']} {self.translator.get('oauth.error_getting_user_data_directory', error=str(e)) if self.translator else f'Error getting user data directory: {e}'}{Style.RESET_ALL}")
|
||||
raise
|
||||
# 在出错时提供一个默认目录
|
||||
if os.name == 'nt':
|
||||
return os.path.join(os.environ.get('LOCALAPPDATA', ''), 'Google', 'Chrome', 'User Data')
|
||||
elif sys.platform == 'darwin':
|
||||
return os.path.expanduser('~/Library/Application Support/Google/Chrome')
|
||||
else:
|
||||
return os.path.expanduser('~/.config/google-chrome')
|
||||
|
||||
def _get_browser_path(self):
|
||||
"""Get the browser executable path based on platform"""
|
||||
"""Get appropriate browser path based on platform and selected browser type"""
|
||||
try:
|
||||
# Try default path first
|
||||
chrome_path = get_default_chrome_path()
|
||||
if chrome_path and os.path.exists(chrome_path):
|
||||
return chrome_path
|
||||
# 从配置中获取浏览器类型
|
||||
config = get_config(self.translator)
|
||||
browser_type = config.get('Browser', 'default_browser', fallback='chrome')
|
||||
browser_type = browser_type.lower()
|
||||
|
||||
# 首先检查配置中是否有明确指定的浏览器路径
|
||||
browser_path = config.get('Browser', f'{browser_type}_path', fallback=None)
|
||||
if browser_path and os.path.exists(browser_path):
|
||||
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} {self.translator.get('oauth.using_configured_browser_path', browser=browser_type, path=browser_path) if self.translator else f'Using configured {browser_type} path: {browser_path}'}{Style.RESET_ALL}")
|
||||
return browser_path
|
||||
|
||||
# 尝试获取默认路径
|
||||
browser_path = get_default_browser_path(browser_type)
|
||||
if browser_path and os.path.exists(browser_path):
|
||||
return browser_path
|
||||
|
||||
print(f"{Fore.YELLOW}{EMOJI['INFO']} {self.translator.get('oauth.searching_for_alternative_browser_installations') if self.translator else 'Searching for alternative browser installations...'}{Style.RESET_ALL}")
|
||||
|
||||
# Platform-specific paths
|
||||
# 如果未找到配置中指定的浏览器,则尝试查找其他兼容浏览器
|
||||
if os.name == 'nt': # Windows
|
||||
alt_paths = [
|
||||
r'C:\Program Files\Google\Chrome\Application\chrome.exe',
|
||||
r'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe',
|
||||
r'C:\Program Files\Chromium\Application\chrome.exe',
|
||||
os.path.expandvars(r'%ProgramFiles%\Google\Chrome\Application\chrome.exe'),
|
||||
os.path.expandvars(r'%ProgramFiles(x86)%\Google\Chrome\Application\chrome.exe')
|
||||
]
|
||||
possible_paths = []
|
||||
if browser_type == 'brave':
|
||||
possible_paths = [
|
||||
os.path.join(os.environ.get('PROGRAMFILES', ''), 'BraveSoftware', 'Brave-Browser', 'Application', 'brave.exe'),
|
||||
os.path.join(os.environ.get('PROGRAMFILES(X86)', ''), 'BraveSoftware', 'Brave-Browser', 'Application', 'brave.exe'),
|
||||
os.path.join(os.environ.get('LOCALAPPDATA', ''), 'BraveSoftware', 'Brave-Browser', 'Application', 'brave.exe')
|
||||
]
|
||||
elif browser_type == 'edge':
|
||||
possible_paths = [
|
||||
os.path.join(os.environ.get('PROGRAMFILES', ''), 'Microsoft', 'Edge', 'Application', 'msedge.exe'),
|
||||
os.path.join(os.environ.get('PROGRAMFILES(X86)', ''), 'Microsoft', 'Edge', 'Application', 'msedge.exe')
|
||||
]
|
||||
elif browser_type == 'firefox':
|
||||
possible_paths = [
|
||||
os.path.join(os.environ.get('PROGRAMFILES', ''), 'Mozilla Firefox', 'firefox.exe'),
|
||||
os.path.join(os.environ.get('PROGRAMFILES(X86)', ''), 'Mozilla Firefox', 'firefox.exe')
|
||||
]
|
||||
elif browser_type == 'opera':
|
||||
possible_paths = [
|
||||
os.path.join(os.environ.get('PROGRAMFILES', ''), 'Opera', 'opera.exe'),
|
||||
os.path.join(os.environ.get('PROGRAMFILES(X86)', ''), 'Opera', 'opera.exe'),
|
||||
os.path.join(os.environ.get('LOCALAPPDATA', ''), 'Programs', 'Opera', 'launcher.exe'),
|
||||
os.path.join(os.environ.get('LOCALAPPDATA', ''), 'Programs', 'Opera', 'opera.exe'),
|
||||
os.path.join(os.environ.get('LOCALAPPDATA', ''), 'Programs', 'Opera GX', 'launcher.exe'),
|
||||
os.path.join(os.environ.get('LOCALAPPDATA', ''), 'Programs', 'Opera GX', 'opera.exe')
|
||||
]
|
||||
else: # 默认为 Chrome
|
||||
possible_paths = [
|
||||
os.path.join(os.environ.get('PROGRAMFILES', ''), 'Google', 'Chrome', 'Application', 'chrome.exe'),
|
||||
os.path.join(os.environ.get('PROGRAMFILES(X86)', ''), 'Google', 'Chrome', 'Application', 'chrome.exe'),
|
||||
os.path.join(os.environ.get('LOCALAPPDATA', ''), 'Google', 'Chrome', 'Application', 'chrome.exe')
|
||||
]
|
||||
|
||||
elif sys.platform == 'darwin': # macOS
|
||||
alt_paths = [
|
||||
'/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
|
||||
'/Applications/Chromium.app/Contents/MacOS/Chromium',
|
||||
'~/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
|
||||
'~/Applications/Chromium.app/Contents/MacOS/Chromium'
|
||||
]
|
||||
possible_paths = []
|
||||
if browser_type == 'brave':
|
||||
possible_paths = ['/Applications/Brave Browser.app/Contents/MacOS/Brave Browser']
|
||||
elif browser_type == 'edge':
|
||||
possible_paths = ['/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge']
|
||||
elif browser_type == 'firefox':
|
||||
possible_paths = ['/Applications/Firefox.app/Contents/MacOS/firefox']
|
||||
else: # 默认为 Chrome
|
||||
possible_paths = ['/Applications/Google Chrome.app/Contents/MacOS/Google Chrome']
|
||||
|
||||
else: # Linux
|
||||
alt_paths = [
|
||||
'/usr/bin/google-chrome',
|
||||
'/usr/bin/chromium-browser',
|
||||
'/usr/bin/chromium',
|
||||
'/snap/bin/chromium',
|
||||
'/usr/local/bin/chrome',
|
||||
'/usr/local/bin/chromium'
|
||||
]
|
||||
possible_paths = []
|
||||
if browser_type == 'brave':
|
||||
possible_paths = ['/usr/bin/brave-browser', '/usr/bin/brave']
|
||||
elif browser_type == 'edge':
|
||||
possible_paths = ['/usr/bin/microsoft-edge']
|
||||
elif browser_type == 'firefox':
|
||||
possible_paths = ['/usr/bin/firefox']
|
||||
else: # 默认为 Chrome
|
||||
possible_paths = ['/usr/bin/google-chrome', '/usr/bin/google-chrome-stable', '/usr/bin/chromium', '/usr/bin/chromium-browser']
|
||||
|
||||
# 检查每个可能的路径
|
||||
for path in possible_paths:
|
||||
if os.path.exists(path):
|
||||
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} {self.translator.get('oauth.found_browser_at', path=path) if self.translator else f'Found browser at: {path}'}{Style.RESET_ALL}")
|
||||
return path
|
||||
|
||||
# Try each alternative path
|
||||
for path in alt_paths:
|
||||
expanded_path = os.path.expanduser(path)
|
||||
if os.path.exists(expanded_path):
|
||||
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} {self.translator.get('oauth.found_browser_at', path=expanded_path) if self.translator else f'Found browser at: {expanded_path}'}{Style.RESET_ALL}")
|
||||
return expanded_path
|
||||
# 如果找不到指定浏览器,则尝试使用Chrome
|
||||
if browser_type != 'chrome':
|
||||
print(f"{Fore.YELLOW}{EMOJI['WARNING']} {self.translator.get('oauth.browser_not_found_trying_chrome', browser=browser_type) if self.translator else f'Could not find {browser_type}, trying Chrome instead'}{Style.RESET_ALL}")
|
||||
return self._get_chrome_path()
|
||||
|
||||
return None
|
||||
|
||||
except Exception as e:
|
||||
print(f"{Fore.RED}{EMOJI['ERROR']} {self.translator.get('oauth.error_finding_browser_path', error=str(e)) if self.translator else f'Error finding browser path: {e}'}{Style.RESET_ALL}")
|
||||
return None
|
||||
|
||||
def _get_chrome_path(self):
|
||||
"""Fallback method to get Chrome path"""
|
||||
try:
|
||||
if os.name == 'nt': # Windows
|
||||
possible_paths = [
|
||||
os.path.join(os.environ.get('PROGRAMFILES', ''), 'Google', 'Chrome', 'Application', 'chrome.exe'),
|
||||
os.path.join(os.environ.get('PROGRAMFILES(X86)', ''), 'Google', 'Chrome', 'Application', 'chrome.exe'),
|
||||
os.path.join(os.environ.get('LOCALAPPDATA', ''), 'Google', 'Chrome', 'Application', 'chrome.exe')
|
||||
]
|
||||
elif sys.platform == 'darwin': # macOS
|
||||
possible_paths = ['/Applications/Google Chrome.app/Contents/MacOS/Google Chrome']
|
||||
else: # Linux
|
||||
possible_paths = ['/usr/bin/google-chrome', '/usr/bin/google-chrome-stable', '/usr/bin/chromium', '/usr/bin/chromium-browser']
|
||||
|
||||
for path in possible_paths:
|
||||
if os.path.exists(path):
|
||||
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} {self.translator.get('oauth.found_chrome_at', path=path) if self.translator else f'Found Chrome at: {path}'}{Style.RESET_ALL}")
|
||||
return path
|
||||
return None
|
||||
except Exception as e:
|
||||
print(f"{Fore.RED}{EMOJI['ERROR']} {self.translator.get('oauth.error_finding_chrome_path', error=str(e)) if self.translator else f'Error finding Chrome path: {e}'}{Style.RESET_ALL}")
|
||||
return None
|
||||
|
||||
def _configure_browser_options(self, chrome_path, user_data_dir, active_profile):
|
||||
def _configure_browser_options(self, browser_path, user_data_dir, active_profile):
|
||||
"""Configure browser options based on platform"""
|
||||
try:
|
||||
co = ChromiumOptions()
|
||||
co.set_paths(browser_path=chrome_path, user_data_path=user_data_dir)
|
||||
co.set_paths(browser_path=browser_path, user_data_path=user_data_dir)
|
||||
co.set_argument(f'--profile-directory={active_profile}')
|
||||
|
||||
# Basic options
|
||||
@@ -342,13 +534,19 @@ class OAuthHandler:
|
||||
# Check if we're on account selection page
|
||||
if "accounts.google.com" in self.browser.url:
|
||||
print(f"{Fore.CYAN}{EMOJI['INFO']} {self.translator.get('oauth.please_select_your_google_account_to_continue') if self.translator else 'Please select your Google account to continue...'}{Style.RESET_ALL}")
|
||||
alert_message = self.translator.get('oauth.please_select_your_google_account_to_continue') if self.translator else 'Please select your Google account to continue with Cursor authentication'
|
||||
try:
|
||||
self.browser.run_js(f"""
|
||||
alert('{alert_message}');
|
||||
""")
|
||||
except:
|
||||
pass # Alert is optional
|
||||
|
||||
# 获取配置中是否启用 alert 选项
|
||||
config = get_config(self.translator)
|
||||
show_alert = config.getboolean('OAuth', 'show_selection_alert', fallback=False)
|
||||
|
||||
if show_alert:
|
||||
alert_message = self.translator.get('oauth.please_select_your_google_account_to_continue') if self.translator else 'Please select your Google account to continue with Cursor authentication'
|
||||
try:
|
||||
self.browser.run_js(f"""
|
||||
alert('{alert_message}');
|
||||
""")
|
||||
except:
|
||||
pass # Alert is optional
|
||||
|
||||
# Wait for authentication to complete
|
||||
auth_info = self._wait_for_auth()
|
||||
@@ -390,13 +588,7 @@ class OAuthHandler:
|
||||
for cookie in cookies:
|
||||
if cookie.get("name") == "WorkosCursorSessionToken":
|
||||
value = cookie.get("value", "")
|
||||
token = None
|
||||
|
||||
if "::" in value:
|
||||
token = value.split("::")[-1]
|
||||
elif "%3A%3A" in value:
|
||||
token = value.split("%3A%3A")[-1]
|
||||
|
||||
token = get_token_from_cookie(value, self.translator)
|
||||
if token:
|
||||
# Get email from settings page
|
||||
print(f"{Fore.CYAN}{EMOJI['INFO']} {self.translator.get('oauth.authentication_successful_getting_account_info') if self.translator else 'Authentication successful, getting account info...'}{Style.RESET_ALL}")
|
||||
@@ -419,21 +611,29 @@ class OAuthHandler:
|
||||
usage_text = usage_element.text
|
||||
print(f"{Fore.CYAN}{EMOJI['INFO']} {self.translator.get('oauth.usage_count', usage=usage_text) if self.translator else f'Usage count: {usage_text}'}{Style.RESET_ALL}")
|
||||
|
||||
# Check if account is expired
|
||||
if usage_text.strip() == "150 / 150":
|
||||
print(f"{Fore.YELLOW}{EMOJI['INFO']} {self.translator.get('oauth.account_has_reached_maximum_usage', creating_new_account='creating new account') if self.translator else 'Account has reached maximum usage, creating new account...'}{Style.RESET_ALL}")
|
||||
|
||||
# Delete current account
|
||||
def check_usage_limits(usage_str):
|
||||
try:
|
||||
parts = usage_str.split('/')
|
||||
if len(parts) != 2:
|
||||
return False
|
||||
current = int(parts[0].strip())
|
||||
limit = int(parts[1].strip())
|
||||
return (limit == 50 and current >= 50) or (limit == 150 and current >= 150)
|
||||
except:
|
||||
return False
|
||||
|
||||
if check_usage_limits(usage_text):
|
||||
print(f"{Fore.YELLOW}{EMOJI['INFO']} {self.translator.get('oauth.account_has_reached_maximum_usage', deleting='deleting') if self.translator else 'Account has reached maximum usage, deleting...'}{Style.RESET_ALL}")
|
||||
if self._delete_current_account():
|
||||
# Start new authentication based on auth type
|
||||
print(f"{Fore.CYAN}{EMOJI['INFO']} {self.translator.get('oauth.starting_new_authentication_process') if self.translator else 'Starting new authentication process...'}{Style.RESET_ALL}")
|
||||
if self.auth_type == "google":
|
||||
return self.handle_google_auth()
|
||||
else: # github
|
||||
else:
|
||||
return self.handle_github_auth()
|
||||
else:
|
||||
print(f"{Fore.RED}{EMOJI['ERROR']} {self.translator.get('oauth.failed_to_delete_expired_account') if self.translator else 'Failed to delete expired account'}{Style.RESET_ALL}")
|
||||
|
||||
else:
|
||||
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} {self.translator.get('oauth.account_is_still_valid', usage=usage_text) if self.translator else f'Account is still valid (Usage: {usage_text})'}{Style.RESET_ALL}")
|
||||
except Exception as e:
|
||||
print(f"{Fore.YELLOW}{EMOJI['INFO']} {self.translator.get('oauth.could_not_check_usage_count', error=str(e)) if self.translator else f'Could not check usage count: {str(e)}'}{Style.RESET_ALL}")
|
||||
|
||||
@@ -462,7 +662,7 @@ class OAuthHandler:
|
||||
|
||||
# Setup browser
|
||||
if not self.setup_browser():
|
||||
print(f"{Fore.RED}{EMOJI['ERROR']} {self.translator.get('oauth.browser_failed')}{Style.RESET_ALL}")
|
||||
print(f"{Fore.RED}{EMOJI['ERROR']} {self.translator.get('oauth.browser_failed', error=str(e)) if self.translator else 'Browser failed to initialize'}{Style.RESET_ALL}")
|
||||
return False, None
|
||||
|
||||
# Navigate to auth URL
|
||||
@@ -593,11 +793,7 @@ class OAuthHandler:
|
||||
for cookie in cookies:
|
||||
if cookie.get("name") == "WorkosCursorSessionToken":
|
||||
value = cookie.get("value", "")
|
||||
if "::" in value:
|
||||
token = value.split("::")[-1]
|
||||
elif "%3A%3A" in value:
|
||||
token = value.split("%3A%3A")[-1]
|
||||
|
||||
token = get_token_from_cookie(value, self.translator)
|
||||
if token:
|
||||
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} {self.translator.get('oauth.authentication_successful') if self.translator else 'Authentication successful!'}{Style.RESET_ALL}")
|
||||
# Navigate to settings page
|
||||
@@ -622,57 +818,31 @@ class OAuthHandler:
|
||||
usage_text = usage_element.text
|
||||
print(f"{Fore.CYAN}{EMOJI['INFO']} {self.translator.get('oauth.usage_count', usage=usage_text) if self.translator else f'Usage count: {usage_text}'}{Style.RESET_ALL}")
|
||||
|
||||
# Check if account is expired
|
||||
if usage_text.strip() == "150 / 150":
|
||||
print(f"{Fore.YELLOW}{EMOJI['INFO']} {self.translator.get('oauth.account_has_reached_maximum_usage', deleting='deleting') if self.translator else 'Account has reached maximum usage, deleting...'}{Style.RESET_ALL}")
|
||||
|
||||
delete_js = """
|
||||
function deleteAccount() {
|
||||
return new Promise((resolve, reject) => {
|
||||
fetch('https://www.cursor.com/api/dashboard/delete-account', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
credentials: 'include'
|
||||
})
|
||||
.then(response => {
|
||||
if (response.status === 200) {
|
||||
resolve('Account deleted successfully');
|
||||
} else {
|
||||
reject('Failed to delete account: ' + response.status);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
reject('Error: ' + error);
|
||||
});
|
||||
});
|
||||
}
|
||||
return deleteAccount();
|
||||
"""
|
||||
|
||||
def check_usage_limits(usage_str):
|
||||
try:
|
||||
result = self.browser.run_js(delete_js)
|
||||
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} Delete account result: {result}{Style.RESET_ALL}")
|
||||
|
||||
# Navigate back to auth page and repeat authentication
|
||||
print(f"{Fore.CYAN}{EMOJI['INFO']} {self.translator.get('oauth.starting_re_authentication_process') if self.translator else 'Starting re-authentication process...'}{Style.RESET_ALL}")
|
||||
print(f"{Fore.CYAN}{EMOJI['INFO']} {self.translator.get('oauth.redirecting_to_authenticator_cursor_sh') if self.translator else 'Redirecting to authenticator.cursor.sh...'}{Style.RESET_ALL}")
|
||||
|
||||
# Explicitly navigate to the authentication page
|
||||
self.browser.get("https://authenticator.cursor.sh/sign-up")
|
||||
time.sleep(get_random_wait_time(self.config, 'page_load_wait'))
|
||||
|
||||
# Call handle_google_auth again to repeat the entire process
|
||||
print(f"{Fore.CYAN}{EMOJI['INFO']} {self.translator.get('oauth.starting_new_google_authentication') if self.translator else 'Starting new Google authentication...'}{Style.RESET_ALL}")
|
||||
return self.handle_google_auth()
|
||||
|
||||
except Exception as e:
|
||||
print(f"{Fore.RED}{EMOJI['ERROR']} {self.translator.get('oauth.failed_to_delete_account_or_re_authenticate', error=str(e)) if self.translator else f'Failed to delete account or re-authenticate: {str(e)}'}{Style.RESET_ALL}")
|
||||
parts = usage_str.split('/')
|
||||
if len(parts) != 2:
|
||||
return False
|
||||
current = int(parts[0].strip())
|
||||
limit = int(parts[1].strip())
|
||||
return (limit == 50 and current >= 50) or (limit == 150 and current >= 150)
|
||||
except:
|
||||
return False
|
||||
|
||||
if check_usage_limits(usage_text):
|
||||
print(f"{Fore.YELLOW}{EMOJI['INFO']} {self.translator.get('oauth.account_has_reached_maximum_usage', deleting='deleting') if self.translator else 'Account has reached maximum usage, deleting...'}{Style.RESET_ALL}")
|
||||
if self._delete_current_account():
|
||||
print(f"{Fore.CYAN}{EMOJI['INFO']} {self.translator.get('oauth.starting_new_authentication_process') if self.translator else 'Starting new authentication process...'}{Style.RESET_ALL}")
|
||||
if self.auth_type == "google":
|
||||
return self.handle_google_auth()
|
||||
else:
|
||||
return self.handle_github_auth()
|
||||
else:
|
||||
print(f"{Fore.RED}{EMOJI['ERROR']} {self.translator.get('oauth.failed_to_delete_expired_account') if self.translator else 'Failed to delete expired account'}{Style.RESET_ALL}")
|
||||
else:
|
||||
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} {self.translator.get('oauth.account_is_still_valid', usage=usage_text) if self.translator else f'Account is still valid (Usage: {usage_text})'}{Style.RESET_ALL}")
|
||||
except Exception as e:
|
||||
print(f"{Fore.YELLOW}{EMOJI['INFO']} {self.translator.get('oauth.could_not_find_usage_count', error=str(e)) if self.translator else f'Could not find usage count: {str(e)}'}{Style.RESET_ALL}")
|
||||
print(f"{Fore.YELLOW}{EMOJI['INFO']} {self.translator.get('oauth.could_not_check_usage_count', error=str(e)) if self.translator else f'Could not check usage count: {str(e)}'}{Style.RESET_ALL}")
|
||||
|
||||
# Remove the browser stay open prompt and input wait
|
||||
return True, {"email": actual_email, "token": token}
|
||||
@@ -686,10 +856,7 @@ class OAuthHandler:
|
||||
for cookie in cookies:
|
||||
if cookie.get("name") == "WorkosCursorSessionToken":
|
||||
value = cookie.get("value", "")
|
||||
if "::" in value:
|
||||
token = value.split("::")[-1]
|
||||
elif "%3A%3A" in value:
|
||||
token = value.split("%3A%3A")[-1]
|
||||
token = get_token_from_cookie(value, self.translator)
|
||||
if token:
|
||||
# Get email and check usage here too
|
||||
try:
|
||||
@@ -708,57 +875,31 @@ class OAuthHandler:
|
||||
usage_text = usage_element.text
|
||||
print(f"{Fore.CYAN}{EMOJI['INFO']} {self.translator.get('oauth.usage_count', usage=usage_text) if self.translator else f'Usage count: {usage_text}'}{Style.RESET_ALL}")
|
||||
|
||||
# Check if account is expired
|
||||
if usage_text.strip() == "150 / 150":
|
||||
print(f"{Fore.YELLOW}{EMOJI['INFO']} {self.translator.get('oauth.account_has_reached_maximum_usage', deleting='deleting') if self.translator else 'Account has reached maximum usage, deleting...'}{Style.RESET_ALL}")
|
||||
|
||||
delete_js = """
|
||||
function deleteAccount() {
|
||||
return new Promise((resolve, reject) => {
|
||||
fetch('https://www.cursor.com/api/dashboard/delete-account', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
credentials: 'include'
|
||||
})
|
||||
.then(response => {
|
||||
if (response.status === 200) {
|
||||
resolve('Account deleted successfully');
|
||||
} else {
|
||||
reject('Failed to delete account: ' + response.status);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
reject('Error: ' + error);
|
||||
});
|
||||
});
|
||||
}
|
||||
return deleteAccount();
|
||||
"""
|
||||
|
||||
def check_usage_limits(usage_str):
|
||||
try:
|
||||
result = self.browser.run_js(delete_js)
|
||||
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} Delete account result: {result}{Style.RESET_ALL}")
|
||||
|
||||
# Navigate back to auth page and repeat authentication
|
||||
print(f"{Fore.CYAN}{EMOJI['INFO']} {self.translator.get('oauth.starting_re_authentication_process') if self.translator else 'Starting re-authentication process...'}{Style.RESET_ALL}")
|
||||
print(f"{Fore.CYAN}{EMOJI['INFO']} {self.translator.get('oauth.redirecting_to_authenticator_cursor_sh') if self.translator else 'Redirecting to authenticator.cursor.sh...'}{Style.RESET_ALL}")
|
||||
|
||||
# Explicitly navigate to the authentication page
|
||||
self.browser.get("https://authenticator.cursor.sh/sign-up")
|
||||
time.sleep(get_random_wait_time(self.config, 'page_load_wait'))
|
||||
|
||||
# Call handle_google_auth again to repeat the entire process
|
||||
print(f"{Fore.CYAN}{EMOJI['INFO']} {self.translator.get('oauth.starting_new_google_authentication') if self.translator else 'Starting new Google authentication...'}{Style.RESET_ALL}")
|
||||
parts = usage_str.split('/')
|
||||
if len(parts) != 2:
|
||||
return False
|
||||
current = int(parts[0].strip())
|
||||
limit = int(parts[1].strip())
|
||||
return (limit == 50 and current >= 50) or (limit == 150 and current >= 150)
|
||||
except:
|
||||
return False
|
||||
|
||||
if check_usage_limits(usage_text):
|
||||
print(f"{Fore.YELLOW}{EMOJI['INFO']} {self.translator.get('oauth.account_has_reached_maximum_usage', deleting='deleting') if self.translator else 'Account has reached maximum usage, deleting...'}{Style.RESET_ALL}")
|
||||
if self._delete_current_account():
|
||||
print(f"{Fore.CYAN}{EMOJI['INFO']} {self.translator.get('oauth.starting_new_authentication_process') if self.translator else 'Starting new authentication process...'}{Style.RESET_ALL}")
|
||||
if self.auth_type == "google":
|
||||
return self.handle_google_auth()
|
||||
|
||||
except Exception as e:
|
||||
print(f"{Fore.RED}{EMOJI['ERROR']} {self.translator.get('oauth.failed_to_delete_account_or_re_authenticate', error=str(e)) if self.translator else f'Failed to delete account or re-authenticate: {str(e)}'}{Style.RESET_ALL}")
|
||||
else:
|
||||
return self.handle_github_auth()
|
||||
else:
|
||||
print(f"{Fore.RED}{EMOJI['ERROR']} {self.translator.get('oauth.failed_to_delete_expired_account') if self.translator else 'Failed to delete expired account'}{Style.RESET_ALL}")
|
||||
else:
|
||||
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} {self.translator.get('oauth.account_is_still_valid', usage=usage_text) if self.translator else f'Account is still valid (Usage: {usage_text})'}{Style.RESET_ALL}")
|
||||
except Exception as e:
|
||||
print(f"{Fore.YELLOW}{EMOJI['INFO']} {self.translator.get('oauth.could_not_find_usage_count', error=str(e)) if self.translator else f'Could not find usage count: {str(e)}'}{Style.RESET_ALL}")
|
||||
print(f"{Fore.YELLOW}{EMOJI['INFO']} {self.translator.get('oauth.could_not_check_usage_count', error=str(e)) if self.translator else f'Could not check usage count: {str(e)}'}{Style.RESET_ALL}")
|
||||
|
||||
# Remove the browser stay open prompt and input wait
|
||||
return True, {"email": actual_email, "token": token}
|
||||
@@ -812,10 +953,7 @@ class OAuthHandler:
|
||||
if name == "WorkosCursorSessionToken":
|
||||
try:
|
||||
value = cookie.get("value", "")
|
||||
if "::" in value:
|
||||
token = value.split("::")[-1]
|
||||
elif "%3A%3A" in value:
|
||||
token = value.split("%3A%3A")[-1]
|
||||
token = get_token_from_cookie(value, self.translator)
|
||||
except Exception as e:
|
||||
print(f"{Fore.YELLOW}{EMOJI['INFO']} {self.translator.get('oauth.token_extraction_error', error=str(e)) if self.translator else f'Token extraction error: {str(e)}'}{Style.RESET_ALL}")
|
||||
elif name == "cursor_email":
|
||||
|
||||
@@ -8,12 +8,14 @@ import sqlite3
|
||||
import platform
|
||||
import re
|
||||
import tempfile
|
||||
import glob
|
||||
from colorama import Fore, Style, init
|
||||
from typing import Tuple
|
||||
import configparser
|
||||
from new_signup import get_user_documents_path
|
||||
import traceback
|
||||
from config import get_config
|
||||
from datetime import datetime
|
||||
|
||||
# Initialize colorama
|
||||
init()
|
||||
@@ -25,7 +27,7 @@ EMOJI = {
|
||||
"SUCCESS": "✅",
|
||||
"ERROR": "❌",
|
||||
"INFO": "ℹ️",
|
||||
"RESET": "<EFBFBD><EFBFBD>",
|
||||
"RESET": "🔄",
|
||||
"WARNING": "⚠️",
|
||||
}
|
||||
|
||||
@@ -46,9 +48,28 @@ def get_cursor_paths(translator=None) -> Tuple[str, str]:
|
||||
default_paths = {
|
||||
"Darwin": "/Applications/Cursor.app/Contents/Resources/app",
|
||||
"Windows": os.path.join(os.getenv("LOCALAPPDATA", ""), "Programs", "Cursor", "resources", "app"),
|
||||
"Linux": ["/opt/Cursor/resources/app", "/usr/share/cursor/resources/app", os.path.expanduser("~/.local/share/cursor/resources/app")]
|
||||
"Linux": ["/opt/Cursor/resources/app", "/usr/share/cursor/resources/app", os.path.expanduser("~/.local/share/cursor/resources/app"), "/usr/lib/cursor/app/"]
|
||||
}
|
||||
|
||||
if system == "Linux":
|
||||
# Look for extracted AppImage with correct usr structure
|
||||
extracted_usr_paths = glob.glob(os.path.expanduser("~/squashfs-root/usr/share/cursor/resources/app"))
|
||||
# Also check current directory for extraction without home path prefix
|
||||
current_dir_paths = glob.glob("squashfs-root/usr/share/cursor/resources/app")
|
||||
|
||||
# Add any found paths to the Linux paths list
|
||||
default_paths["Linux"].extend(extracted_usr_paths)
|
||||
default_paths["Linux"].extend(current_dir_paths)
|
||||
|
||||
# Print debug information
|
||||
print(f"{Fore.CYAN}{EMOJI['INFO']} Available paths found:{Style.RESET_ALL}")
|
||||
for path in default_paths["Linux"]:
|
||||
if os.path.exists(path):
|
||||
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} {path} (exists){Style.RESET_ALL}")
|
||||
else:
|
||||
print(f"{Fore.RED}{EMOJI['ERROR']} {path} (not found){Style.RESET_ALL}")
|
||||
|
||||
|
||||
# If config doesn't exist, create it with default paths
|
||||
if not os.path.exists(config_file):
|
||||
for section in ['MacPaths', 'WindowsPaths', 'LinuxPaths']:
|
||||
@@ -159,6 +180,14 @@ def get_cursor_machine_id_path(translator=None) -> str:
|
||||
def get_workbench_cursor_path(translator=None) -> str:
|
||||
"""Get Cursor workbench.desktop.main.js path"""
|
||||
system = platform.system()
|
||||
|
||||
# Read configuration
|
||||
config_dir = os.path.join(get_user_documents_path(), ".cursor-free-vip")
|
||||
config_file = os.path.join(config_dir, "config.ini")
|
||||
config = configparser.ConfigParser()
|
||||
|
||||
if os.path.exists(config_file):
|
||||
config.read(config_file)
|
||||
|
||||
paths_map = {
|
||||
"Darwin": { # macOS
|
||||
@@ -166,14 +195,19 @@ def get_workbench_cursor_path(translator=None) -> str:
|
||||
"main": "out/vs/workbench/workbench.desktop.main.js"
|
||||
},
|
||||
"Windows": {
|
||||
"base": os.path.join(os.getenv("LOCALAPPDATA", ""), "Programs", "Cursor", "resources", "app"),
|
||||
"main": "out/vs/workbench/workbench.desktop.main.js"
|
||||
"main": "out\\vs\\workbench\\workbench.desktop.main.js"
|
||||
},
|
||||
"Linux": {
|
||||
"bases": ["/opt/Cursor/resources/app", "/usr/share/cursor/resources/app"],
|
||||
"bases": ["/opt/Cursor/resources/app", "/usr/share/cursor/resources/app", "/usr/lib/cursor/app/"],
|
||||
"main": "out/vs/workbench/workbench.desktop.main.js"
|
||||
}
|
||||
}
|
||||
|
||||
if system == "Linux":
|
||||
# Add extracted AppImage with correct usr structure
|
||||
extracted_usr_paths = glob.glob(os.path.expanduser("~/squashfs-root/usr/share/cursor/resources/app"))
|
||||
|
||||
paths_map["Linux"]["bases"].extend(extracted_usr_paths)
|
||||
|
||||
if system not in paths_map:
|
||||
raise OSError(translator.get('reset.unsupported_os', system=system) if translator else f"不支持的操作系统: {system}")
|
||||
@@ -181,11 +215,19 @@ def get_workbench_cursor_path(translator=None) -> str:
|
||||
if system == "Linux":
|
||||
for base in paths_map["Linux"]["bases"]:
|
||||
main_path = os.path.join(base, paths_map["Linux"]["main"])
|
||||
print(f"{Fore.CYAN}{EMOJI['INFO']} Checking path: {main_path}{Style.RESET_ALL}")
|
||||
if os.path.exists(main_path):
|
||||
return main_path
|
||||
raise OSError(translator.get('reset.linux_path_not_found') if translator else "在 Linux 系统上未找到 Cursor 安装路径")
|
||||
|
||||
base_path = paths_map[system]["base"]
|
||||
if system == "Windows":
|
||||
base_path = config.get('WindowsPaths', 'cursor_path')
|
||||
elif system == "Darwin":
|
||||
base_path = paths_map[system]["base"]
|
||||
else: # Linux
|
||||
# For Linux, we've already checked all bases in the loop above
|
||||
# If we're here, it means none of the bases worked, so we'll use the first one
|
||||
base_path = paths_map[system]["bases"][0]
|
||||
|
||||
main_path = os.path.join(base_path, paths_map[system]["main"])
|
||||
|
||||
if not os.path.exists(main_path):
|
||||
@@ -297,37 +339,40 @@ def modify_workbench_js(file_path: str, translator=None) -> bool:
|
||||
with open(file_path, "r", encoding="utf-8", errors="ignore") as main_file:
|
||||
content = main_file.read()
|
||||
|
||||
if sys.platform == "win32":
|
||||
# Define replacement patterns
|
||||
CButton_old_pattern = r'$(k,E(Ks,{title:"Upgrade to Pro",size:"small",get codicon(){return F.rocket},get onClick(){return t.pay}}),null)'
|
||||
CButton_new_pattern = r'$(k,E(Ks,{title:"yeongpin GitHub",size:"small",get codicon(){return F.rocket},get onClick(){return function(){window.open("https://github.com/yeongpin/cursor-free-vip","_blank")}}}),null)'
|
||||
elif sys.platform == "linux":
|
||||
CButton_old_pattern = r'$(k,E(Ks,{title:"Upgrade to Pro",size:"small",get codicon(){return F.rocket},get onClick(){return t.pay}}),null)'
|
||||
CButton_new_pattern = r'$(k,E(Ks,{title:"yeongpin GitHub",size:"small",get codicon(){return F.rocket},get onClick(){return function(){window.open("https://github.com/yeongpin/cursor-free-vip","_blank")}}}),null)'
|
||||
elif sys.platform == "darwin":
|
||||
CButton_old_pattern = r'M(x,I(as,{title:"Upgrade to Pro",size:"small",get codicon(){return $.rocket},get onClick(){return t.pay}}),null)'
|
||||
CButton_new_pattern = r'M(x,I(as,{title:"yeongpin GitHub",size:"small",get codicon(){return $.rocket},get onClick(){return function(){window.open("https://github.com/yeongpin/cursor-free-vip","_blank")}}}),null)'
|
||||
patterns = {
|
||||
# 通用按钮替换模式
|
||||
r'B(k,D(Ln,{title:"Upgrade to Pro",size:"small",get codicon(){return A.rocket},get onClick(){return t.pay}}),null)': r'B(k,D(Ln,{title:"yeongpin GitHub",size:"small",get codicon(){return A.github},get onClick(){return function(){window.open("https://github.com/yeongpin/cursor-free-vip","_blank")}}}),null)',
|
||||
|
||||
# Windows/Linux/Mac 通用按钮替换模式
|
||||
r'M(x,I(as,{title:"Upgrade to Pro",size:"small",get codicon(){return $.rocket},get onClick(){return t.pay}}),null)': r'M(x,I(as,{title:"yeongpin GitHub",size:"small",get codicon(){return $.rocket},get onClick(){return function(){window.open("https://github.com/yeongpin/cursor-free-vip","_blank")}}}),null)',
|
||||
|
||||
# Badge 替换
|
||||
r'<div>Pro Trial': r'<div>Pro',
|
||||
|
||||
CBadge_old_pattern = r'<div>Pro Trial'
|
||||
CBadge_new_pattern = r'<div>Pro'
|
||||
r'py-1">Auto-select': r'py-1">Bypass-Version-Pin',
|
||||
|
||||
#
|
||||
r'async getEffectiveTokenLimit(e){const n=e.modelName;if(!n)return 2e5;':r'async getEffectiveTokenLimit(e){return 9000000;const n=e.modelName;if(!n)return 9e5;',
|
||||
# Pro
|
||||
r'var DWr=ne("<div class=settings__item_description>You are currently signed in with <strong></strong>.");': r'var DWr=ne("<div class=settings__item_description>You are currently signed in with <strong></strong>. <h1>Pro</h1>");',
|
||||
|
||||
# Toast 替换
|
||||
r'notifications-toasts': r'notifications-toasts hidden'
|
||||
}
|
||||
|
||||
CToast_old_pattern = r'notifications-toasts'
|
||||
CToast_new_pattern = r'notifications-toasts hidden'
|
||||
|
||||
# Replace content
|
||||
content = content.replace(CButton_old_pattern, CButton_new_pattern)
|
||||
content = content.replace(CBadge_old_pattern, CBadge_new_pattern)
|
||||
content = content.replace(CToast_old_pattern, CToast_new_pattern)
|
||||
# 使用patterns进行替换
|
||||
for old_pattern, new_pattern in patterns.items():
|
||||
content = content.replace(old_pattern, new_pattern)
|
||||
|
||||
# Write to temporary file
|
||||
tmp_file.write(content)
|
||||
tmp_path = tmp_file.name
|
||||
|
||||
# Backup original file
|
||||
backup_path = file_path + ".backup"
|
||||
if os.path.exists(backup_path):
|
||||
os.remove(backup_path)
|
||||
# Backup original file with timestamp
|
||||
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
||||
backup_path = f"{file_path}.backup.{timestamp}"
|
||||
shutil.copy2(file_path, backup_path)
|
||||
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} {translator.get('reset.backup_created', path=backup_path)}{Style.RESET_ALL}")
|
||||
|
||||
# Move temporary file to original position
|
||||
if os.path.exists(file_path):
|
||||
@@ -374,7 +419,10 @@ def modify_main_js(main_path: str, translator) -> bool:
|
||||
tmp_file.write(content)
|
||||
tmp_path = tmp_file.name
|
||||
|
||||
shutil.copy2(main_path, main_path + ".old")
|
||||
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
||||
backup_path = f"{main_path}.old.{timestamp}"
|
||||
shutil.copy2(main_path, backup_path)
|
||||
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} {translator.get('reset.backup_created', path=backup_path)}{Style.RESET_ALL}")
|
||||
shutil.move(tmp_path, main_path)
|
||||
|
||||
os.chmod(main_path, original_mode)
|
||||
@@ -424,7 +472,8 @@ def patch_cursor_get_machine_id(translator) -> bool:
|
||||
print(f"{Fore.CYAN}{EMOJI['INFO']} {translator.get('reset.version_check_passed')}{Style.RESET_ALL}")
|
||||
|
||||
# Backup file
|
||||
backup_path = main_path + ".bak"
|
||||
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
||||
backup_path = f"{main_path}.bak.{timestamp}"
|
||||
if not os.path.exists(backup_path):
|
||||
shutil.copy2(main_path, backup_path)
|
||||
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} {translator.get('reset.backup_created', path=backup_path)}{Style.RESET_ALL}")
|
||||
@@ -601,8 +650,8 @@ class MachineIDResetter:
|
||||
winreg.SetValueEx(key, "MachineGuid", 0, winreg.REG_SZ, new_guid)
|
||||
winreg.CloseKey(key)
|
||||
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} {self.translator.get('reset.windows_machine_guid_updated')}{Style.RESET_ALL}")
|
||||
except PermissionError:
|
||||
print(f"{Fore.RED}{EMOJI['ERROR']} {self.translator.get('reset.permission_denied')}{Style.RESET_ALL}")
|
||||
except PermissionError as e:
|
||||
print(f"{Fore.RED}{EMOJI['ERROR']} {self.translator.get('reset.permission_denied', error=str(e))}{Style.RESET_ALL}")
|
||||
raise
|
||||
except Exception as e:
|
||||
print(f"{Fore.RED}{EMOJI['ERROR']} {self.translator.get('reset.update_windows_machine_guid_failed', error=str(e))}{Style.RESET_ALL}")
|
||||
@@ -680,12 +729,10 @@ class MachineIDResetter:
|
||||
with open(self.db_path, "r", encoding="utf-8") as f:
|
||||
config = json.load(f)
|
||||
|
||||
backup_path = self.db_path + ".bak"
|
||||
if not os.path.exists(backup_path):
|
||||
print(f"{Fore.YELLOW}{EMOJI['BACKUP']} {self.translator.get('reset.creating_backup')}: {backup_path}{Style.RESET_ALL}")
|
||||
shutil.copy2(self.db_path, backup_path)
|
||||
else:
|
||||
print(f"{Fore.YELLOW}{EMOJI['INFO']} {self.translator.get('reset.backup_exists')}{Style.RESET_ALL}")
|
||||
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
||||
backup_path = f"{self.db_path}.bak.{timestamp}"
|
||||
print(f"{Fore.YELLOW}{EMOJI['BACKUP']} {self.translator.get('reset.creating_backup')}: {backup_path}{Style.RESET_ALL}")
|
||||
shutil.copy2(self.db_path, backup_path)
|
||||
|
||||
print(f"{Fore.CYAN}{EMOJI['RESET']} {self.translator.get('reset.generating')}...{Style.RESET_ALL}")
|
||||
new_ids = self.generate_new_ids()
|
||||
@@ -749,7 +796,8 @@ class MachineIDResetter:
|
||||
|
||||
# Create backup if file exists
|
||||
if os.path.exists(machine_id_path):
|
||||
backup_path = machine_id_path + ".backup"
|
||||
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
||||
backup_path = f"{machine_id_path}.backup.{timestamp}"
|
||||
try:
|
||||
shutil.copy2(machine_id_path, backup_path)
|
||||
print(f"{Fore.GREEN}{EMOJI['INFO']} {self.translator.get('reset.backup_created', path=backup_path) if self.translator else f'Backup created at: {backup_path}'}{Style.RESET_ALL}")
|
||||
@@ -786,4 +834,4 @@ def run(translator=None):
|
||||
|
||||
if __name__ == "__main__":
|
||||
from main import translator as main_translator
|
||||
run(main_translator)
|
||||
run(main_translator)
|
||||
|
||||
@@ -14,6 +14,7 @@ import configparser
|
||||
from new_signup import get_user_documents_path
|
||||
import traceback
|
||||
from config import get_config
|
||||
import glob
|
||||
|
||||
# Initialize colorama
|
||||
init()
|
||||
@@ -25,7 +26,7 @@ EMOJI = {
|
||||
"SUCCESS": "✅",
|
||||
"ERROR": "❌",
|
||||
"INFO": "ℹ️",
|
||||
"RESET": "<EFBFBD><EFBFBD>",
|
||||
"RESET": "🔄",
|
||||
"WARNING": "⚠️",
|
||||
}
|
||||
|
||||
@@ -49,6 +50,24 @@ def get_cursor_paths(translator=None) -> Tuple[str, str]:
|
||||
"Linux": ["/opt/Cursor/resources/app", "/usr/share/cursor/resources/app", os.path.expanduser("~/.local/share/cursor/resources/app")]
|
||||
}
|
||||
|
||||
if system == "Linux":
|
||||
# Look for extracted AppImage directories - with usr structure
|
||||
extracted_usr_paths = glob.glob(os.path.expanduser("~/squashfs-root/usr/share/cursor/resources/app"))
|
||||
# Check current directory for extraction without home path prefix
|
||||
current_dir_paths = glob.glob("squashfs-root/usr/share/cursor/resources/app")
|
||||
|
||||
# Add all paths to the Linux paths list
|
||||
default_paths["Linux"].extend(extracted_usr_paths)
|
||||
default_paths["Linux"].extend(current_dir_paths)
|
||||
|
||||
# Print debug info for troubleshooting
|
||||
print(f"{Fore.CYAN}{EMOJI['INFO']} Available paths found:{Style.RESET_ALL}")
|
||||
for path in default_paths["Linux"]:
|
||||
if os.path.exists(path):
|
||||
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} {path} (exists){Style.RESET_ALL}")
|
||||
else:
|
||||
print(f"{Fore.RED}{EMOJI['ERROR']} {path} (not found){Style.RESET_ALL}")
|
||||
|
||||
# If config doesn't exist, create it with default paths
|
||||
if not os.path.exists(config_file):
|
||||
for section in ['MacPaths', 'WindowsPaths', 'LinuxPaths']:
|
||||
@@ -175,10 +194,16 @@ def get_workbench_cursor_path(translator=None) -> str:
|
||||
}
|
||||
}
|
||||
|
||||
if system not in paths_map:
|
||||
raise OSError(translator.get('reset.unsupported_os', system=system) if translator else f"不支持的操作系统: {system}")
|
||||
|
||||
if system == "Linux":
|
||||
# Look for extracted AppImage with correct usr structure
|
||||
extracted_usr_paths = glob.glob(os.path.expanduser("~/squashfs-root/usr/share/cursor/resources/app"))
|
||||
# Check current directory for extraction
|
||||
current_dir_paths = glob.glob("squashfs-root/usr/share/cursor/resources/app")
|
||||
|
||||
|
||||
paths_map["Linux"]["bases"].extend(extracted_usr_paths)
|
||||
paths_map["Linux"]["bases"].extend(current_dir_paths)
|
||||
|
||||
for base in paths_map["Linux"]["bases"]:
|
||||
main_path = os.path.join(base, paths_map["Linux"]["main"])
|
||||
if os.path.exists(main_path):
|
||||
@@ -786,4 +811,4 @@ def run(translator=None):
|
||||
|
||||
if __name__ == "__main__":
|
||||
from main import translator as main_translator
|
||||
run(main_translator)
|
||||
run(main_translator)
|
||||
148
utils.py
148
utils.py
@@ -9,15 +9,147 @@ def get_user_documents_path():
|
||||
return os.path.expanduser("~\\Documents")
|
||||
else:
|
||||
return os.path.expanduser("~/Documents")
|
||||
|
||||
def get_default_chrome_path():
|
||||
"""Get default Chrome path"""
|
||||
if sys.platform == "win32":
|
||||
return r"C:\Program Files\Google\Chrome\Application\chrome.exe"
|
||||
elif sys.platform == "darwin":
|
||||
return "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
|
||||
|
||||
def get_default_driver_path(browser_type='chrome'):
|
||||
"""Get default driver path based on browser type"""
|
||||
browser_type = browser_type.lower()
|
||||
if browser_type == 'chrome':
|
||||
return get_default_chrome_driver_path()
|
||||
elif browser_type == 'edge':
|
||||
return get_default_edge_driver_path()
|
||||
elif browser_type == 'firefox':
|
||||
return get_default_firefox_driver_path()
|
||||
elif browser_type == 'brave':
|
||||
# Brave 使用 Chrome 的 driver
|
||||
return get_default_chrome_driver_path()
|
||||
else:
|
||||
return "/usr/bin/google-chrome"
|
||||
# Default to Chrome if browser type is unknown
|
||||
return get_default_chrome_driver_path()
|
||||
|
||||
def get_default_chrome_driver_path():
|
||||
"""Get default Chrome driver path"""
|
||||
if sys.platform == "win32":
|
||||
return os.path.join(os.path.dirname(os.path.abspath(__file__)), "drivers", "chromedriver.exe")
|
||||
elif sys.platform == "darwin":
|
||||
return os.path.join(os.path.dirname(os.path.abspath(__file__)), "drivers", "chromedriver")
|
||||
else:
|
||||
return "/usr/local/bin/chromedriver"
|
||||
|
||||
def get_default_edge_driver_path():
|
||||
"""Get default Edge driver path"""
|
||||
if sys.platform == "win32":
|
||||
return os.path.join(os.path.dirname(os.path.abspath(__file__)), "drivers", "msedgedriver.exe")
|
||||
elif sys.platform == "darwin":
|
||||
return os.path.join(os.path.dirname(os.path.abspath(__file__)), "drivers", "msedgedriver")
|
||||
else:
|
||||
return "/usr/local/bin/msedgedriver"
|
||||
|
||||
def get_default_firefox_driver_path():
|
||||
"""Get default Firefox driver path"""
|
||||
if sys.platform == "win32":
|
||||
return os.path.join(os.path.dirname(os.path.abspath(__file__)), "drivers", "geckodriver.exe")
|
||||
elif sys.platform == "darwin":
|
||||
return os.path.join(os.path.dirname(os.path.abspath(__file__)), "drivers", "geckodriver")
|
||||
else:
|
||||
return "/usr/local/bin/geckodriver"
|
||||
|
||||
def get_default_brave_driver_path():
|
||||
"""Get default Brave driver path (uses Chrome driver)"""
|
||||
# Brave 浏览器基于 Chromium,所以使用相同的 chromedriver
|
||||
return get_default_chrome_driver_path()
|
||||
|
||||
def get_default_browser_path(browser_type='chrome'):
|
||||
"""Get default browser executable path"""
|
||||
browser_type = browser_type.lower()
|
||||
|
||||
if sys.platform == "win32":
|
||||
if browser_type == 'chrome':
|
||||
# 尝试在 PATH 中找到 Chrome
|
||||
try:
|
||||
import shutil
|
||||
chrome_in_path = shutil.which("chrome")
|
||||
if chrome_in_path:
|
||||
return chrome_in_path
|
||||
except:
|
||||
pass
|
||||
# 使用默认路径
|
||||
return r"C:\Program Files\Google\Chrome\Application\chrome.exe"
|
||||
elif browser_type == 'edge':
|
||||
return r"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe"
|
||||
elif browser_type == 'firefox':
|
||||
return r"C:\Program Files\Mozilla Firefox\firefox.exe"
|
||||
elif browser_type == 'opera':
|
||||
# 尝试多个可能的 Opera 路径
|
||||
opera_paths = [
|
||||
r"C:\Program Files\Opera\opera.exe",
|
||||
r"C:\Program Files (x86)\Opera\opera.exe",
|
||||
os.path.join(os.environ.get('LOCALAPPDATA', ''), 'Programs', 'Opera', 'launcher.exe'),
|
||||
os.path.join(os.environ.get('LOCALAPPDATA', ''), 'Programs', 'Opera', 'opera.exe'),
|
||||
os.path.join(os.environ.get('LOCALAPPDATA', ''), 'Programs', 'Opera GX', 'launcher.exe'),
|
||||
os.path.join(os.environ.get('LOCALAPPDATA', ''), 'Programs', 'Opera GX', 'opera.exe')
|
||||
]
|
||||
for path in opera_paths:
|
||||
if os.path.exists(path):
|
||||
return path
|
||||
return opera_paths[0] # 返回第一个路径,即使它不存在
|
||||
elif browser_type == 'brave':
|
||||
# Brave 浏览器的默认安装路径
|
||||
paths = [
|
||||
os.path.join(os.environ.get('PROGRAMFILES', ''), 'BraveSoftware/Brave-Browser/Application/brave.exe'),
|
||||
os.path.join(os.environ.get('PROGRAMFILES(X86)', ''), 'BraveSoftware/Brave-Browser/Application/brave.exe'),
|
||||
os.path.join(os.environ.get('LOCALAPPDATA', ''), 'BraveSoftware/Brave-Browser/Application/brave.exe')
|
||||
]
|
||||
for path in paths:
|
||||
if os.path.exists(path):
|
||||
return path
|
||||
return paths[0] # 返回第一个路径,即使它不存在
|
||||
|
||||
elif sys.platform == "darwin":
|
||||
if browser_type == 'chrome':
|
||||
return "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
|
||||
elif browser_type == 'edge':
|
||||
return "/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge"
|
||||
elif browser_type == 'firefox':
|
||||
return "/Applications/Firefox.app/Contents/MacOS/firefox"
|
||||
elif browser_type == 'brave':
|
||||
return "/Applications/Brave Browser.app/Contents/MacOS/Brave Browser"
|
||||
elif browser_type == 'opera':
|
||||
return "/Applications/Opera.app/Contents/MacOS/Opera"
|
||||
|
||||
else: # Linux
|
||||
if browser_type == 'chrome':
|
||||
# 尝试多种可能的名称
|
||||
chrome_names = ["google-chrome", "chrome", "chromium", "chromium-browser"]
|
||||
for name in chrome_names:
|
||||
try:
|
||||
import shutil
|
||||
path = shutil.which(name)
|
||||
if path:
|
||||
return path
|
||||
except:
|
||||
pass
|
||||
return "/usr/bin/google-chrome"
|
||||
elif browser_type == 'edge':
|
||||
return "/usr/bin/microsoft-edge"
|
||||
elif browser_type == 'firefox':
|
||||
return "/usr/bin/firefox"
|
||||
elif browser_type == 'opera':
|
||||
return "/usr/bin/opera"
|
||||
elif browser_type == 'brave':
|
||||
# 尝试常见的 Brave 路径
|
||||
brave_names = ["brave", "brave-browser"]
|
||||
for name in brave_names:
|
||||
try:
|
||||
import shutil
|
||||
path = shutil.which(name)
|
||||
if path:
|
||||
return path
|
||||
except:
|
||||
pass
|
||||
return "/usr/bin/brave-browser"
|
||||
|
||||
# 如果找不到指定的浏览器类型,则返回 Chrome 的路径
|
||||
return get_default_browser_path('chrome')
|
||||
|
||||
def get_linux_cursor_path():
|
||||
"""Get Linux Cursor path"""
|
||||
|
||||
Reference in New Issue
Block a user