|
(() => { |
|
'use strict'; |
|
|
|
const dqs = document.querySelector.bind(document); |
|
const dqsa = document.querySelectorAll.bind(document); |
|
if (dqs('#jesus') || dqs('span.style9')) { |
|
(dqs('#jesus') || dqs('span.style9')).remove(); |
|
} |
|
|
|
const anchors = dqsa('a'); |
|
const downloadlink = document.createElement('a'); |
|
const linksToDownload = []; |
|
|
|
const counter = document.createElement('div'); |
|
counter.style.cssText = ` |
|
display: flex; |
|
position: fixed; |
|
justify-content: center; |
|
align-items: center; |
|
top: 0; |
|
right: 0; |
|
padding: .4em 1.6em; |
|
font-size: 16pt; |
|
width: auto; |
|
min-width: 5vw; |
|
height: 5vh; |
|
border-radius: 0 0 0 2em; |
|
background: #FFF; |
|
box-shadow: -4px 5px 13px 0px rgba(0,0,0,0.5); |
|
`; |
|
counter.id = 'jesus'; |
|
dqs('#god').appendChild(counter); |
|
|
|
// Find all images that link to the full-res versions. Every other version is a detailed (i.e. zoomed-in) version of the same image. |
|
for (let i = 0; i < anchors.length; i++) { |
|
if (anchors[i].href && anchors[i].href.includes('bilderbig') && !linksToDownload.includes(anchors[i].href)) { |
|
linksToDownload.push(anchors[i].href); |
|
}; |
|
} |
|
|
|
dqs('#jesus').innerText = `Downloading 0/${linksToDownload.length}`; |
|
|
|
// Download all the images we found earlier - one every 2000 milliseconds to prevent congestion |
|
let linkIndex = 0; |
|
let downloadInterval = setInterval(() => { |
|
if (linkIndex === linksToDownload.length) { |
|
console.log("Done downloading"); |
|
clearInterval(downloadInterval); |
|
dqs('#jesus').innerText = `Done downloading.`; |
|
setTimeout(() => { |
|
dqs('#jesus').remove(); |
|
}, 5000); |
|
} |
|
|
|
dqs('#jesus').innerText = `Downloading ${linkIndex + 1}/${linksToDownload.length}\nTime remaining: ${SecondsToFullTime((linksToDownload.length - linkIndex + 1) * 2)}`; |
|
|
|
downloadlink.download = linksToDownload[linkIndex].split('/')[1].split('.')[0]; |
|
downloadlink.href = linksToDownload[linkIndex]; |
|
downloadlink.click(); |
|
|
|
linkIndex++; |
|
}, 2000); |
|
|
|
const SecondsToFullTime = seconds => { |
|
const remainingHours = pad(Math.round(seconds / 3600 % 60)); |
|
const remainingMinutes = pad(Math.round(seconds / 60 % 60)); |
|
const remaingSeconds = pad(Math.round(seconds % 60)); |
|
return remainingHours + ':' + remainingMinutes + ':' + remaingSeconds; |
|
} |
|
|
|
const pad = int => { |
|
return int > 9 ? int : '0' + int; |
|
} |
|
})(); |