Last active
January 10, 2017 08:09
-
-
Save Meir017/778fdcf76a53a5194a767e8b93cde367 to your computer and use it in GitHub Desktop.
adds vsix download liks to https://marketplace.visualstudio.com
This file contains hidden or 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
const extensions = document.querySelectorAll('.carousel-item'); | |
extensions.forEach(e => { | |
const image = e.querySelector('img'); | |
if (image === null) return; | |
addDownloadLink(image); | |
}); | |
/** | |
* @param image {HTMLImageElement} | |
*/ | |
function addDownloadLink(image) { | |
const downloadElement = createDownloadElementFromImage(image); | |
image.parentNode.insertBefore(downloadElement, image.nextSibling); | |
} | |
/** | |
* @param image {HTMLImageElement} | |
*/ | |
function createDownloadElementFromImage(image) { | |
const parts = image.src.split('/'); | |
const publisher = parts[4]; | |
const extensionName = parts[5]; | |
const version = parts[6]; | |
const downloadElement = document.createElement('a'); | |
downloadElement.innerText = 'download vsix' | |
downloadElement.href = createDownloadLink(publisher, extensionName, version); | |
downloadElement.target = '_blank'; | |
downloadElement.setAttribute('onclick',`console.log('${extensionName}.${publisher}.${version}.vsix')`); | |
return downloadElement; | |
} | |
/** | |
* @param publisher {string} | |
* @param extensionName {string} | |
* @param version {string} | |
*/ | |
function createDownloadLink(publisher, extensionName, version) { | |
return `https://${publisher}.gallery.vsassets.io/_apis/public/gallery/publisher/${publisher}/extension/${extensionName}/${version}/assetbyname/Microsoft.VisualStudio.Services.VSIXPackage`; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment