Last active
April 23, 2024 12:30
-
-
Save da8/2d791309f5acf1e299205f85e9314e95 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.clear(); | |
function saveData(blob, fileName) | |
{ | |
var a = document.createElement("a"); | |
document.body.appendChild(a); | |
a.style = "display: none"; | |
var url = window.URL.createObjectURL(blob); | |
a.href = url; | |
a.download = fileName; | |
a.click(); | |
window.URL.revokeObjectURL(url); | |
} | |
var urls = document.querySelectorAll('a.icon-menu'); | |
console.log('element count a.icon-menu: ' + urls.length); | |
for (url in urls) { | |
console.log (urls[url].href); | |
var xhr = new XMLHttpRequest(); | |
xhr.open("GET", urls[url].href); | |
xhr.responseType = "blob"; | |
xhr.onload = function () { | |
var fileName = xhr.getResponseHeader('Content-Disposition').split("filename=")[1]; | |
saveData(this.response, fileName); | |
}; | |
xhr.send(); | |
} | |
console.log('done.'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment