/* Open up vertical photo gallery and scroll all the way to the bottom */ const script33 = document.createElement('script'); script33.src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"; script33.onload = () => { $ = jQuery.noConflict(); function biggestSrc(srcset) { if (srcset == undefined) { return ""; } const srcs = srcset.split(' '); return srcs[srcs.length - 2]; } const imageList = $('div.vertical-gallery-wrapper img').map((i,e) => biggestSrc($(e).attr('srcset'))).get(); // const imgs = $('div.vertical-gallery-wrapper img') console.log('imageList', imageList.length, imageList); const delay = ms => new Promise(res => setTimeout(res, ms)); // promise delay // get all image blobs in parallel first before downloading for proper batching Promise.all(imageList.map(i => fetch(i))).then(responses => Promise.all(responses.map(res => res.blob())) ).then(async (blobs) => { for (let i = 0; i < blobs.length; i++) { if (i % 10 === 0) { console.log('1 sec delay...'); await delay(1000); } let a = document.createElement('a'); a.style = "display: none"; console.log(i); let url = window.URL.createObjectURL(blobs[i]); a.href = url; const picNum = (i+1) if (picNum < 10) { a.download = '0' + picNum + ''; } else { a.download = picNum + ''; } document.body.appendChild(a); a.click(); setTimeout(() => { window.URL.revokeObjectURL(url); }, 100); } }); }; document.getElementsByTagName('head')[0].appendChild(script33);