Web Automation Flow
Relevant source files
The following files were used as context for generating this wiki page:
The Web Automation Flow within the cursor-free-vip project is a suite of scripts designed to automate interactions with the Cursor application and its associated web services. The primary purpose is to manage the user's trial status by automating account registration, resetting application state, and modifying local application files to bypass certain restrictions. This is achieved through a combination of browser automation for web interactions and direct file system manipulation for patching application files.
The core of the system is a command-line interface presented to the user, which orchestrates various modules for tasks such as creating new accounts via Google/GitHub OAuth, performing a full reset of the Cursor application's settings and identifiers, and bypassing version checks or token limits. The automation is designed to be cross-platform, with specific logic to handle file paths and system commands for Windows, macOS, and Linux.
Core Components and Entry Point
The main entry point for all automation tasks is main.py. This script presents a menu-driven interface to the user, allowing them to select from various operations. It uses a Translator class to provide a localized experience based on the user's system language, loading strings from JSON files in the locales/ directory.
Sources: main.py:313-383, locales/en.json:2-30
Main Menu Operations
The main menu orchestrates calls to different modules based on user selection.
| Choice | Description | Module/Function Called |
|---|---|---|
| 1 | Reset Machine ID | reset_machine_manual.run() |
| 2 | Register New Cursor Account | cursor_register_manual.main() |
| 5 | Register with Self Google Account | oauth_auth.main('google', ...) |
| 6 | Register with Self GitHub Account | oauth_auth.main('github', ...) |
| 8 | Totally Reset Cursor | totally_reset_cursor.run() |
| 11 | Bypass Cursor Version Check | bypass_version.main() |
| 13 | Bypass Token Limit | bypass_token_limit.run() |
| 15 | Delete Cursor Google Account | delete_cursor_google.main() |
Sources: main.py:313-383
The following diagram illustrates the high-level module interaction originating from the main script.
Sources: main.py:313-383
Account Registration and Authentication
The system provides multiple automated methods for creating and authenticating Cursor accounts. This is primarily handled by oauth_auth.py for Google and GitHub, and new_signup.py for manual registration flows.
OAuth Authentication Flow (Google/GitHub)
The oauth_auth.py script automates the process of logging into Cursor using a third-party OAuth provider (Google or GitHub). It launches a browser, navigates to the Cursor authentication page, and waits for the user to complete the login process. After successful authentication, it extracts the session token.
The process is as follows:
- Initialize the
OAuthHandlerwith the authentication type ('google' or 'github'). - Set up the browser, detecting the platform and locating the browser executable and user data directory.
- Navigate to the Cursor authentication page.
- The script waits for the user to manually select their account and complete the OAuth flow.
- Once the page redirects back to a Cursor URL, the script checks for authentication success and extracts account information.
Sources: oauth_auth.py
This sequence diagram shows the interaction between the script, the user, and the web services during OAuth authentication.
Sources: oauth_auth.py:304-338
Cursor Application Modification
A key feature of the automation flow is the ability to modify the local Cursor application files to reset its state or bypass limitations. This is handled by scripts like totally_reset_cursor.py, reset_machine_manual.py, and bypass_token_limit.py.
Full Application Reset
The totally_reset_cursor.py script performs a comprehensive reset of the Cursor application. This includes:
- Locating Files: Finding critical Cursor directories and files across different operating systems.
- Deleting Configuration: Removing known trial, license, and configuration files, including a deep scan for other potential files.
- Resetting Machine ID: Generating new, randomized machine identifiers (
devDeviceId,macMachineId,machineId). - Updating Storage: Writing the new IDs to
storage.jsonand the SQLite database (state.vscdb). - Patching Application Code: Modifying JavaScript files like
workbench.desktop.main.jsandmain.jsto alter application behavior.
Sources: totally_reset_cursor.py
The following flowchart illustrates the "Totally Reset" process.
File Patching
The scripts directly modify JavaScript files within the Cursor application bundle to change its functionality. This is done by reading the file content, performing string replacements based on predefined patterns, and writing the modified content back to the file.
Key modifications in workbench.desktop.main.js include:
| Original Behavior | Patched Behavior | Source File |
|---|---|---|
| "Upgrade to Pro" button | Button links to the cursor-free-vip GitHub repo | totally_reset_cursor.py |
| "Pro Trial" badge | Badge displays "Pro" | totally_reset_cursor.py |
| Limited token count | Token limit is bypassed (returns a large number) | bypass_token_limit.py |
| Toast notifications visible | Toast notifications are hidden via CSS class | totally_reset_cursor.py |
Sources: totally_reset_cursor.py:442-482, bypass_token_limit.py:120-158, reset_machine_manual.py:360-418
The modify_workbench_js function demonstrates this string replacement technique.
# Source: bypass_token_limit.py:120-158
def modify_workbench_js(file_path: str, translator=None) -> bool:
"""
Modify file content
"""
try:
# ... (file permission handling) ...
with open(file_path, "r", encoding="utf-8", errors="ignore") as main_file:
content = main_file.read()
patterns = {
# ... (patterns for button replacement) ...
# Bypass token limit
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;',
# Change UI to show "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>");',
# Hide toast notifications
r'notifications-toasts': r'notifications-toasts hidden'
}
for old_pattern, new_pattern in patterns.items():
content = content.replace(old_pattern, new_pattern)
# ... (write file back) ...
return True
# ... (error handling) ...
Path and Configuration Management
The scripts are designed to work on Windows, macOS, and Linux. This requires robust logic for locating the Cursor application and configuration files, which are stored in different locations on each OS.
Functions like get_cursor_paths, get_workbench_cursor_path, and get_cursor_machine_id_path are used to abstract away these differences. They check a list of default paths and also allow for user-configured paths via a config.ini file.
Sources: totally_reset_cursor.py:53-270, reset_machine_manual.py:54-271
Default Application Paths
The table below summarizes the default paths checked by the scripts to locate the Cursor application resources.
| Operating System | Default Path(s) | Source Function |
|---|---|---|
| Windows | %LOCALAPPDATA%\Programs\Cursor\resources\app | get_cursor_paths |
| macOS | /Applications/Cursor.app/Contents/Resources/app | get_cursor_paths |
| Linux | /opt/Cursor/resources/app/usr/share/cursor/resources/app~/.local/share/cursor/resources/app/usr/lib/cursor/app/ | get_cursor_paths |
Sources: totally_reset_cursor.py:53-172, reset_machine_manual.py:54-173
This cross-platform support ensures that the file modification and reset features can be executed regardless of the user's environment. The scripts also handle AppImage extractions on Linux by searching for squashfs-root directories.
Sources: totally_reset_cursor.py:73-80