yhzc2023 发表于 2024-12-23 13:46:31

分享一个 修改cursor 和 windsurf 机器码的 python 脚本


```
import os
import uuid
import json


# 生成随机标识符
def generate_random_hex_id():
    return "".join()


def generate_uuid():
    return str(uuid.uuid4())# 生成标准UUID


def change(mode):
    user_name = os.getenv("USERNAME")
    if mode == "1":
      file_path = rf"C:\Users\{user_name}\AppData\Roaming\Cursor\User\globalStorage\storage.json"
    else:
      file_path = rf"C:\Users\{user_name}\AppData\Roaming\Windsurf\User\globalStorage\storage.json"
    print(file_path)
    with open(file_path, "r") as f:
      data = f.read()
      data_info = json.loads(data)
    if "telemetry.sqmId" in data_info:
      data_info["telemetry.sqmId"] = f"{{{generate_uuid().upper()}}}"
    if "telemetry.machineId" in data_info:
      data_info["telemetry.machineId"] = generate_random_hex_id()
    if "telemetry.macMachineId" in data_info:
      data_info["telemetry.macMachineId"] = generate_random_hex_id()
    if "telemetry.devDeviceId" in data_info:
      data_info["telemetry.devDeviceId"] = generate_uuid()
    with open(file_path, "w") as f:
      json.dump(data_info, f, ensure_ascii=False, indent=4)
    print(f"{'cursor' if mode == '1' else 'windsurf'}修改成功")


if __name__ == "__main__":
    mode = ""
    while True:
      mode = input("cursor 输入1 windsurf输入2\nmode:")
      if mode not in ["1", "2"]:
            print("输入错误")
            continue
      break
    change(mode)

```

李恒道 发表于 2024-12-23 19:48:16

牛逼!
页: [1]
查看完整版本: 分享一个 修改cursor 和 windsurf 机器码的 python 脚本