MCPcopy Create free account
hub / github.com/Useful-Scripts-Extension/useful-script / forceDownload

Function forceDownload

scripts/insta_injectDownloadBtn.js:907–917  ·  view source on GitHub ↗
(blob, filename, extension)

Source from the content-addressed store, hash-verified

905 }
906
907 function forceDownload(blob, filename, extension) {
908 // ref: https://stackoverflow.com/questions/49474775/chrome-65-blocks-cross-origin-a-download-client-side-workaround-to-force-down
909 var a = document.createElement("a");
910 if (replaceJpegWithJpg) extension = extension.replace("jpeg", "jpg");
911 a.download = filename + "." + extension;
912 a.href = blob;
913 // For Firefox https://stackoverflow.com/a/32226068
914 document.body.appendChild(a);
915 a.click();
916 a.remove();
917 }
918
919 // Current blob size limit is around 500MB for browsers
920 function downloadResource(url, filename) {

Callers 1

downloadResourceFunction · 0.85

Calls 3

replaceMethod · 0.80
clickMethod · 0.80
removeMethod · 0.45

Tested by

no test coverage detected