diff --git a/README.md b/README.md
index b6d8999..c4a0678 100644
--- a/README.md
+++ b/README.md
@@ -6,7 +6,7 @@
[](https://github.com/yuaotian/go-cursor-help/blob/master/LICENSE)
[](https://github.com/yuaotian/go-cursor-help/stargazers)
-[🌟 English](README.md) | [🌏 中文](README_CN.md)
+[🌟 English](README.md) | [🌏 中文](README_CN.md) | [🌏 日本語](README_JP.md)
diff --git a/README_CN.md b/README_CN.md
index 5baf216..6d1b43b 100644
--- a/README_CN.md
+++ b/README_CN.md
@@ -6,7 +6,7 @@
[](https://github.com/yuaotian/go-cursor-help/blob/master/LICENSE)
[](https://github.com/yuaotian/go-cursor-help/stargazers)
-[🌟 English](README.md) | [🌏 中文](README_CN.md)
+[🌟 English](README.md) | [🌏 中文](README_CN.md) | [🌏 日本語](README_JP.md)
diff --git a/README_JP.md b/README_JP.md
new file mode 100644
index 0000000..fe94199
--- /dev/null
+++ b/README_JP.md
@@ -0,0 +1,547 @@
+# 🚀 Cursor 無料試用リセットツール
+
+
+
+[](https://github.com/yuaotian/go-cursor-help/releases/latest)
+[](https://github.com/yuaotian/go-cursor-help/blob/master/LICENSE)
+[](https://github.com/yuaotian/go-cursor-help/stargazers)
+
+[🌟 English](README.md) | [🌏 中文](README_CN.md) | [🌏 日本語](README_JP.md)
+
+

+
+
+
+> ⚠️ **重要なお知らせ**
+>
+> このツールは現在以下のバージョンをサポートしています:
+> - ✅ Cursor v0.45.x およびそれ以前のバージョン
+> - ✅ Windows: 最新の0.47.xバージョン(サポート済み)
+> - ✅ Mac/Linux: 最新の0.47.xバージョン(サポート済み、フィードバック歓迎)
+>
+> このツールを使用する前に、Cursorのバージョンを確認してください。
+
+
+📦 バージョン履歴とダウンロード
+
+
+
+### 🌟 最新バージョン
+- v0.45.11 (2025-02-07) - 最新リリース
+- v0.45.x (2025-01-03) - 最も安定したリリース
+
+[完全なバージョン履歴を見る](CursorHistoryDown.md)
+
+
+
+### 📥 直接ダウンロードリンク
+
+**v0.45.x (推奨安定版)**
+- Windows: [公式](https://downloader.cursor.sh/builds/250103fqxdt5u9z/windows/nsis/x64) | [ミラー](https://download.todesktop.com/230313mzl4w4u92/Cursor%20Setup%200.44.11%20-%20Build%20250103fqxdt5u9z-x64.exe)
+- Mac: [Apple Silicon](https://dl.todesktop.com/230313mzl4w4u92/versions/0.44.11/mac/zip/arm64)
+
+
+
+⚠️ **MACアドレス変更警告**
+>
+> Macユーザーの皆様へ: このスクリプトにはMACアドレス変更機能が含まれています。以下の操作が行われます:
+> - ネットワークインターフェースのMACアドレスを変更します
+> - 変更前に元のMACアドレスをバックアップします
+> - この変更により一時的にネットワーク接続が影響を受ける可能性があります
+> - 実行中にこのステップをスキップすることができます
+>
+> 💾 **Cursor v0.45.xをダウンロード**
+>
+> Windows:
+> - [Cursor公式からダウンロード](https://downloader.cursor.sh/builds/250103fqxdt5u9z/windows/nsis/x64)
+> - [ToDesktopからダウンロード](https://download.todesktop.com/230313mzl4w4u92/Cursor%20Setup%200.44.11%20-%20Build%20250103fqxdt5u9z-x64.exe)
+>
+> Mac:
+> - [Mac用ダウンロード (Apple Silicon)](https://dl.todesktop.com/230313mzl4w4u92/versions/0.44.11/mac/zip/arm64)
+
+
+🔒 自動更新機能の無効化
+
+> Cursorがサポートされていない新しいバージョンに自動的に更新されるのを防ぐために、自動更新機能を無効にすることができます。
+
+#### 方法1: 組み込みスクリプトを使用する(推奨)
+
+リセットツールを実行するとき、スクリプトは自動更新を無効にするかどうかを尋ねます:
+```text
+[質問] Cursorの自動更新機能を無効にしますか?
+0) いいえ - デフォルト設定を維持(Enterキーを押す)
+1) はい - 自動更新を無効にする
+```
+
+`1`を選択して無効化操作を自動的に完了します。
+
+#### 方法2: 手動で無効化
+
+**Windows:**
+1. すべてのCursorプロセスを閉じます
+2. ディレクトリを削除します: `%LOCALAPPDATA%\cursor-updater`
+3. 同じ名前のファイルを作成します(拡張子なし)
+
+**macOS:**
+```bash
+# 注意: テスト済みでは、この方法はバージョン0.45.11およびそれ以前のバージョンでのみ機能します。
+# Cursorを閉じます
+pkill -f "Cursor"
+# app-update.ymlを空の読み取り専用ファイルに置き換えます
+cd /Applications/Cursor.app/Contents/Resources
+mv app-update.yml app-update.yml.bak
+touch app-update.yml
+chmod 444 app-update.yml
+
+# 設定 -> アプリケーション -> 更新、モードをnoneに設定します。
+# これを行わないと、Cursorは更新をチェックし続けます。
+
+# 注意: cursor-updaterの変更方法はもはや有効ではないかもしれません
+# いずれにせよ、更新ディレクトリを削除し、ブロックファイルを作成します
+rm -rf ~/Library/Application\ Support/Caches/cursor-updater
+touch ~/Library/Application\ Support/Caches/cursor-updater
+```
+
+**Linux:**
+```bash
+# Cursorを閉じます
+pkill -f "Cursor"
+# 更新ディレクトリを削除し、ブロックファイルを作成します
+rm -rf ~/.config/cursor-updater
+touch ~/.config/cursor-updater
+```
+
+> ⚠️ **注意:** 自動更新を無効にした後、新しいバージョンを手動でダウンロードしてインストールする必要があります。新しいバージョンが互換性があることを確認した後に更新することをお勧めします。
+
+
+
+---
+
+### 📝 説明
+
+> これらのメッセージのいずれかに遭遇した場合:
+
+#### 問題1: 試用アカウント制限 
+
+```text
+Too many free trial accounts used on this machine.
+Please upgrade to pro. We have this limit in place
+to prevent abuse. Please let us know if you believe
+this is a mistake.
+```
+
+#### 問題2: APIキー制限 
+
+```text
+[New Issue]
+
+Composer relies on custom models that cannot be billed to an API key.
+Please disable API keys and use a Pro or Business subscription.
+Request ID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
+```
+
+#### 問題3: 試用リクエスト制限
+
+> これは、VIP無料試用期間中に使用制限に達したことを示しています:
+
+```text
+You've reached your trial request limit.
+```
+
+#### 問題4: Claude 3.7 高負荷 
+
+```text
+High Load
+We're experiencing high demand for Claude 3.7 Sonnet right now. Please upgrade to Pro, or switch to the
+'default' model, Claude 3.5 sonnet, another model, or try again in a few moments.
+```
+
+
+
+
+
+#### 解決策 : Cursorを完全にアンインストールして再インストールする(APIキーの問題)
+
+1. [Geek.exeアンインストーラー[無料]](https://geekuninstaller.com/download)をダウンロードします
+2. Cursorアプリを完全にアンインストールします
+3. Cursorアプリを再インストールします
+4. 解決策1を続行します
+
+
+
+
+
+> 一時的な解決策:
+
+#### 解決策1: クイックリセット(推奨)
+
+1. Cursorアプリケーションを閉じます
+2. マシンコードリセットスクリプトを実行します(以下のインストール手順を参照)
+3. Cursorを再度開いて使用を続けます
+
+#### 解決策2: アカウントの切り替え
+
+1. ファイル -> Cursor設定 -> サインアウト
+2. Cursorを閉じます
+3. マシンコードリセットスクリプトを実行します
+4. 新しいアカウントでログインします
+
+#### 解決策3: ネットワークの最適化
+
+上記の解決策が機能しない場合は、次のことを試してください:
+
+- 低遅延ノードに切り替えます(推奨地域:日本、シンガポール、米国、香港)
+- ネットワークの安定性を確保します
+- ブラウザのキャッシュをクリアして再試行します
+
+#### 解決策4: Claude 3.7 アクセス問題(高負荷)
+
+Claude 3.7 Sonnetの"High Load"メッセージが表示された場合、これはCursorが特定の時間帯に無料試用アカウントの3.7モデルの使用を制限していることを示しています。次のことを試してください:
+
+1. Gmailで作成した新しいアカウントに切り替えます。異なるIPアドレスを使用して接続することをお勧めします
+2. 非ピーク時間帯にアクセスを試みます(通常、5-10 AMまたは3-7 PMの間に制限が少ないです)
+3. Proにアップグレードしてアクセスを保証します
+4. Claude 3.5 Sonnetを代替オプションとして使用します
+
+> 注意: Cursorがリソース配分ポリシーを調整するにつれて、これらのアクセスパターンは変更される可能性があります。
+
+### 💻 システムサポート
+
+
+
+
+
+**Windows** ✅
+
+- x64 (64ビット)
+- x86 (32ビット)
+
+ |
+
+
+**macOS** ✅
+
+- Intel (x64)
+- Apple Silicon (M1/M2)
+
+ |
+
+
+**Linux** ✅
+
+- x64 (64ビット)
+- x86 (32ビット)
+- ARM64
+
+ |
+
+
+
+### 🚀 ワンクリックソリューション
+
+
+グローバルユーザー
+
+**macOS**
+
+```bash
+# 方法2
+curl -fsSL https://aizaozao.com/accelerate.php/https://raw.githubusercontent.com/yuaotian/go-cursor-help/refs/heads/master/scripts/run/cursor_mac_id_modifier.sh -o ./cursor_mac_id_modifier.sh && sudo bash ./cursor_mac_id_modifier.sh && rm ./cursor_mac_id_modifier.sh
+```
+
+**Linux**
+
+```bash
+curl -fsSL https://raw.githubusercontent.com/yuaotian/go-cursor-help/refs/heads/master/scripts/run/cursor_linux_id_modifier.sh | sudo bash
+```
+
+**Windows**
+
+```powershell
+irm https://raw.githubusercontent.com/yuaotian/go-cursor-help/refs/heads/master/scripts/run/cursor_win_id_modifier.ps1 | iex
+```
+
+
+

+
+
+
+
+
+中国ユーザー(推奨)
+
+**macOS**
+
+```bash
+curl -fsSL https://aizaozao.com/accelerate.php/https://raw.githubusercontent.com/yuaotian/go-cursor-help/refs/heads/master/scripts/run/cursor_mac_id_modifier.sh -o ./cursor_mac_id_modifier.sh && sudo bash ./cursor_mac_id_modifier.sh && rm ./cursor_mac_id_modifier.sh
+```
+
+**Linux**
+
+```bash
+curl -fsSL https://aizaozao.com/accelerate.php/https://raw.githubusercontent.com/yuaotian/go-cursor-help/refs/heads/master/scripts/run/cursor_linux_id_modifier.sh | sudo bash
+```
+
+**Windows**
+
+```powershell
+irm https://aizaozao.com/accelerate.php/https://raw.githubusercontent.com/yuaotian/go-cursor-help/refs/heads/master/scripts/run/cursor_win_id_modifier.ps1 | iex
+```
+
+
+
+
+Windowsターミナルの実行と構成
+
+#### Windowsで管理者ターミナルを開く方法:
+
+##### 方法1: Win + Xショートカットを使用する
+```md
+1. Win + Xキーの組み合わせを押します
+2. メニューから次のオプションのいずれかを選択します:
+ - "Windows PowerShell (管理者)"
+ - "Windows Terminal (管理者)"
+ - "ターミナル (管理者)"
+ (Windowsのバージョンによってオプションが異なる場合があります)
+```
+
+##### 方法2: Win + R実行コマンドを使用する
+```md
+1. Win + Rキーの組み合わせを押します
+2. 実行ダイアログにpowershellまたはpwshと入力します
+3. Ctrl + Shift + Enterを押して管理者として実行します
+ または開いたウィンドウに次のように入力します: Start-Process pwsh -Verb RunAs
+4. 管理者ターミナルにリセットスクリプトを入力します:
+
+irm https://aizaozao.com/accelerate.php/https://raw.githubusercontent.com/yuaotian/go-cursor-help/refs/heads/master/scripts/run/cursor_win_id_modifier.ps1 | iex
+```
+
+##### 方法3: 検索を使用する
+>
+>
+>検索ボックスにpwshと入力し、右クリックして「管理者として実行」を選択します
+>
+
+管理者ターミナルにリセットスクリプトを入力します:
+```powershell
+irm https://aizaozao.com/accelerate.php/https://raw.githubusercontent.com/yuaotian/go-cursor-help/refs/heads/master/scripts/run/cursor_win_id_modifier.ps1 | iex
+```
+
+### 🔧 PowerShellインストールガイド
+
+システムにPowerShellがインストールされていない場合は、次の方法でインストールできます:
+
+#### 方法1: Wingetを使用してインストール(推奨)
+
+1. コマンドプロンプトまたはPowerShellを開きます
+2. 次のコマンドを実行します:
+```powershell
+winget install --id Microsoft.PowerShell --source winget
+```
+
+#### 方法2: 手動でインストール
+
+1. システムに適したインストーラーをダウンロードします:
+ - [PowerShell-7.4.6-win-x64.msi](https://github.com/PowerShell/PowerShell/releases/download/v7.4.6/PowerShell-7.4.6-win-x64.msi)(64ビットシステム用)
+ - [PowerShell-7.4.6-win-x86.msi](https://github.com/PowerShell/PowerShell/releases/download/v7.4.6/PowerShell-7.4.6-win-x86.msi)(32ビットシステム用)
+ - [PowerShell-7.4.6-win-arm64.msi](https://github.com/PowerShell/PowerShell/releases/download/v7.4.6/PowerShell-7.4.6-win-arm64.msi)(ARM64システム用)
+
+2. ダウンロードしたインストーラーをダブルクリックし、インストールの指示に従います
+
+> 💡 問題が発生した場合は、[Microsoft公式インストールガイド](https://learn.microsoft.com/ja-jp/powershell/scripting/install/installing-powershell-on-windows)を参照してください
+
+
+
+#### Windowsインストール機能:
+
+- 🔍 PowerShell 7が利用可能な場合は自動的に検出して使用します
+- 🛡️ UACプロンプトを介して管理者権限を要求します
+- 📝 PS7が見つからない場合はWindows PowerShellにフォールバックします
+- 💡 権限昇格に失敗した場合は手動の指示を提供します
+
+これで完了です!スクリプトは次のことを行います:
+
+1. ✨ ツールを自動的にインストールします
+2. 🔄 Cursorの試用期間を即座にリセットします
+
+### 📦 手動インストール
+
+> [リリース](https://github.com/yuaotian/go-cursor-help/releases/latest)からシステムに適したファイルをダウンロードします
+
+
+Windowsパッケージ
+
+- 64ビット: `cursor-id-modifier_windows_x64.exe`
+- 32ビット: `cursor-id-modifier_windows_x86.exe`
+
+
+
+macOSパッケージ
+
+- Intel: `cursor-id-modifier_darwin_x64_intel`
+- M1/M2: `cursor-id-modifier_darwin_arm64_apple_silicon`
+
+
+
+Linuxパッケージ
+
+- 64ビット: `cursor-id-modifier_linux_x64`
+- 32ビット: `cursor-id-modifier_linux_x86`
+- ARM64: `cursor-id-modifier_linux_arm64`
+
+
+### 🔧 技術的詳細
+
+
+構成ファイル
+
+プログラムはCursorの`storage.json`構成ファイルを変更します。場所は次のとおりです:
+
+- Windows: `%APPDATA%\Cursor\User\globalStorage\storage.json`
+- macOS: `~/Library/Application Support/Cursor/User/globalStorage/storage.json`
+- Linux: `~/.config/Cursor/User/globalStorage/storage.json`
+
+
+
+変更されたフィールド
+
+ツールは次の新しい一意の識別子を生成します:
+
+- `telemetry.machineId`
+- `telemetry.macMachineId`
+- `telemetry.devDeviceId`
+- `telemetry.sqmId`
+
+
+
+手動自動更新無効化
+
+Windowsユーザーは自動更新機能を手動で無効にすることができます:
+
+1. すべてのCursorプロセスを閉じます
+2. ディレクトリを削除します: `C:\Users\username\AppData\Local\cursor-updater`
+3. 同じ名前のファイルを作成します: `cursor-updater`(拡張子なし)
+
+macOS/Linuxユーザーはシステム内で同様の`cursor-updater`ディレクトリを見つけて同じ操作を行うことができます。
+
+
+
+
+安全機能
+
+- ✅ 安全なプロセス終了
+- ✅ アトミックファイル操作
+- ✅ エラーハンドリングとリカバリ
+
+
+
+レジストリ変更通知
+
+> ⚠️ **重要: このツールはWindowsレジストリを変更します**
+
+#### 変更されたレジストリ
+- パス: `コンピュータ\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography`
+- キー: `MachineGuid`
+
+#### 潜在的な影響
+このレジストリキーを変更すると、次のことに影響を与える可能性があります:
+- Windowsシステムの一意のデバイス識別
+- 特定のソフトウェアのデバイス認識と認証状態
+- ハードウェア識別に基づくシステム機能
+
+#### 安全対策
+1. 自動バックアップ
+ - 変更前に元の値が自動的にバックアップされます
+ - バックアップ場所: `%APPDATA%\Cursor\User\globalStorage\backups`
+ - バックアップファイル形式: `MachineGuid.backup_YYYYMMDD_HHMMSS`
+
+2. 手動復元手順
+ - レジストリエディタ(regedit)を開きます
+ - 次の場所に移動します: `コンピュータ\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography`
+ - `MachineGuid`を右クリックします
+ - 「修正」を選択します
+ - バックアップファイルの値を貼り付けます
+
+#### 重要な注意事項
+- 変更前にバックアップファイルの存在を確認します
+- 必要に応じてバックアップファイルを使用して元の値を復元します
+- レジストリの変更には管理者権限が必要です
+
+
+---
+
+### 📚 推奨読書
+
+- [Cursorの問題収集と解決策](https://mp.weixin.qq.com/s/pnJrH7Ifx4WZvseeP1fcEA)
+- [AIユニバーサル開発アシスタントプロンプトガイド](https://mp.weixin.qq.com/s/PRPz-qVkFJSgkuEKkTdzwg)
+
+---
+
+## サポート
+
+
+
このツールが役立つと感じた場合、スパイシーグルテンのおやつ(Latiao)を買っていただけると嬉しいです~ 💁☕️
+
+
+
+
+WeChat Pay
+
+要到饭咧?啊咧?啊咧?不给也没事~ 请随意打赏
+ |
+
+Alipay
+
+如果觉得有帮助,来包辣条犒劳一下吧~
+ |
+
+Alipay
+
+1 Latiao = 1 AI thought cycle
+ |
+
+WeChat
+
+二维码7天内(3月24日前)有效,过期请加微信
+ |
+
+
+
+
+
+
+---
+
+## ⭐ プロジェクト統計
+
+
+
+[](https://star-history.com/#yuaotian/go-cursor-help&Date)
+
+
+
+
+
+## 📄 ライセンス
+
+
+MITライセンス
+
+Copyright (c) 2024
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+
diff --git a/scripts/run/cursor_linux_id_modifier.sh b/scripts/run/cursor_linux_id_modifier.sh
index 2458d76..72d3296 100644
--- a/scripts/run/cursor_linux_id_modifier.sh
+++ b/scripts/run/cursor_linux_id_modifier.sh
@@ -1,474 +1,210 @@
#!/bin/bash
# 设置错误处理
-set -e
+set -eo pipefail
# 颜色定义
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
-NC='\033[0m' # No Color
+NC='\033[0m'
# 日志函数
-log_info() {
- echo -e "${GREEN}[INFO]${NC} $1"
+log() {
+ local level=$1; shift
+ local color
+ case "$level" in
+ "INFO") color="$GREEN" ;;
+ "WARN") color="$YELLOW" ;;
+ "ERROR") color="$RED" ;;
+ "DEBUG") color="$BLUE" ;;
+ *) color="$NC" ;;
+ esac
+ echo -e "${color}[$level]${NC} $(date '+%Y-%m-%d %H:%M:%S') - $*"
}
-log_warn() {
- echo -e "${YELLOW}[WARN]${NC} $1"
-}
-
-log_error() {
- echo -e "${RED}[ERROR]${NC} $1"
-}
-
-log_debug() {
- echo -e "${BLUE}[DEBUG]${NC} $1"
-}
-
-# 获取当前用户
-get_current_user() {
- if [ "$EUID" -eq 0 ]; then
- echo "$SUDO_USER"
- else
- echo "$USER"
- fi
-}
-
-CURRENT_USER=$(get_current_user)
-if [ -z "$CURRENT_USER" ]; then
- log_error "无法获取用户名"
- exit 1
-fi
-
-# 定义配置文件路径
-if [ "$EUID" -eq 0 ] && [ -n "$SUDO_USER" ]; then
- USER_HOME=$(eval echo ~$SUDO_USER)
-else
- USER_HOME="$HOME"
-fi
-STORAGE_FILE="$USER_HOME/.config/Cursor/User/globalStorage/storage.json"
-BACKUP_DIR="$USER_HOME/.config/Cursor/User/globalStorage/backups"
-
-# 检查权限
+# 检查访问权限
check_permissions() {
- if [ "$EUID" -ne 0 ]; then
- log_error "请使用 sudo 运行此脚本"
- echo "示例: sudo $0"
- exit 1
- fi
-}
-
-# 检查并关闭 Cursor 进程
-check_and_kill_cursor() {
- log_info "检查 Cursor 进程..."
-
- local attempt=1
- local max_attempts=5
-
- # 函数:获取进程详细信息
- get_process_details() {
- local process_name="$1"
- log_debug "正在获取 $process_name 进程详细信息:"
- ps aux | grep -i "$process_name" | grep -v grep
- }
-
- while [ $attempt -le $max_attempts ]; do
- CURSOR_PIDS=$(pgrep -i "cursor" || true)
-
- if [ -z "$CURSOR_PIDS" ]; then
- log_info "未发现运行中的 Cursor 进程"
- return 0
- fi
-
- log_warn "发现 Cursor 进程正在运行"
- get_process_details "cursor"
-
- log_warn "尝试关闭 Cursor 进程..."
-
- if [ $attempt -eq $max_attempts ]; then
- log_warn "尝试强制终止进程..."
- kill -9 $CURSOR_PIDS 2>/dev/null || true
- else
- kill $CURSOR_PIDS 2>/dev/null || true
- fi
-
- sleep 1
-
- if ! pgrep -i "cursor" > /dev/null; then
- log_info "Cursor 进程已成功关闭"
- return 0
- fi
-
- log_warn "等待进程关闭,尝试 $attempt/$max_attempts..."
- ((attempt++))
- done
-
- log_error "在 $max_attempts 次尝试后仍无法关闭 Cursor 进程"
- get_process_details "cursor"
- log_error "请手动关闭进程后重试"
+ if [ "$(id -u)" -ne 0 ]; then
+ log "ERROR" "所需许可证 root. 用 sudo 运行:"
+ echo " sudo $0"
exit 1
+ fi
}
-# 备份系统 ID
-backup_system_id() {
- log_info "正在备份系统 ID..."
- local system_id_file="$BACKUP_DIR/system_id.backup_$(date +%Y%m%d_%H%M%S)"
-
- # 创建备份目录
- mkdir -p "$BACKUP_DIR"
-
- {
- echo "# Original System ID Backup - $(date)" > "$system_id_file"
- echo "## Machine ID:" >> "$system_id_file"
- cat /etc/machine-id >> "$system_id_file"
- echo -e "\n## DMI System UUID:" >> "$system_id_file"
- dmidecode -s system-uuid >> "$system_id_file" 2>/dev/null || echo "N/A"
-
- chmod 444 "$system_id_file"
- chown "$CURRENT_USER" "$system_id_file"
- log_info "系统 ID 已备份到: $system_id_file"
- } || {
- log_error "备份系统 ID 失败"
- return 1
- }
+# 查找 Cursor 安装文件夹
+find_cursor_dir() {
+ local possible_dirs=(
+ "/opt/Cursor"
+ "/opt/cursor-bin"
+ "/usr/lib/cursor"
+ "$HOME/.cursor"
+ )
+
+ for dir in "${possible_dirs[@]}"; do
+ if [ -d "$dir" ]; then
+ echo "$dir"
+ return 0
+ fi
+ done
+
+ log "ERROR" "无法找到文件夹 Cursor"
+ exit 1
}
-# 备份配置文件
-backup_config() {
- if [ ! -f "$STORAGE_FILE" ]; then
- log_warn "配置文件不存在,跳过备份"
- return 0
- fi
-
- mkdir -p "$BACKUP_DIR"
- local backup_file="$BACKUP_DIR/storage.json.backup_$(date +%Y%m%d_%H%M%S)"
-
- if cp "$STORAGE_FILE" "$backup_file"; then
- chmod 644 "$backup_file"
- chown "$CURRENT_USER" "$backup_file"
- log_info "配置已备份到: $backup_file"
- else
- log_error "备份失败"
- exit 1
- fi
+# 获取准确的流程清单
+get_cursor_pids() {
+ local cursor_dir=$(find_cursor_dir)
+ ps aux | grep -iE "$cursor_dir/[cC]ursor" | grep -v -E 'grep|--type=renderer' | awk '{print $2}'
}
-# 生成随机 ID
-generate_random_id() {
- # 生成32字节(64个十六进制字符)的随机数,并确保一行输出
- head -c 32 /dev/urandom | xxd -p -c 32
-}
+# 安全终止进程
+terminate_cursor() {
+ log "INFO" "光标进程搜索..."
+ local pids=$(get_cursor_pids)
-# 生成随机 UUID
-generate_uuid() {
- uuidgen | tr '[:upper:]' '[:lower:]'
-}
-
-# 修改现有文件
-modify_or_add_config() {
- local key="$1"
- local value="$2"
- local file="$3"
-
- # 转义特殊字符
- local key_escaped=$(sed 's/[\/&]/\\&/g' <<< "$key")
- local value_escaped=$(sed 's/[\/&]/\\&/g' <<< "$value")
-
- if [ ! -f "$file" ]; then
- log_error "文件不存在: $file"
- return 1
- fi
-
- # 检查并移除chattr只读属性(如果存在)
- if lsattr "$file" 2>/dev/null | grep -q '^....i'; then
- log_debug "移除文件不可变属性..."
- sudo chattr -i "$file" || {
- log_error "无法移除文件不可变属性"
- return 1
- }
- fi
-
- # 确保文件可写
- chmod 644 "$file" || {
- log_error "无法修改文件权限: $file"
- return 1
- }
-
- # 创建临时文件
- local temp_file=$(mktemp)
-
- # 检查key是否存在
- if grep -q "\"$key\":" "$file"; then
- # 使用#作为分隔符避免冲突,并转义特殊字符
- sed "s#\"${key_escaped}\":[[:space:]]*\"[^\"]*\"#\"${key_escaped}\": \"${value_escaped}\"#" "$file" > "$temp_file" || {
- log_error "修改配置失败: $key"
- rm -f "$temp_file"
- return 1
- }
- else
- # 添加新键值对时转义特殊字符
- sed "s/}$/,\n \"${key_escaped}\": \"${value_escaped}\"\n}/" "$file" > "$temp_file" || {
- log_error "添加配置失败: $key"
- rm -f "$temp_file"
- return 1
- }
- fi
-
- # 检查临时文件是否为空
- if [ ! -s "$temp_file" ]; then
- log_error "生成的临时文件为空"
- rm -f "$temp_file"
- return 1
- fi
-
- # 使用 cat 替换原文件内容
- cat "$temp_file" > "$file" || {
- log_error "无法写入文件: $file"
- rm -f "$temp_file"
- return 1
- }
-
- rm -f "$temp_file"
-
- # 恢复文件权限
- chmod 444 "$file"
-
+ if [ -z "$pids" ]; then
+ log "INFO" "未发现任何 Cursor 进程"
return 0
+ fi
+
+ log "WARN" "发现的过程 Cursor (PID): $pids"
+ echo "过程详情:"
+ ps -fp $pids
+
+ read -r -p "您确定要终止这些进程吗? [y/N] " response /dev/null || true
+
+ for i in {1..10}; do
+ sleep 0.5
+ local remaining=$(get_cursor_pids)
+ [ -z "$remaining" ] && break
+ done
+
+ local remaining=$(get_cursor_pids)
+ if [ -n "$remaining" ]; then
+ log "WARN" "强制完成..."
+ kill -KILL $remaining 2>/dev/null || true
+ fi
+
+ log "INFO" "成功完成的流程"
+ else
+ log "ERROR" "用户取消"
+ exit 1
+ fi
}
-# 生成新的配置
-generate_new_config() {
- # 修改系统 ID
- log_info "正在修改系统 ID..."
-
- # 备份当前系统 ID
- backup_system_id
-
- # 生成新的 machine-id
- local new_machine_id=$(generate_random_id | cut -c1-32)
-
- # 备份并修改 machine-id
- if [ -f "/etc/machine-id" ]; then
- cp /etc/machine-id /etc/machine-id.backup
- echo "$new_machine_id" > /etc/machine-id
- log_info "系统 machine-id 已更新"
- fi
-
- # 将 auth0|user_ 转换为字节数组的十六进制
- local prefix_hex=$(echo -n "auth0|user_" | xxd -p)
- local random_part=$(generate_random_id)
- local machine_id="${prefix_hex}${random_part}"
-
- local mac_machine_id=$(generate_random_id)
- local device_id=$(generate_uuid | tr '[:upper:]' '[:lower:]')
- local sqm_id="{$(generate_uuid | tr '[:lower:]' '[:upper:]')}"
-
- log_info "正在修改配置文件..."
- # 检查配置文件是否存在
- if [ ! -f "$STORAGE_FILE" ]; then
- log_error "未找到配置文件: $STORAGE_FILE"
- log_warn "请先安装并运行一次 Cursor 后再使用此脚本"
- exit 1
- fi
-
- # 确保配置文件目录存在
- mkdir -p "$(dirname "$STORAGE_FILE")" || {
- log_error "无法创建配置目录"
- exit 1
- }
-
- # 如果文件不存在,创建一个基本的 JSON 结构
- if [ ! -s "$STORAGE_FILE" ]; then
- echo '{}' > "$STORAGE_FILE" || {
- log_error "无法初始化配置文件"
- exit 1
- }
- fi
-
- # 修改现有文件
- modify_or_add_config "telemetry.machineId" "$machine_id" "$STORAGE_FILE" || exit 1
- modify_or_add_config "telemetry.macMachineId" "$mac_machine_id" "$STORAGE_FILE" || exit 1
- modify_or_add_config "telemetry.devDeviceId" "$device_id" "$STORAGE_FILE" || exit 1
- modify_or_add_config "telemetry.sqmId" "$sqm_id" "$STORAGE_FILE" || exit 1
-
- # 设置文件权限和所有者
- chmod 444 "$STORAGE_FILE" # 改为只读权限
- chown "$CURRENT_USER" "$STORAGE_FILE"
-
- # 验证权限设置
- if [ -w "$STORAGE_FILE" ]; then
- log_warn "无法设置只读权限,尝试使用其他方法..."
- chattr +i "$STORAGE_FILE" 2>/dev/null || true
- else
- log_info "成功设置文件只读权限"
- fi
-
- echo
- log_info "已更新配置: $STORAGE_FILE"
- log_debug "machineId: $machine_id"
- log_debug "macMachineId: $mac_machine_id"
- log_debug "devDeviceId: $device_id"
- log_debug "sqmId: $sqm_id"
+# 备份
+backup_files() {
+ local user_home=$1
+ local cursor_dir_name=$(basename $(find_cursor_dir))
+ local config_dir="$user_home/.config/$cursor_dir_name/User/globalStorage"
+ local storage_file="$config_dir/storage.json"
+ local backup_dir="$config_dir/backups"
+
+ mkdir -p "$backup_dir"
+ local timestamp=$(date +%Y%m%d_%H%M%S)
+
+ if [ -f "$storage_file" ]; then
+ cp "$storage_file" "$backup_dir/storage.json.bak_$timestamp"
+ log "INFO" "配置已备份: $backup_dir/storage.json.bak_$timestamp"
+ fi
+
+ local machine_id="/etc/machine-id"
+ if [ -f "$machine_id" ]; then
+ cp "$machine_id" "$backup_dir/machine-id.bak_$timestamp"
+ log "INFO" "创建了备份机器 ID"
+ fi
}
-# 显示文件树结构
-show_file_tree() {
- local base_dir=$(dirname "$STORAGE_FILE")
- echo
- log_info "文件结构:"
- echo -e "${BLUE}$base_dir${NC}"
- echo "├── globalStorage"
- echo "│ ├── storage.json (已修改)"
- echo "│ └── backups"
-
- # 列出备份文件
- if [ -d "$BACKUP_DIR" ]; then
- local backup_files=("$BACKUP_DIR"/*)
- if [ ${#backup_files[@]} -gt 0 ]; then
- for file in "${backup_files[@]}"; do
- if [ -f "$file" ]; then
- echo "│ └── $(basename "$file")"
- fi
- done
- else
- echo "│ └── (空)"
- fi
- fi
- echo
+# 生成新的 ID
+generate_ids() {
+ local user_home=$1
+ local cursor_dir_name=$(basename $(find_cursor_dir))
+ local config_file="$user_home/.config/$cursor_dir_name/User/globalStorage/storage.json"
+
+ local new_machine_id=$(uuidgen | tr -d '-')
+ local new_device_id=$(uuidgen)
+ local new_sqm_id="$(uuidgen | tr '[:lower:]' '[:upper:]')"
+
+ log "DEBUG" "生成新的 ID:"
+ log "DEBUG" "Machine ID: $new_machine_id"
+ log "DEBUG" "Device ID: $new_device_id"
+ log "DEBUG" "SQM ID: $new_sqm_id"
+
+ if [ ! -f "$config_file" ]; then
+ mkdir -p "$(dirname "$config_file")"
+ echo '{}' > "$config_file"
+ fi
+
+ echo "$new_machine_id" | tr -d '-' | cut -c1-32 > "/etc/machine-id"
+
+ tmp_file=$(mktemp)
+ jq --arg machine "$new_machine_id" \
+ --arg device "$new_device_id" \
+ --arg sqm "{$new_sqm_id}" \
+ '.telemetry.machineId = $machine |
+ .telemetry.devDeviceId = $device |
+ .telemetry.sqmId = $sqm' "$config_file" > "$tmp_file"
+
+ mv "$tmp_file" "$config_file"
+ chmod 444 "$config_file"
+ chattr +i "$config_file" 2>/dev/null || true
}
-# 显示公众号信息
-show_follow_info() {
- echo
- echo -e "${GREEN}================================${NC}"
- echo -e "${YELLOW} 关注公众号【煎饼果子卷AI】一起交流更多Cursor技巧和AI知识(脚本免费、关注公众号加群有更多技巧和大佬) ${NC}"
- echo -e "${GREEN}================================${NC}"
- echo
+# 关闭更新
+disable_updates() {
+ local user_home=$1
+ local updater_dir="$user_home/.config/cursor-updater"
+
+ log "WARN" "设置更新..."
+ echo -e "选择一项操作: \n1) 禁用更新 \n2) 保持不变"
+ read -r -p "您的选择 [1/2: " choice /dev/null || log "WARN" "阻止更新失败"
+ log "INFO" "禁用自动更新"
+ fi
}
-# 修改 disable_auto_update 函数,在失败处理时添加手动教程
-disable_auto_update() {
- echo
- log_warn "是否要禁用 Cursor 自动更新功能?"
- echo "0) 否 - 保持默认设置 (按回车键)"
- echo "1) 是 - 禁用自动更新"
- read -r choice
-
- if [ "$choice" = "1" ]; then
- echo
- log_info "正在处理自动更新..."
- local updater_path="$HOME/.config/cursor-updater"
-
- # 定义手动设置教程
- show_manual_guide() {
- echo
- log_warn "自动设置失败,请尝试手动操作:"
- echo -e "${YELLOW}手动禁用更新步骤:${NC}"
- echo "1. 打开终端"
- echo "2. 复制粘贴以下命令:"
- echo -e "${BLUE}rm -rf \"$updater_path\" && touch \"$updater_path\" && chmod 444 \"$updater_path\"${NC}"
- echo
- echo -e "${YELLOW}如果上述命令提示权限不足,请使用 sudo:${NC}"
- echo -e "${BLUE}sudo rm -rf \"$updater_path\" && sudo touch \"$updater_path\" && sudo chmod 444 \"$updater_path\"${NC}"
- echo
- echo -e "${YELLOW}如果要添加额外保护(推荐),请执行:${NC}"
- echo -e "${BLUE}sudo chattr +i \"$updater_path\"${NC}"
- echo
- echo -e "${YELLOW}验证方法:${NC}"
- echo "1. 运行命令:ls -l \"$updater_path\""
- echo "2. 确认文件权限为 r--r--r--"
- echo "3. 运行命令:lsattr \"$updater_path\""
- echo "4. 确认有 'i' 属性(如果执行了 chattr 命令)"
- echo
- log_warn "完成后请重启 Cursor"
- }
-
- if [ -d "$updater_path" ]; then
- rm -rf "$updater_path" 2>/dev/null || {
- log_error "删除 cursor-updater 目录失败"
- show_manual_guide
- return 1
- }
- log_info "成功删除 cursor-updater 目录"
- fi
-
- touch "$updater_path" 2>/dev/null || {
- log_error "创建阻止文件失败"
- show_manual_guide
- return 1
- }
-
- if ! chmod 444 "$updater_path" 2>/dev/null || ! chown "$CURRENT_USER:$CURRENT_USER" "$updater_path" 2>/dev/null; then
- log_error "设置文件权限失败"
- show_manual_guide
- return 1
- fi
-
- # 尝试设置不可修改属性
- if command -v chattr &> /dev/null; then
- chattr +i "$updater_path" 2>/dev/null || {
- log_warn "chattr 设置失败"
- show_manual_guide
- return 1
- }
- fi
-
- # 验证设置是否成功
- if [ ! -f "$updater_path" ] || [ -w "$updater_path" ]; then
- log_error "验证失败:文件权限设置可能未生效"
- show_manual_guide
- return 1
- fi
-
- log_info "成功禁用自动更新"
- else
- log_info "保持默认设置,不进行更改"
- fi
-}
-
-# 主函数
+# 主要功能
main() {
- # 检查是否为 Linux 系统
- if [[ $(uname) != "Linux" ]]; then
- log_error "本脚本仅支持 Linux 系统"
- exit 1
- fi
-
- clear
- # 显示 Logo
- echo -e "
- ██████╗██╗ ██╗██████╗ ███████╗ ██████╗ ██████╗
+ check_permissions
+ clear
+
+ echo -e "
+ ██████╗██╗ ██╗██████╗ ███████╗ ██████╗ ██████╗
██╔════╝██║ ██║██╔══██╗██╔════╝██╔═══██╗██╔══██╗
██║ ██║ ██║██████╔╝███████╗██║ ██║██████╔╝
██║ ██║ ██║██╔══██╗╚════██║██║ ██║██╔══██╗
╚██████╗╚██████╔╝██║ ██║███████║╚██████╔╝██║ ██║
╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝ ╚═════╝ ╚═╝ ╚═╝
- "
- echo -e "${BLUE}================================${NC}"
- echo -e "${GREEN} Cursor 设备ID 修改工具 (Linux版) ${NC}"
- echo -e "${YELLOW} 关注公众号【煎饼果子卷AI】 ${NC}"
- echo -e "${YELLOW} 一起交流更多Cursor技巧和AI知识(脚本免费、关注公众号加群有更多技巧和大佬) ${NC}"
- echo -e "${BLUE}================================${NC}"
- echo
- echo -e "${YELLOW}[重要提示]${NC} 本工具支持 Cursor v0.47.x"
- echo -e "${YELLOW}[重要提示]${NC} 本工具免费,如果对您有帮助,请关注公众号【煎饼果子卷AI】"
- echo
-
- check_permissions
- check_and_kill_cursor
- backup_config
- generate_new_config
- show_file_tree
- show_follow_info
-
- # 添加禁用自动更新功能
- disable_auto_update
-
- log_info "请重启 Cursor 以应用新的配置"
- show_follow_info
+ "
+ echo -e "${BLUE}================================${NC}"
+ echo -e "${GREEN} Cursor 设备ID 修改工具 (Linux版) ${NC}"
+ echo -e "${YELLOW} 关注公众号【煎饼果子卷AI】 ${NC}"
+ echo -e "${YELLOW} 一起交流更多Cursor技巧和AI知识(脚本免费、关注公众号加群有更多技巧和大佬) ${NC}"
+ echo -e "${BLUE}================================${NC}"
+ echo
+ echo -e "${YELLOW}[重要提示]${NC} 本工具支持 Cursor v0.47.x"
+ echo -e "${YELLOW}[重要提示]${NC} 本工具免费,如果对您有帮助,请关注公众号【煎饼果子卷AI】"
+ echo
+
+ local current_user=$(logname 2>/dev/null || echo "$SUDO_USER")
+ local user_home=$(getent passwd "$current_user" | cut -d: -f6)
+
+ terminate_cursor
+ backup_files "$user_home"
+ generate_ids "$user_home"
+ disable_updates "$user_home"
+
+ log "INFO" "操作完成! 请重新启动Cursor"
}
-# 执行主函数
-main
+main "$@"