Skip to content

Instantly share code, notes, and snippets.

@tomayac
Last active August 29, 2015 14:06
Show Gist options
  • Save tomayac/c2358b1cbee764b679e9 to your computer and use it in GitHub Desktop.
Save tomayac/c2358b1cbee764b679e9 to your computer and use it in GitHub Desktop.
TwitPic backup script
// Browse through your photo collection page-by-page,
// each time pasting the script in the console.
// Then save images one-by-one, or just "Save as" > "Web page complete".
// The alt attribute contains the original tweet text.
// License: CC0. Author: Thomas Steiner (tomayac).
var images = [];
Array.prototype.forEach.call(document.querySelectorAll('div[class~="user-photo"] a img'), function(img, i) {
img.src = /.*?\/thumb\/.*?/g.test(img.src) ? img.src.replace('/thumb/', '/large/') : img.src;
images[i] = '<img src="' + img.src + '" alt="' + img.alt.replace(/"/g, '&quot;')+ '"/>';
});
document.write(images.join());
@RubenVerborgh
Copy link

Perhaps img.alt.replace(/"/g, '&quot;') for safety?

@tomayac
Copy link
Author

tomayac commented Sep 17, 2014

Incorporated :-) Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment