idea和vs code都可以,vs studio咋整?
1 个赞
木有用过哎,顶一下
我也不知道, 但是看别人的激活脚本是这么写的
import os
import platform
from activator.base_activator import BaseActivator
class VisualStudio(BaseActivator):
def __init__(self):
user_home_dir = os.path.expanduser("~")
self.search_path = ""
if platform.system() == "Windows":
self.search_path = os.path.join(
user_home_dir,
"AppData",
"Local",
"Microsoft",
"VisualStudio",
"*",
"Extensions",
"**",
"GitHub.Copilot.VisualStudio.dll",
)
self.path_suffix = os.path.join("..", "service", "dist")
这个脚本是不是没写完?
人目录结构都给你写出来了 过去看一眼呗,
是因为没有能直接运行的么?
我能看懂的是要修改的内容在GitHub.Copilot.VisualStudio.dll这个文件里,反编译了之后还是没有头绪
activate.py
import platform
from rich.console import Console
from rich.markdown import Markdown
import activator.auth as auth
import utils.machine_id as machine_id
from activator.android_studio import AndroidStudio
from activator.jetbrains import JetBrains
from activator.vs import VisualStudio
from activator.vscode import VSCode
from frozen_dir import app_path
console = Console()
APP_PATH = app_path()
def activate(key, version):
_machine_id = machine_id.get_machine_id()
is_valid, response = auth.auth_copilot(key, _machine_id, version)
if not is_valid:
console.print("授权失败", style="bold red")
console.print("错误信息:" + response)
if "machine num exceeded" in response:
console.print(
"绑定机器数超过限制,如果您使用的是同一台电脑,可能由于某些原因您电脑的机器码发生了变化,请联系客服解绑\n另外,请前往网盘检查您的activator是否是最新版本,如果不是,请解绑后使用最新版本授权激活",
style="bold yellow",
)
else:
if "too old version" in response:
console.print("您的activator版本过旧,请前往网盘下载最新版本", style="bold yellow")
console.print("下载链接: https://www.lanzoub.com/b04wcnlqj")
console.print("提取密码: dxke")
return
while True:
console.print(Markdown("1. 激活VSCode (激活前请先升级到最新版本)"))
console.print(Markdown("2. 激活JetBrains全家桶"))
console.print(Markdown("3. 激活Android Studio"))
console.print(Markdown("4. 激活VisualStudio (支持Windows2022以上版本)"))
console.print(Markdown("5. 退出"))
choice = input("\n请选择要进行的操作(输入对应数字按回车即可):")
if choice == "1":
activator = VSCode()
else:
if choice == "2":
activator = JetBrains()
else:
if choice == "3":
activator = AndroidStudio()
else:
if choice == "4":
if platform.system() == "Windows":
activator = VisualStudio()
else:
console.print("\n只支持Windows激活VS\n", style="bold yellow")
continue
else:
if choice == "5":
break
else:
console.print("输入错误,请重新输入", style="yellow")
continue
copilot_path = activator.get_path()
if len(copilot_path) == 0:
console.print("未检测到Copilot插件,请安装后使用", style="bold yellow")
else:
if choice == "1":
activator.modify_extension(copilot_path, key)
else:
activator.modify_extension(copilot_path)
console.print("\n激活成功,重启应用后生效\n", style="bold green")
input("按回车键继续")
base_activator.py
import glob
import os
import platform
import shutil
from rich.console import Console
from frozen_dir import app_path
console = Console()
APP_PATH = app_path()
class BaseActivator:
def __init__(self):
self.search_path = ""
self.path_suffix = ""
def get_path(self):
if self.search_path == "":
return []
else:
matching_dirs = glob.glob((self.search_path), recursive=True)
agent_paths = []
for dir in matching_dirs:
if os.path.exists(os.path.join(dir, self.path_suffix)):
agent_paths.append(os.path.join(dir, self.path_suffix))
return agent_paths
def modify_extension(self, paths):
if not paths:
paths = self.get_path()
agent_bin_path = os.path.join(APP_PATH, "bin")
for file_path in paths:
if os.path.exists(file_path):
if os.path.exists(file_path):
try:
shutil.rmtree(file_path)
except Exception as e:
console.print(
"\n请关闭要授权的应用再试,如果关闭了还是不行,可能后台还有残留进程,重启电脑即可\n",
style="bold red",
)
break
os.mkdir(file_path)
for file in os.listdir(agent_bin_path):
shutil.copy(os.path.join(agent_bin_path, file), file_path)
user_home_dir = os.path.expanduser("~")
if platform.system() == "Darwin":
hosts_file = os.path.join(
user_home_dir, ".config", "github-copilot", "hosts.json"
)
if os.path.exists(hosts_file):
os.remove(hosts_file)
elif platform.system() == "Windows":
hosts_file = os.path.join(
user_home_dir, "AppData", "Local", "github-copilot", "hosts.json"
)
if os.path.exists(hosts_file):
os.remove(hosts_file)
他这激活和coco有啥关系?仓库里搜了下coco也没