42 lines
1.3 KiB
Python
42 lines
1.3 KiB
Python
import json
|
|
import sqlite3
|
|
|
|
prefs_path = r"C:\Users\Administrator\AppData\Roaming\Cursor\molten\prefs.json"
|
|
db_path = r"C:\Users\Administrator\AppData\Roaming\Cursor\User\globalStorage\state.vscdb"
|
|
with open(prefs_path, encoding="utf-8") as f:
|
|
prefs = json.load(f)
|
|
prefs["i18nGate"] = True
|
|
prefs["language"] = "zh-CN"
|
|
with open(prefs_path, "w", encoding="utf-8", newline="\n") as f:
|
|
json.dump(prefs, f, ensure_ascii=False, indent=2)
|
|
f.write("\n")
|
|
|
|
con = sqlite3.connect(db_path, timeout=20)
|
|
try:
|
|
mirror = con.execute(
|
|
"SELECT value FROM ItemTable WHERE key = ?",
|
|
("cursor.agentsWindow.gateMirror",),
|
|
).fetchone()
|
|
auth_id = json.loads(mirror[0])["authId"] if mirror else ""
|
|
if not auth_id:
|
|
raise SystemExit("missing auth id")
|
|
override = json.dumps({"authId": auth_id, "mode": "molten"}, separators=(",", ":"))
|
|
row = con.execute(
|
|
"SELECT key FROM ItemTable WHERE key = ?",
|
|
("cursor.agentsWindow.override",),
|
|
).fetchone()
|
|
if row:
|
|
con.execute(
|
|
"UPDATE ItemTable SET value = ? WHERE key = ?",
|
|
(override, "cursor.agentsWindow.override"),
|
|
)
|
|
else:
|
|
con.execute(
|
|
"INSERT INTO ItemTable (key, value) VALUES (?, ?)",
|
|
("cursor.agentsWindow.override", override),
|
|
)
|
|
con.commit()
|
|
finally:
|
|
con.close()
|
|
print("ok")
|