VS Code Extension Downloader

Downloads .vsix package on VS Code Marketplace

  1. // ==UserScript==
  2. // @name VS Code Extension Downloader
  3. // @namespace https://github.com/yookibooki/userscripts
  4. // @version 1.0
  5. // @description Downloads .vsix package on VS Code Marketplace
  6. // @match https://marketplace.visualstudio.com/items*
  7. // ==/UserScript==
  8.  
  9. (function() {
  10. 'use strict';
  11.  
  12. const url = new URL(window.location.href);
  13. const itemName = url.searchParams.get("itemName");
  14. if (!itemName) return;
  15.  
  16. const [publisher, extensionName] = itemName.split(".");
  17. if (!publisher || !extensionName) return;
  18.  
  19. const observer = new MutationObserver(() => {
  20. const versionCell = document.querySelector("table.ux-table-metadata td[aria-labelledby='Version'], table.ux-table-metadata td[aria-labelledby='version']");
  21.  
  22. if (versionCell && !versionCell.querySelector('.vsix-download-link')) {
  23. const version = versionCell.textContent.trim();
  24.  
  25. const link = document.createElement("a");
  26. link.href = `https://marketplace.visualstudio.com/_apis/public/gallery/publishers/${publisher}/vsextensions/${extensionName}/${version}/vspackage/`;
  27. link.textContent = version;
  28. link.className = "vsix-download-link";
  29. link.title = "Download .vsix package";
  30.  
  31. versionCell.textContent = '';
  32. versionCell.appendChild(link);
  33. }
  34. });
  35.  
  36. observer.observe(document, { childList: true, subtree: true });
  37. })();