Skip to content

Instantly share code, notes, and snippets.

@jackyliu16
Created October 27, 2025 17:02
Show Gist options
  • Select an option

  • Save jackyliu16/1e3115130a3ae72939d9ac2c7234f14c to your computer and use it in GitHub Desktop.

Select an option

Save jackyliu16/1e3115130a3ae72939d9ac2c7234f14c to your computer and use it in GitHub Desktop.
Vscode 插件离线下载脚本
// Generater: jackyliu16
// Large models used to generate:grok
// Date: 2025/10/28 12:58AM UTC+8
// Note:
// 1. open https://marketplace.visualstudio.com/
// 2. found the extension that you want
// 3. click F12 or open website terminal
// 4. Copy & Paste this script into it
// 5. Run and click the link to download the VSIX package
// 6. Open VSCode and Install from VSIX
(function() {
// 从 URL 提取发布者和扩展名称
const url = window.location.href;
const urlParams = new URLSearchParams(window.location.search);
const itemName = urlParams.get('itemName');
if (!itemName || !itemName.includes('.')) {
console.error('无法从 URL 提取 itemName 或格式不正确,期望格式为 publisher.extensionName');
return;
}
const [publisher, extensionName] = itemName.split('.');
// 获取版本号
const versionElement = document.querySelector('[aria-labelledby="version"]');
const listElement = document.querySelector('.ux-section-resources ul');
// 错误处理
if (!versionElement || !listElement) {
console.error('无法找到所需元素,请检查以下选择器:');
console.error('版本号:', versionElement ? '找到' : '未找到 ([aria-labelledby="version"])');
console.error('插入位置:', listElement ? '找到' : '未找到 (.ux-section-resources ul)');
return;
}
// 提取版本号
const version = versionElement.innerText; // 例如 2023.18.0(ms-python.python 的版本)
// 构造下载地址
const vsix_url = `https://marketplace.visualstudio.com/_apis/public/gallery/publishers/${publisher}/vsextensions/${extensionName}/${version}/vspackage`;
// 输出调试信息
console.log('发布者:', publisher);
console.log('扩展名:', extensionName);
console.log('版本号:', version);
console.log('下载地址:', vsix_url);
// 插入下载链接到页面
listElement.insertAdjacentHTML('beforeend', `<li><a href="${vsix_url}">下载</a></li>`);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment