Created
May 13, 2025 21:27
-
-
Save khoerodin/b5fb49dd9ec01ea4acc05081ba182756 to your computer and use it in GitHub Desktop.
VSCode Extension Downloader
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
// open extension page | |
// copy-paste this code to browser console | |
(async () => { | |
const match = location.href.match(/itemName=([^&]+)/); | |
if (!match) { | |
console.error('Tidak dapat menemukan itemName di URL.'); | |
return; | |
} | |
const [publisher, extensionName] = match[1].split('.'); | |
const apiUrl = `https://marketplace.visualstudio.com/_apis/public/gallery/extensionquery`; | |
const body = { | |
filters: [{ | |
criteria: [{ filterType: 7, value: `${publisher}.${extensionName}` }] | |
}], | |
flags: 103 | |
}; | |
const res = await fetch(apiUrl, { | |
method: 'POST', | |
headers: { | |
'Content-Type': 'application/json', | |
'Accept': 'application/json;api-version=3.0-preview.1' | |
}, | |
body: JSON.stringify(body) | |
}); | |
const json = await res.json(); | |
const extension = json.results[0].extensions[0]; | |
const version = extension.versions[0].version; | |
const vsixAsset = extension.versions[0].files.find(f => f.assetType === 'Microsoft.VisualStudio.Services.VSIXPackage'); | |
const vsixUrl = vsixAsset.source; | |
const vsixRes = await fetch(vsixUrl); | |
const blob = await vsixRes.blob(); | |
const a = document.createElement('a'); | |
a.href = URL.createObjectURL(blob); | |
a.download = `${extensionName}-${version}.vsix`; | |
document.body.appendChild(a); | |
a.click(); | |
document.body.removeChild(a); | |
URL.revokeObjectURL(a.href); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment