免责声明:本文所述内容仅限于个人之间学习交流vscode插件技术,禁止他人依此做出“破解”、“商业用途”等侵权行为。若他人依此产生侵权行为,本人概不负责。
项目场景:
某些特定场景下,第三方提供的vscode插件可能在功能上会有不足,这个时候可以尝试进行一些适当的修改以匹配个人需求。
问题描述:
比如,有这样一个vscode插件,使用中发现部分功能存在问题。
- 正常的插件功能应该是这样子的:
- 实际上自己使用是这样子的:
从官方文档可知,插件本身是具备离线使用的功能的,但是先要给钱,否则不给用。有时候只是想临时用用里面个别功能,比如可以看看曲线啥的就行了,并不需要使用插件的完整功能;并且因为“墙”等的原因,也不具备在线访问权限,所以就只能自己修改了。
原因分析:
插件需要在线授权验证,所以可以修改验证判断条件就可以跳过授权。
解决方案:
-
从vscode插件市场下载插件vsix文件;
-
右键vsix文件用压缩软件打开,将
extension.js
解压出来;
-
用vscode打开extension.js,里面可能是一团乱麻,用插件Prettier - Code formatter格式化一下;
-
查找关键词“Upgrade Now”,找到对应的行,向上找到调用函数
_subscribeProjectPanel(e)
,再向上层找到调用函数注释掉即可;
// case "subscribe":
// return (
// this._panel && (this._panel.title = "Subscribe"),
// this._subscribeProjectPanel(e)
// );
-
重新使用压缩软件打开vsix文件里
extension.js
,右键使用记事本打开,找到对应行代码注释掉;
-
更新到压缩包;
-
重新安装插件即可。
小结:
这里仅给出vsix修改思路,不做完整功能修改,仅做技术学习交流之用。
- 补充1:查找第一个
loggedIn: !1,
改为loggedIn: 1,
则去掉登陆验证。 - 补充2:跳过验证到“Open Project”,能够创建工程了,创建工程后打开“main.py”可以看到调试按钮了。
case "subscribe":
/*
return (
this._panel &&
(this._panel.title = "Subscribe"),
this._subscribeProjectPanel(e)
);
*/
case "open-project":
return (
this._panel &&
(this._panel.title = "Open Project"),
this._openProjectPanel(e)
);
- 补充3:首先四个docker镜像都要下到本地,插件会check四个,但目前看到只用到local-platform-services、messaging两个镜像,并且还有版本时间校验(可以在代码里修改版本时间往前),可选注释掉"–rm",注释掉在线下载docker部分;
docker pull quantconnect/lean:latest
docker pull quantconnect/research:latest
docker pull quantconnect/local-platform-services:latest
docker pull quantconnect/messaging:latest
/*
!1 === e.docker
? ((t.check = !1),
(t.extraLabel =
"We could not detect a docker installation, read more <a href='https://www.quantconnect.com/docs/v2/local-platform/installation#03-Install-Docker' >here</a>. <br><a οnclick='SetDockerPath()'>Set Docker Path</a>"))
: !1 === e.dockerRunning
? ((t.check = !1),
(t.extraLabel =
"We found docker but it doesn't seem to be running.."))
: !1 === e.dockerPermissions
? ((t.check = !1),
(t.extraLabel =
"Docker is running but the VSCode user does not have permissions to run it, read more <a href='https://www.quantconnect.com/docs/v2/lean-cli/installation/installing-docker' >here</a>."))
: !1 === e.messagingImage
? ((t.check = !1),
(t.extraLabel =
"Downloading Image 1 of 4:<br>" +
this.getMessagingImagePullProgress()))
: !1 === e.leanImage
? ((t.check = !1),
(t.extraLabel =
"Downloading Image 2 of 4:<br>" +
this.getLeanImagePullProgress()))
: !1 === e.localServicesImage
? ((t.check = !1),
(t.extraLabel =
"Downloading Image 3 of 4:<br>" +
this.getLocalServicesImagePullProgress()))
: !1 === e.researchImage &&
((t.check = !1),
(t.extraLabel =
"Downloading Image 4 of 4:<br>" +
this.getResearchImagePullProgress()));
*/
- 补充4:docker镜像quantconnect/local-playform-services的入口点使用了私有的ResultService库,入口处进行权限认证,无法进一步跳过。
IMAGE CREATED CREATED BY SIZE COMMENT
sha256:5cd4e99377f1a4916ef38e98446f4ca6b96738f3e83b5b14002d7ee208963ef3 2 days ago ENTRYPOINT ["dotnet" "QuantConnect.ResultService.dll"] 0B buildkit.dockerfile.v0
<missing> 2 days ago COPY ./LeanCloud.Services/ResultService/QuantConnect.ResultService/bin/Release /Lean/Launcher/bin/Debug # buildkit 47.5MB buildkit.dockerfile.v0
<missing> 2 days ago ENTRYPOINT ["dotnet" "QuantConnect.Lean.Launcher.dll"] 0B buildkit.dockerfile.v0
<missing> 2 days ago WORKDIR /Lean/Launcher/bin/Debug 0B buildkit.dockerfile.v0
<missing> 2 days ago COPY ./Lean/Report/bin/Debug/ /Lean/Report/bin/Debug/ # buildkit 47.3MB buildkit.dockerfile.v0
<missing> 2 days ago COPY ./Lean/Optimizer.Launcher/bin/Debug/ /Lean/Optimizer.Launcher/bin/Debug/ # buildkit