Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save royduin/973af5672bdcee6938e789fbbd46a251 to your computer and use it in GitHub Desktop.
Save royduin/973af5672bdcee6938e789fbbd46a251 to your computer and use it in GitHub Desktop.
pic-time.com ripper
var saveBlob = (function () {
var a = document.createElement("a");
document.body.appendChild(a);
a.style = "display: none";
return function (blob, fileName) {
var url = window.URL.createObjectURL(blob);
a.href = url;
a.download = fileName;
a.click();
window.URL.revokeObjectURL(url);
};
}());
const regex = /highres.*blob:(.*)&/g;
let m;
var downloaded = []
var gogogo = function () {
while ((m = regex.exec(document.body.innerHTML)) !== null) {
if (m.index === regex.lastIndex) {
regex.lastIndex++
}
m.forEach((match, index) => {
if (index == 0) {
return
}
let image = match
// Keep a list of what we already downloaded.
if (downloaded.includes(image)) {
return
}
console.log('Found: '+image)
downloaded.push(image)
// For debugging
// return
fetch('blob:'+image)
.then((response) => response.blob()
.then((b) => saveBlob(b, new URL(image).pathname.slice(1)+'.jpg')))
});
}
}
window.onscroll = function() {gogogo()};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment