diff --git a/README.md b/README.md index 99d195b..3e3fa46 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,32 @@ Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManage ``` 5. Save the file and restart Cursor +#### Script Method (Alternative) + +If you prefer using scripts directly, you can use these platform-specific scripts: + +**For Linux/macOS:** +1. Download the [cursor_modifier.sh](scripts/cursor_modifier.sh) +2. Make it executable: + ```bash + chmod +x cursor_modifier.sh + ``` +3. Run with sudo: + ```bash + sudo ./cursor_modifier.sh + ``` + +**For Windows:** +1. Download the [cursor_modifier.bat](scripts/cursor_modifier.bat) +2. Right-click and "Run as administrator" + +These scripts will: +- Automatically detect system language (English/Chinese) +- Check for and close any running Cursor instances +- Generate new random IDs +- Update the configuration file +- Show the results with a nice UI + ### 🔧 Technical Details The program modifies Cursor's `storage.json` config file: @@ -135,6 +161,32 @@ Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManage ``` 5. ä¿å­˜æ–‡ä»¶å¹¶é‡å¯ Cursor +#### 脚本方法(替代方法) + +如果您喜欢直接使用脚本,å¯ä»¥ä½¿ç”¨è¿™äº›ç‰¹å®šå¹³å°çš„脚本: + +**适用于 Linux/macOS:** +1. 下载 [cursor_modifier.sh](scripts/cursor_modifier.sh) +2. ä½¿å…¶å¯æ‰§è¡Œï¼š + ```bash + chmod +x cursor_modifier.sh + ``` +3. 用 sudo è¿è¡Œ + ```bash + sudo ./cursor_modifier.sh + ``` + +**适用于 Windows:** +1. 下载 [cursor_modifier.bat](脚本/cursor_modifier.bat) +2. å³é”®å•击并 “以管ç†å‘˜èº«ä»½è¿è¡Œâ€ã€‚ + +这些脚本将 +- 自动检测系统语言(英语/中文) +- 检查并关闭任何正在è¿è¡Œçš„光标实例 +- ç”Ÿæˆæ–°çš„éšæœº ID +- æ›´æ–°é…置文件 +- ä»¥æ¼‚äº®çš„ç”¨æˆ·ç•Œé¢æ˜¾ç¤ºç»“æžœ + ### 🔧 技术细节 程åºä¿®æ”¹Cursorçš„`storage.json`é…置文件: diff --git a/cursor_modifier.bat b/cursor_modifier.bat new file mode 100644 index 0000000..f26dc19 --- /dev/null +++ b/cursor_modifier.bat @@ -0,0 +1,141 @@ +@echo off +chcp 65001 >nul +setlocal EnableDelayedExpansion + +:: °æ±¾ºÅ +set "VERSION=1.0.1" + +:: ¼ì²âÓïÑÔ +for /f "tokens=2 delims==" %%a in ('wmic os get OSLanguage /value') do set OSLanguage=%%a +if "%OSLanguage%"=="2052" ( + set "LANG=cn" +) else ( + set "LANG=en" +) + +:: ¶àÓïÑÔÎı¾ +if "%LANG%"=="cn" ( + set "SUCCESS_MSG=[¡Ì] ÅäÖÃÎļþÒѳɹ¦¸üУ¡" + set "RESTART_MSG=[!] ÇëÊÖ¶¯ÖØÆô Cursor ÒÔʹ¸üÐÂÉúЧ" + set "READING_CONFIG=ÕýÔÚ¶ÁÈ¡ÅäÖÃÎļþ..." + set "GENERATING_IDS=ÕýÔÚÉú³Éеıêʶ·û..." + set "CHECKING_PROCESSES=ÕýÔÚ¼ì²éÔËÐÐÖÐµÄ Cursor ʵÀý..." + set "CLOSING_PROCESSES=ÕýÔÚ¹Ø±Õ Cursor ʵÀý..." + set "PROCESSES_CLOSED=ËùÓÐ Cursor ʵÀýÒѹرÕ" + set "PLEASE_WAIT=ÇëÉÔºò..." +) else ( + set "SUCCESS_MSG=[¡Ì] Configuration file updated successfully!" + set "RESTART_MSG=[!] Please restart Cursor manually for changes to take effect" + set "READING_CONFIG=Reading configuration file..." + set "GENERATING_IDS=Generating new identifiers..." + set "CHECKING_PROCESSES=Checking for running Cursor instances..." + set "CLOSING_PROCESSES=Closing Cursor instances..." + set "PROCESSES_CLOSED=All Cursor instances have been closed" + set "PLEASE_WAIT=Please wait..." +) + +:: ¼ì²é¹ÜÀíԱȨÏÞ +net session >nul 2>&1 +if %errorLevel% neq 0 ( + echo ÇëÒÔ¹ÜÀíÔ±Éí·ÝÔËÐд˽ű¾ + echo Please run this script as administrator + pause + exit /b 1 +) + +:: Éú³ÉËæ»úID +:generateId +set "id=" +for /L %%i in (1,1,32) do ( + set /a "r=!random! %% 16" + set "hex=0123456789abcdef" + for %%j in (!r!) do set "id=!id!!hex:~%%j,1!" +) +exit /b + +:: Éú³ÉUUID +:generateUUID +set "uuid=" +for /L %%i in (1,1,32) do ( + set /a "r=!random! %% 16" + set "hex=0123456789abcdef" + for %%j in (!r!) do set "uuid=!uuid!!hex:~%%j,1!" + if %%i==8 set "uuid=!uuid!-" + if %%i==12 set "uuid=!uuid!-" + if %%i==16 set "uuid=!uuid!-" + if %%i==20 set "uuid=!uuid!-" +) +exit /b + +:: Ö÷³ÌÐò +:main +cls +call :printBanner + +echo %CHECKING_PROCESSES% +tasklist | find /i "Cursor.exe" >nul +if %errorLevel% equ 0 ( + echo %CLOSING_PROCESSES% + taskkill /F /IM "Cursor.exe" >nul 2>&1 + timeout /t 2 >nul + echo %PROCESSES_CLOSED% +) + +set "CONFIG_PATH=%APPDATA%\Cursor\User\globalStorage\storage.json" +echo %READING_CONFIG% + +echo %GENERATING_IDS% +call :generateId +set "machineId=!id!" +call :generateId +set "macMachineId=!id!" +call :generateUUID +set "devDeviceId=!uuid!" +call :generateId +set "sqmId=!id!" + +:: ´´½¨ÅäÖÃĿ¼ +if not exist "%APPDATA%\Cursor\User\globalStorage" ( + mkdir "%APPDATA%\Cursor\User\globalStorage" +) + +:: Éú³ÉÅäÖÃÎļþ +( +echo { +echo "telemetry.macMachineId": "%macMachineId%", +echo "telemetry.machineId": "%machineId%", +echo "telemetry.devDeviceId": "%devDeviceId%", +echo "telemetry.sqmId": "%sqmId%", +echo "lastModified": "%date:~10,4%-%date:~4,2%-%date:~7,2%T%time:~0,2%:%time:~3,2%:%time:~6,2%Z", +echo "version": "%VERSION%" +echo } +) > "%CONFIG_PATH%" + +echo. +echo ©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥ +echo %SUCCESS_MSG% +echo %RESTART_MSG% +echo ©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥ +echo. +echo Config file location: +echo %CONFIG_PATH% +echo. +pause +exit /b + +:: ´òÓ¡banner +:printBanner +echo. +echo ¨€¨€¨€¨€¨€¨€¨[¨€¨€¨[ ¨€¨€¨[¨€¨€¨€¨€¨€¨€¨[ ¨€¨€¨€¨€¨€¨€¨€¨[ ¨€¨€¨€¨€¨€¨€¨[ ¨€¨€¨€¨€¨€¨€¨[ +echo ¨€¨€¨X¨T¨T¨T¨T¨a¨€¨€¨U ¨€¨€¨U¨€¨€¨X¨T¨T¨€¨€¨[¨€¨€¨X¨T¨T¨T¨T¨a¨€¨€¨X ¨T¨T¨€¨€¨[¨€¨€¨X¨T¨T¨€¨€¨[ +echo ¨€¨€¨U ¨€¨€¨U ¨€¨€¨U¨€¨€¨€¨€¨€¨€¨X¨a¨€¨€¨€¨€¨€¨€¨€¨[¨€¨€¨U ¨€¨€¨U¨€¨€¨€¨€¨€¨€¨X¨a +echo ¨€¨€¨U ¨€¨€¨U ¨€¨€¨U¨€¨€¨X¨T¨T¨€¨€¨[¨^¨T¨T¨T¨T¨€¨€¨U¨€¨€¨U ¨€¨€¨U¨€¨€¨X¨T¨T¨€¨€¨[ +echo ¨^¨€¨€¨€¨€¨€¨€¨[¨^¨€¨€¨€¨€¨€¨€¨X¨a¨€¨€¨U ¨€¨€¨U¨€¨€¨€¨€¨€¨€¨€¨U¨^¨€¨€¨€¨€¨€¨€¨X¨a¨€¨€¨U ¨€¨€¨U +echo ¨^¨T¨T¨T¨T¨T¨a ¨^¨T¨T¨T¨T¨T¨a ¨^¨T¨a ¨^¨T¨a¨^¨T¨T¨T¨T¨T¨T¨a ¨^¨T¨T¨T¨T¨T¨a ¨^¨T¨a ¨^¨T¨a +echo. +echo ^>^> Cursor ID Modifier v1.0 ^<^< +echo [ By Pancake Fruit Rolled Shark Chili ] +echo. +exit /b + +endlocal \ No newline at end of file diff --git a/cursor_modifier.sh b/cursor_modifier.sh new file mode 100644 index 0000000..60f8d02 --- /dev/null +++ b/cursor_modifier.sh @@ -0,0 +1,164 @@ +#!/bin/bash + +# ç‰ˆæœ¬å· +VERSION="1.0.1" + +# 颜色定义 +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +CYAN='\033[0;36m' +NC='\033[0m' + +# 语言检测 +detect_language() { + local lang=$(locale | grep "LANG=" | cut -d= -f2) + if [[ $lang == *"zh"* ]]; then + echo "cn" + else + echo "en" + fi +} + +LANG=$(detect_language) + +# 多语言文本 +if [ "$LANG" == "cn" ]; then + SUCCESS_MSG="[√] é…置文件已æˆåŠŸæ›´æ–°ï¼" + RESTART_MSG="[!] 请手动é‡å¯ Cursor 以使更新生效" + READING_CONFIG="正在读å–é…置文件..." + GENERATING_IDS="æ­£åœ¨ç”Ÿæˆæ–°çš„æ ‡è¯†ç¬¦..." + CHECKING_PROCESSES="正在检查è¿è¡Œä¸­çš„ Cursor 实例..." + CLOSING_PROCESSES="正在关闭 Cursor 实例..." + PROCESSES_CLOSED="所有 Cursor 实例已关闭" + PLEASE_WAIT="请ç¨å€™..." +else + SUCCESS_MSG="[√] Configuration file updated successfully!" + RESTART_MSG="[!] Please restart Cursor manually for changes to take effect" + READING_CONFIG="Reading configuration file..." + GENERATING_IDS="Generating new identifiers..." + CHECKING_PROCESSES="Checking for running Cursor instances..." + CLOSING_PROCESSES="Closing Cursor instances..." + PROCESSES_CLOSED="All Cursor instances have been closed" + PLEASE_WAIT="Please wait..." +fi + +# 生æˆéšæœºID +generate_machine_id() { + openssl rand -hex 32 +} + +generate_dev_device_id() { + printf '%04x%04x-%04x-%04x-%04x-%04x%04x%04x' \ + $RANDOM $RANDOM \ + $RANDOM \ + $(($RANDOM & 0x0fff | 0x4000)) \ + $(($RANDOM & 0x3fff | 0x8000)) \ + $RANDOM $RANDOM $RANDOM +} + +# 获å–é…置文件路径 +get_config_path() { + local username=$1 + case "$(uname)" in + "Darwin") + echo "/Users/$username/Library/Application Support/Cursor/User/globalStorage/storage.json" + ;; + "Linux") + echo "/home/$username/.config/Cursor/User/globalStorage/storage.json" + ;; + *) + echo "Unsupported operating system" + exit 1 + ;; + esac +} + +# 检查Cursor进程 +check_cursor_running() { + pgrep -f "Cursor|AppRun" >/dev/null +} + +# 关闭Cursor进程 +kill_cursor_processes() { + echo -e "${CYAN}$CLOSING_PROCESSES${NC}" + pkill -f "Cursor|AppRun" + sleep 2 + if check_cursor_running; then + pkill -9 -f "Cursor|AppRun" + fi + echo -e "${GREEN}$PROCESSES_CLOSED${NC}" +} + +# 打å°èµ›åšæœ‹å…‹é£Žæ ¼banner +print_banner() { + echo -e "${CYAN}" + echo ' ██████╗██╗ ██╗██████╗ ███████╗ ██████╗ ██████╗ ' + echo ' ██╔â•â•â•â•â•██║ ██║██╔â•â•██╗██╔â•â•â•â•â•██╔â•â•â•██╗██╔â•â•██╗' + echo ' ██║ ██║ ██║██████╔â•███████╗██║ ██║██████╔â•' + echo ' ██║ ██║ ██║██╔â•â•██╗╚â•â•â•â•██║██║ ██║██╔â•â•██╗' + echo ' ╚██████╗╚██████╔â•██║ ██║███████║╚██████╔â•██║ ██║' + echo ' ╚â•â•â•â•â•╠╚â•â•â•â•â•╠╚â•╠╚â•â•╚â•â•â•â•â•â•╠╚â•â•â•â•â•╠╚â•╠╚â•â•' + echo -e "${NC}" + echo -e "${YELLOW}\t\t>> Cursor ID Modifier v1.0 <<${NC}" + echo -e "${CYAN}\t\t [ By Pancake Fruit Rolled Shark Chili ]${NC}" + echo +} + +# 主函数 +main() { + # 检查rootæƒé™ + if [ "$EUID" -ne 0 ]; then + echo "Please run as root" + exit 1 + fi + + # 获å–实际用户å + REAL_USER=${SUDO_USER:-$USER} + + clear + print_banner + + # ç¡®ä¿Cursor已关闭 + if check_cursor_running; then + kill_cursor_processes + fi + + CONFIG_PATH=$(get_config_path "$REAL_USER") + echo -e "${CYAN}$READING_CONFIG${NC}" + + # ç”Ÿæˆæ–°é…ç½® + echo -e "${CYAN}$GENERATING_IDS${NC}" + NEW_CONFIG=$(cat < "$CONFIG_PATH" + chown "$REAL_USER" "$CONFIG_PATH" + chmod 644 "$CONFIG_PATH" + + # 显示æˆåŠŸæ¶ˆæ¯ + echo -e "\n${GREEN}â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”${NC}" + echo -e "${GREEN}$SUCCESS_MSG${NC}" + echo -e "${YELLOW}$RESTART_MSG${NC}" + echo -e "${GREEN}â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”${NC}" + + echo -e "\n���置文件ä½ç½®/Config file location:" + echo -e "${CYAN}$CONFIG_PATH${NC}\n" + + read -p "Press Enter to exit..." +} + +main "$@" \ No newline at end of file