Created
August 1, 2024 18:06
-
-
Save royduin/973af5672bdcee6938e789fbbd46a251 to your computer and use it in GitHub Desktop.
pic-time.com ripper
This file contains hidden or 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
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