Simpler ScrapBook backup bookmarklets

May 05, 2012 11:46

For anyone worried about the upcoming ScrapBook transition, and who is trying to back up your hundreds or thousands of photos, I've come up with a bookmarklet to make the job a bit simpler.
Edit, June 6: Now with bookmarklet for new Scrapbook
Edit, June 11: And now with a fix for leading/trailing underscore names.

Step 1

[Archived instructions for old ScrapBook]Old ScrapBook
Just copy this code:

javascript:var%20links=document.getElementsByTagName('a');for(var%20i=0,link;link=links[i];i++){var%20splits=link.href.split('/');link.href=splits.splice(0,splits.length-1).join('/');}void(0);

into a new bookmark on your bookmark bar and press it whenever you're viewing one of your gallery pages in old ScrapBook. It'll convert all the links that led to thumbnails, or image description pages, into direct links to the full-size image.

For instance, say I'm viewing this gallery page and want to quickly download all the images. After pressing the bookmarklet all the links that led to an image page will now lead directly to the full-size image.


New Scrapbook
Copy this code:

javascript:function%20sub100(s){return%20s.replace('100.','original.');}A='';var%20z=open().document;for(i=0;i'+sub100(A)+'
');}}z.close();

into a new bookmark on your bookmark bar and press it whenever you're viewing an album page in new Scrapbook. It'll open up a new tab filled with links to the fullsize version of all the images on that page of your album (plus the fullsize version of any cover images for the albums that appear on the right-hand side of the screen).

Step 2

And now that you have a page that is filled with links to the full-size images you can use lots of other webtools to quickly download all the images. I recommend using the DownThemAll!! extension for Firefox. Not only is it simplicity to download all the images off a page, but it keeps the original dates and times of the image and it'll point out when it's failed to save the full-sized image. I used this extension a few days ago to help a friend download her ScrapBook images; I downloaded almost a thousand images in under a couple hours and I knew instantly which images had already failed.

If you want a different option for saving the images there are plenty of ways to go about it. You could use a second bookmarklet to display all the images those links lead to and then you could save the webpage locally (see below). Or you could open all the images in new tabs and use the Save Images Firefox extension to save them all. And of course, there's always the old standby of right click, clicking "save link as".

Below: Okay, so I cobbled together an option for step 2 of the project: a way to display all those linked images on a single webpage. Paste the following code:

javascript:(function(){var x,z,i;function linkIsSafe(u){if(u.substr(0,7)=='mailto:')return false;if(u.substr(0,11)=='javascript:')return false;return true;}function htmlEscape(s){s=s.replace(/%26/g,'%26amp;');s=s.replace(/%3E/g,'%26gt;');s=s.replace(/%3C/g,'%26lt;');return s;}z=window.open().document;z.writeln('%3Cp%3EImages%20linked%20to%20by%20'+htmlEscape(location.href)+':%3C/p%3E%3Chr%3E');x=document.links;for(i=0;i%3Cx.length;++i)if(linkIsSafe(x[i].href))z.writeln('%3Cp%3E'+x[i].innerHTML+'%20('+htmlEscape(x[i].href)+')%3Cbr%3E%3Cimg%20src=%22'+x[i].href.replace(/%22/g,'%26quot;')+'%22%3E%3C/p%3E');z.writeln('%3Chr%3E');z.close();})();
into a new bookmarklet. This will display every full-size image that a gallery page links to and display it on a single page. If your computer is a bit older, or if you have a lousy internet connection, this could crush your browser so please try it on a smaller gallery first before you try downloading 25 or so images at a time.

Leading/trailing underscore in usernames, Scrapbook won't display

[Archived instructions]If your username starts or ends with an underscore, you may have noticed that your Scrapbook won't display right now. This is because of the underscore. Everywhere else on the site, links that look like name.livejournal.com for everyone else look like users.livejournal.com/name for you. It's for technical reason, and you can blame ICANN as much as anybody for it, but the upshot is that LJ long ago disallowed people from making new usernames that start/end with underscores. So long ago that it looks like the engineers working on new Scrapbook forgot that it was even an issue.
So until they get that fixed, if you want to see your Scrapbook you need to fix the URLs yourself. Click on the Scrapbook link in your profile and you'll end up at a page with a big blue box promoting Scrapbook and a URL like this: [http://users.livejournal.com/_NAME_/pics/catalog . Change the URL so it reads [ http://_NAME_.livejournal.com/pics/catalog ]. Then, create a new bookmark in your toolbar and copy the following code in for the destination (after changing EXAMPLEUSERNAME to your own username first):

javascript:var links=document.getElementsByTagName('a');for(var i=0,link;link=links[i];i++){link.href=link.href.replace('users.livejournal.com/EXAMPLEUSERNAME','EXAMPLEUSERNAME.livejournal.com');}void(0);
Clicking this bookmarklet changes all the links on the page so that they all go to the http://name.livejournal.com/ version of the URLS. You'll have to click the bookmarklet for every page you visit in your Scrapbook, but at least you'll be able to look around and use it.


Technical notes:
The first bookmarklet for old ScrapBook is really a very basic JavaScript. It takes the URL of any link on the page and throws out the last slash and everything after it. It works here because of the predictable structure of old ScrapBook URLs.
The second bookmarklet, for new Scrapbook, takes the URL for the 100px thumbnails displayed in the albums, changes the "100" to "original", and compiles a list onto a new tab.
The third bookmarklet, the one that displays all the linked images on a single page, is a bit more complex, but basically it checks to see if the link is safe to click (i.e. not javascript or mailto) and produces an image tag with that link as the source.
The last bookmarklet, the one that fixes beginning/end underscores, simply replaces the part of the URL that breaks Scrapbook with one that doesn't.

livejournal, howto

Previous post Next post
Up