Merge pull request #4 from ttcy/main

Added download via bookmark method.

@ttcy  Thank you for the contribution, truly appreciated.
This commit is contained in:
Mirza Iqbal
2025-03-21 20:28:47 +01:00
committed by GitHub
2 changed files with 8 additions and 0 deletions

View File

@@ -9,6 +9,13 @@ This script allows you to download VS Code extensions as VSIX files directly fro
3. **Paste the script into the console and press Enter.**
4. **A "Download VSIX" button will appear on the page.** Click it to download the VSIX file.
Or
1. **Copy all content from "downloadVSIX-V2.bookmark"**
2. **Create a bookmark in your browser (tested with Chrome) and paste the content as the URL.**
3. **Open the VS Code extension page on the Visual Studio Marketplace.**
4. **Click on the bookmark and the VSIX file will be downloaded automatically.**
## Script Breakdown
The script consists of two parts:

1
downloadVSIX-V2.bookmark Normal file
View File

@@ -0,0 +1 @@
javascript:(function(){var extensionData={version:"",publisher:"",identifier:"",getDownloadUrl:function(){var p=this.identifier.split(".");return "https://"+p[0]+".gallery.vsassets.io/_apis/public/gallery/publisher/"+p[0]+"/extension/"+p[1]+"/"+this.version+"/assetbyname/Microsoft.VisualStudio.Services.VSIXPackage"},getFileName:function(){return this.identifier+"_"+this.version+".vsix"},getDownloadButton:function(){var b=document.createElement("a");b.innerHTML="Download VSIX";b.style.fontFamily="wf_segoe-ui,Helvetica Neue,Helvetica,Arial,Verdana";b.style.display="inline-block";b.style.padding="10px 20px";b.style.background="darkgreen";b.style.color="white";b.style.fontWeight="bold";b.style.fontSize="16px";b.style.margin="2px 5px";b.style.textDecoration="none";b.setAttribute("data-download-url",this.getDownloadUrl());b.setAttribute("data-download-filename",this.getFileName());b.onclick=function(e){var d=e.target.getAttribute("data-download-url"),f=e.target.getAttribute("data-download-filename"),a=document.createElement("a");a.href=d;a.download=f;a.click()};return b}};var metadataMap={"Version":"version","Publisher":"publisher","Unique Identifier":"identifier"};var rows=document.querySelectorAll(".ux-table-metadata tr");for(var i=0;i<rows.length;i++){var cells=rows[i].querySelectorAll("td");if(cells.length===2){var key=cells[0].innerText.trim(),value=cells[1].innerText.trim();if(metadataMap.hasOwnProperty(key))extensionData[metadataMap[key]]=value}};var mi=document.querySelector(".vscode-moreinformation");if(mi){mi.parentElement.appendChild(extensionData.getDownloadButton());}else{console.error("Element with class 'vscode-moreinformation' not found.");}var URL_VSIX_PATTERN='https://marketplace.visualstudio.com/_apis/public/gallery/publishers/${publisher}/vsextensions/${extension}/${version}/vspackage';var itemName=new URL(window.location.href).searchParams.get("itemName");if(itemName){var parts=itemName.split("."),pub=parts[0],ext=parts[1],ver=document.querySelector("#versionHistoryTab tbody tr .version-history-container-column").textContent;var url=URL_VSIX_PATTERN.replace("${publisher}",pub).replace("${extension}",ext).replace("${version}",ver);window.open(url,"_blank");}else{console.error("itemName parameter not found in URL");}})();