解决marketplace.visualstudio.com已隐藏下载离线安装包按钮
离线环境下想要安装vs code插件,发现不知何时开始marketplace.visualstudio.com
已隐藏了下载按钮。于是就编写了此脚本并发布到油猴:
visualstudio marketplace toolkit | greasyfork.org
并附上源代码:
//--------------------------marketplace.visualstudio.com----download-------------------------------//
let vsMarketDownloader = (function () {
return {
addDownloadBtn: function () {
if (window.location.host.toUpperCase() !== 'MARKETPLACE.VISUALSTUDIO.COM') return false;
let arr = window.location.href.split('?')[1].split('=')[1].split('.');
let author = arr[0];
let id = arr[1];
var histories = document.querySelectorAll('tr.version-history-container-row');
for (var i = 1; i < histories.length; i++) {
let version = histories[i].firstChild.textContent;
let a = document.createElement('a');
a.className = 'bowtie-icon bowtie-install';
a.style = 'margin-left: 1rem;'
a.href = `https://marketplace.visualstudio.com/_apis/public/gallery/publishers/${author}/vsextensions/${id}/${version}/vspackage`;
histories[i].firstChild.appendChild(a);
}
return true;
}
}
})();
setTimeout(() => {
vsMarketDownloader.addDownloadBtn();
}, 1200);
使用后会在页面的【版本历史】列表中添加一个下载按钮,点击即可下载对应版本的离线安装包。
效果如下: