Skip to content

Instantly share code, notes, and snippets.

@lumin3000
Created October 22, 2011 14:28
Show Gist options
  • Save lumin3000/1306059 to your computer and use it in GitHub Desktop.
Save lumin3000/1306059 to your computer and use it in GitHub Desktop.
transform the 500px images to 1280 images in boutofcontext.com (for tumblr backup)
var newScript = document.createElement('script');
newScript.type = 'text/javascript';
newScript.src = ' https://ajax.googleapis.com/ajax/libs/mootools/1.4.1/mootools-yui-compressed.js';
document.getElementsByTagName("body")[0].appendChild(newScript);
//###make a bookmarklet using the code before this line###
var post = $$('div#post');
var posturl,
postid,
imageid,
image1280url,
postfragment;
for (var i = 0; i < post.length; i++)
{
if ((post[i].innerHTML + '').indexOf('[ Posted <a href=') >= 0)
{
try {
posturl = (post[i].innerHTML + '').split('[ Posted <a href="')[1].split('">')[0];
postid = posturl.split('/post/')[1];
postfragment = (post[i].innerHTML + '').split('<img src="');
imageid = postfragment[1].split('/tumblr_')[1].split('o1_')[0];
postfragment = [postfragment[0] + '<img src="', '">' + postfragment[1].split('">')[1]];
image1280url = "http://www.tumblr.com/photo/1280/" + postid + "/1/tumblr_" + imageid;
post[i].innerHTML = postfragment.join(image1280url);
} catch(e) {
console.log(e + i + ':' + post[i].innerHTML)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment