Skip to content

Instantly share code, notes, and snippets.

@Prof9
Last active June 21, 2022 01:17
Show Gist options
  • Save Prof9/65d558d9b5efe15386c37b6f9086d4e1 to your computer and use it in GitHub Desktop.
Save Prof9/65d558d9b5efe15386c37b6f9086d4e1 to your computer and use it in GitHub Desktop.
Quick-n-dirty Photobucket scraper
// Quick-n-dirty Photobucket scraper
// Dumps one page of photos on Photobucket at a time.
// You'll have to do the folder management yourself.
// Hey, it beats saving everything one by one!
//
// Before you use it:
// Change the 3 on line 39 to the number of digits in the server number of your Photobucket album.
// (You know... the XXX numbers in the url http://sXXX.photobucket.com)
//
// How to use:
// 1. Copy the whole damn thing from line 14
// 2. Open an album on Photobucket
// 3. Open your browser's JavaScript console
// 4. Ctrl+V, Enter
// 5. All images on the current page of the album are downloaded
// 6. ...You should probably change your default download location
$(".thumbnailImage a img").toArray().forEach(function(a) {
// lifted from https://ausdemmaschinenraum.wordpress.com/2012/12/06/how-to-save-a-file-from-a-url-with-javascript/
function saveFile(url) {
// Get file name from url.
var filename = url.substring(url.lastIndexOf("/") + 1).split("?")[0];
var xhr = new XMLHttpRequest();
xhr.responseType = 'blob';
xhr.onload = function() {
var a = document.createElement('a');
a.href = window.URL.createObjectURL(xhr.response); // xhr.response is a blob
a.download = filename; // Set the file name.
a.style.display = 'none';
document.body.appendChild(a);
a.click();
delete a;
};
xhr.open('GET', url);
xhr.send();
}
a = a.src;
a = a.replace(/^https?:\/\/\w+(\d{3})\.\w+\.com\//, "http://i$1.photobucket.com/");
a = a.replace(/~.*$/, "");
saveFile(a);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment