Last active
January 12, 2023 14:57
-
-
Save Mido22/a1c660f0955250f96309ec6cdccf17d2 to your computer and use it in GitHub Desktop.
In Visual Studio Code: for adding a download link to download extension in .vsix format to install offiline
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name get vsix | |
// @namespace https://gist.github.com/Mido22 | |
// @include https://marketplace.visualstudio.com/items?itemName=* | |
// @version 0.0.1 | |
// @grant none | |
// ==/UserScript== | |
window.addEventListener('load', setDownloadLink) | |
function setDownloadLink () { | |
let version = document.querySelector('.ux-table-metadata > tbody:nth-child(1) > tr:nth-child(1) > td:nth-child(2) > div:nth-child(1)').innerText | |
, itemDetails = window.location.search.replace('?', '').split('&').filter(str => !str.indexOf('itemName')).map(str => str.split('=')[1])[0] | |
if (!itemDetails) return; | |
let [author, extension] = itemDetails.split('.') | |
, lAuthor = author.toLowerCase() | |
, href = `https://${lAuthor}.gallery.vsassets.io:443/_apis/public/gallery/publisher/${author}/extension/${extension}/${version}/assetbyname/Microsoft.VisualStudio.Services.VSIXPackage` | |
, element = document.createElement('a') | |
element.href = href | |
element.className = 'vscode-moreinformation dark' | |
element.innerHTML = 'download .vsix file' | |
element.download = `${extension}.${version}.vsix` | |
document.querySelector('.vscode-install-info-container').appendChild(element) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment