Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【简化】一个python文件 #61

Open
white0dew opened this issue Dec 19, 2024 · 2 comments
Open

【简化】一个python文件 #61

white0dew opened this issue Dec 19, 2024 · 2 comments

Comments

@white0dew
Copy link

如下:

import os
import json
import uuid
from datetime import date
import ctypes
import sys

def is_admin():
    try:
        return ctypes.windll.shell32.IsUserAnAdmin()
    except:
        return False

def main():
    if not is_admin():
        print("请以管理员权限运行此脚本!")
        input("按Enter键退出...")
        sys.exit()

    try:
        # 获取用户配置文件路径
        user_profile = os.environ['USERPROFILE']
        config_path = os.path.join(user_profile, "AppData", "Roaming", "Cursor", "User", "globalStorage")

        # 生成新的设备ID
        device_id = str(uuid.uuid4())

        # 创建基础JSON对象
        json_object = {
            "telemetry.devDeviceId": device_id,
            "telemetry.deviceId": device_id,
            "telemetry.firstWebInstall": date.today().isoformat(),
            "telemetry.webInstallId": device_id,
            "update.lastCheckDate": date.today().isoformat(),
            "update.updateChannel": "stable",
            "workbench.hasSeenOnboarding": True,
            "workbench.theme": "Monokai Pro",
            "workbench.colorTheme": "Monokai Pro",
            "telemetry.machineId": device_id,
            "settingsVersion": 2,
            "sync.machineId": device_id
        }

        # 确保目录存在
        os.makedirs(config_path, exist_ok=True)

        # 将JSON对象保存到文件
        storage_file = os.path.join(config_path, "storage.json")
        with open(storage_file, 'w', encoding='utf-8') as f:
            json.dump(json_object, f, indent=2)

        print(f"已重置 storage.json: {storage_file}")
        print("重置完成!")
        print("请重新启动 Cursor 以应用更改。")

    except Exception as e:
        print(f"发生错误: {e}")

    input("按Enter键退出...")

if __name__ == "__main__":
    main()


@white0dew
Copy link
Author

大伙如果你们也成功了的话,不妨留个言?

@ccchan234
Copy link

我也叫python 做了個GUI,
就計算那 2 個UUID 及 2個 alike UUID.
自已手動改入 windows 的那個.json.
人手吧, 安全一點。

有人要再說。

我都不敢跑其他人的。
有些跑了看不到結果, 怕怕。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants