Files
Download-VSIX-From-Visual-S…/downloadVSIX-V2.bookmark
2025-03-20 21:23:29 +08:00

1 line
2.2 KiB
Plaintext

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");}})();