-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap.js
30 lines (28 loc) · 971 Bytes
/
bootstrap.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
const imgContainer = document.querySelector(".galleryimage-large");
console.log(imgContainer);
const btn = document.createElement("button");
btn.innerText="Download all";
btn.className="button";
btn.style="display:flex;align-self:start;justify-self:start;position:relative;z-index:100"
btn.onclick = () => {
const images = document.querySelectorAll(".galleryimage-element img");
console.log(images);
for(let i=0; i<images.length;i++){
const url = images[i].src;
fetch(url)
.then(resp => resp.blob())
.then(blob => {
const url = window.URL.createObjectURL(blob);
const a = document.createElement('a');
a.style.display = 'none';
a.href = url;
// the filename you want
a.download = document.title + "_" + i + ".jpg";
document.body.appendChild(a);
a.click();
window.URL.revokeObjectURL(url);
})
.catch(() => alert('oh no!'));
}
};
imgContainer.appendChild(btn);