đź”§ Script to automatically fetch and download the latest VSIX package of a Visual Studio Code extension from its Marketplace page. It parses the page to extract the publisher, extension name, and latest version, then builds the VSIX URL and downloads the file automatically.
This script automatically fetches and downloads the latest VSIX package of a Visual Studio Code extension from its Marketplace page.
- âś… Extracts publisher and extension name from
og:url
- âś… Reads the latest version from the embedded Marketplace JSON
- âś… Builds the correct VSIX download URL
- âś… Automatically downloads the
.vsix
file in the browser
-
Go to the extension’s Marketplace page
Example:
https://marketplace.visualstudio.com/items?itemName=GitHub.copilot
-
Open browser devtools → Console tab
-
Paste the script and hit Enter
The script will automatically:
- Fetch the latest
.vsix
package - Trigger a download in your browser
(async () => {
const og = document.querySelector('meta[property="og:url"]');
if (!og) throw new Error('og:url meta tag not found');
const itemName = new URL(og.content).searchParams.get('itemName');
if (!itemName) throw new Error('itemName not in og:url');
const [publisher, extension] = itemName.split('.');
const ji = document.querySelector('script.jiContent[type="application/json"]');
if (!ji) throw new Error('Marketplace JSON blob not found');
const meta = JSON.parse(ji.textContent);
const version = meta.Versions?.[0]?.version;
if (!version) throw new Error('No version info found in JSON');
const vsixUrl = `https://marketplace.visualstudio.com/_apis/public/gallery/publishers/${publisher}/vsextensions/${extension}/${version}/vspackage`;
const resp = await fetch(vsixUrl);
if (!resp.ok) throw new Error(`VSIX fetch failed: ${resp.status}`);
const blob = await resp.blob();
const a = document.createElement('a');
a.href = URL.createObjectURL(blob);
a.download = `${publisher}.${extension}-${version}.vsix`;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
})();
- Works only on the extension’s Marketplace page, not directly from raw URLs.
- You need to manually paste it in the browser console; it is not a userscript.
- Useful when the direct download link is broken or unavailable.
MIT License