当前位置: 首页 > web >正文

如何下载VSCode插件市场为VSIX文件

引言

估计是VSCode的模仿者太多了,VSCode Market现在不运行从其页面下载VSIX文件了,这对想在支持VSCode插件的第三方集成环境中安装VSCode插件的难度增大了。今天在网上找到一个脚本可以下载VSCode插件,分享给大家。

解决方案

脚本下载

就像有脚本程序可以下载YouTube视频一样,也有人研究了VSCode下载插件的流程,写了这样一个脚本:GitHub - mjmirza/Download-VSIX-From-Visual-Studio-Market-Place: This script allows you to download VS Code extensions as VSIX files directly from the Visual Studio Marketplace.

 

这个网站提供了一个downloadVSIX.js用于下载VSCode插件,亲测可用,分享给大家。

考虑到有人上Github不方便,把脚本粘贴如下。不过如果能够上Github的,建议去给原作者打个星。

/***
#          Download VS Code extensions as VSIX
#          Author: Mirza Iqbal
***/// *** SCRIPTS NOT TESTED After July 2024 *** ///***
// First 
***/
!function() {(function() {const extensionData = {version: "",publisher: "",identifier: "",getDownloadUrl: function() {return `https://${this.identifier.split(".")[0]}.gallery.vsassets.io/_apis/public/gallery/publisher/${this.identifier.split(".")[0]}/extension/${this.identifier.split(".")[1]}/${this.version}/assetbyname/Microsoft.VisualStudio.Services.VSIXPackage`;},getFileName: function() {return `${this.identifier}_${this.version}.vsix`;},getDownloadButton: function() {const button = document.createElement("a");button.innerHTML = "Download VSIX";button.href = "javascript:void(0);";button.style.fontFamily = "wf_segoe-ui,Helvetica Neue,Helvetica,Arial,Verdana";button.style.display = "inline-block";button.style.padding = "2px 5px";button.style.background = "darkgreen";button.style.color = "white";button.style.fontWeight = "bold";button.style.margin = "2px 5px";button.setAttribute("data-url", this.getDownloadUrl());button.setAttribute("data-filename", this.getFileName());button.onclick = function(event) {event.target.onclick = null;event.target.innerHTML = "Downloading VSIX...";const xhr = new XMLHttpRequest();console.log(event.target.getAttribute("data-url"));xhr.open("GET", event.target.getAttribute("data-url"), true);xhr.responseType = "blob";xhr.onprogress = function(event) {if (event.lengthComputable) {const progress = (event.loaded / event.total * 100).toFixed(0);event.target.innerHTML = `Downloading VSIX... ${progress}%`;}};xhr.onload = function() {if (this.status === 200) {const blob = this.response;const link = document.createElement("a");link.href = window.URL.createObjectURL(blob);link.download = event.target.getAttribute("data-filename");link.click();event.target.href = link.href;event.target.download = link.download;event.target.innerHTML = "Download VSIX";} else {event.target.innerHTML = "Error. Please reload the page and try again.";alert(`Error ${this.status} error receiving the document.`);}};xhr.onerror = function() {event.target.innerHTML = "Error. Please reload the page and try again.";alert(`Error ${this.target.status} occurred while receiving the document.`);};xhr.send();};return button;}};const metadataMap = {Version: "version",Publisher: "publisher","Unique Identifier": "identifier"};const metadataRows = document.querySelectorAll(".ux-table-metadata tr");for (let i = 0; i < metadataRows.length; i++) {const row = metadataRows[i];const cells = row.querySelectorAll("td");if (cells.length === 2) {const key = cells[0].innerText.trim();const value = cells[1].innerText.trim();if (metadataMap.hasOwnProperty(key)) {extensionData[metadataMap[key]] = value;}}}// Handle the case where the element might not existconst moreInfoElement = document.querySelector(".vscode-moreinformation");if (moreInfoElement) {moreInfoElement.parentElement.appendChild(extensionData.getDownloadButton()).scrollIntoView();} else {console.error("Element with class 'vscode-moreinformation' not found.");}})()
}();/***
// 2nd 
***/
(function() {const URL_VSIX_PATTERN = 'https://marketplace.visualstudio.com/_apis/public/gallery/publishers/${publisher}/vsextensions/${extension}/${version}/vspackage';const itemName = new URL(window.location.href).searchParams.get('itemName');const [publisher, extension] = itemName.split('.');const version = document.querySelector('#versionHistoryTab tbody tr .version-history-container-column').textContent;const url = URL_VSIX_PATTERN.replace('${publisher}', publisher).replace('${extension}', extension).replace('${version}', version);window.open(url, '_blank');})();

 脚本使用

先进入VSCode的插件市场:Extensions for Visual Studio family of products | Visual Studio Marketplace

找到你感兴趣的插件,比如CMake Tools,然后按F12键出现右边的开发者窗口。

然后在下面的控制台粘贴前面的脚本,然后按下回车键,这个脚本就会被执行,并下载你所需要的插件的VSIX文件。

注意:首次在浏览器中粘贴代码的时候,浏览器会有个提示信息,按照提示信息确认你确实需要粘贴脚本。

插件安装测试

我使用的第三方IDE是HiSpark Studio 1.0.0.11,这是海思开发的一个单片机开发的集成环境。下面是按照了CMake Tools后的场景。

结语

感觉最近IDE市场不太太平,用户只能在夹缝里生存。

http://www.xdnf.cn/news/2175.html

相关文章:

  • 在Mybatis中为什么要同时指定扫描mapper接口和 mapper.xml 文件,理论单独扫描 xml 文件就可以啊
  • Maven进阶知识
  • 【TypeScript】速通篇
  • 打破云墙:多云环境中的DevOps实践指南
  • 5.3/Q1,GBD数据库最新文章解读
  • 【Java面试笔记:进阶】22.AtomicInteger底层实现原理是什么?如何在自己的产品代码中应用CAS操作?
  • QQMusic项目功能总结
  • openEuler对比CentOS的核心优势分析
  • Web端ER可视化
  • 部署大模型需要多少GPU显存?以DeepSeek R1部署为例
  • MongoDB Atlas与MongoDB连接MCP服务器的区别解析
  • SpringBoot物资管理系统 | JavaWeb项目设计与实现
  • 山东大学离散数学第九章习题解析
  • 雪花算法
  • 深入解析NuttX:为何它是嵌入式RTOS领域的标杆?​​
  • 多模态大语言模型arxiv论文略读(四十三)
  • 力扣2444. 统计定界子数组的数目:Java三种解法详解
  • 5G助力智慧城市的崛起——从概念到落地的技术实践
  • 哈希表的模拟实现---C++
  • Ubuntu下安装vsode+qt搭建开发框架(一)
  • 推荐几个免费提取音视频文案的工具(SRT格式、通义千问、飞书妙记、VideoCaptioner、AsrTools)
  • 直线模组精度测试的标准是什么?
  • Linux 进程控制
  • 树状数组底层逻辑探讨 / 模版代码-P3374-P3368
  • 阿里云VS AWS中国区:ICP备案全攻略与常见误区解析
  • 判断 ONNX 模型是否支持 GPU
  • 微信小程序 - 根据经纬度打开导航
  • 追风赶月莫停留
  • WebcamJS中文文档
  • Debian安装避坑