Skip to content

Instantly share code, notes, and snippets.

@andrew-ma
Last active November 16, 2021 00:55
Show Gist options
  • Save andrew-ma/9663afc75ed402ca446b9796353f0fc3 to your computer and use it in GitHub Desktop.
Save andrew-ma/9663afc75ed402ca446b9796353f0fc3 to your computer and use it in GitHub Desktop.
Edge Extension File Download
var extensionName = document.title.split(" -")[0];
var extensionNameForFile = extensionName.replaceAll(" ", "_");
var extensionIDRegex = /(?:[^:]+[:][/][/])(?:.*[/])([^?]+)/;
var extensionID = window.location.href.match(extensionIDRegex)[1];
console.log("Extension ID: ", extensionID);
var extensionURL = `https://edge.microsoft.com/extensionwebstorebase/v1/crx?response=redirect&prod=chromiumcrx&prodchannel=&x=id%3D${extensionID}%26installsource%3Dondemand%26uc`
console.log("Extension File Download: ", extensionURL);
var parentEl = document.querySelector("#main > div > div > div > div.c014 > div.c015 > div > h1");
var aTag = document.createElement("a");
aTag.setAttribute("download", extensionNameForFile + '.crx');
aTag.href = extensionURL;
aTag.innerHTML = extensionNameForFile;
parentEl.appendChild(aTag);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment