[AppleScript] Delete "IMG_####" captions from Facebook photos

Mikuro

Crotchety UI Nitpicker
I like iPhoto's Facebook photo exporter, but I don't like the way it captions every photo with the file name. The file names are always worthless for me, since I upload them straight from my camera with the default "IMG_####" naming scheme.

Now, you might think it's a minor issue, but it bugged me. So I made a quick script to erase the captions. It's an AppleScript that tells Safari to execute a JavaScript snippet that will clear all the fields on Facebook's "Edit Photos" page that start with "IMG_". It won't touch captions that don't start with "IMG_" so should be able to use it on existing albums without deleting your REAL captions.

So, here it is. In Safari, go to the album, click "Edit Photos", and then run the script in Script Editor.

Code:
tell application "Safari"
	do JavaScript "
	function x() {
		a=document.getElementsByTagName('textarea')
		var i=0
		for (i=0; i<a.length; i++) {
			if (a[i].value.indexOf('IMG_')==0) {
				a[i].value=''
			}
		}
	}
	x();
	" in tab 1 of window 1
end tell
Since all the real functionality of this is in JavaScript, it can also be packaged as a bookmarklet for Safari. Maybe you'll find that more convenient, so here it is in bookmarklet form: <edited; see below>. Bookmark that link, then open Facebook's "Edit Photos" page and select the bookmark.

Edit: This forum won't let me make a bookmarklet link that works. :( So you'll have to manually make a bookmark with this "address":
Code:
javascript:function x() {     a=document.getElementsByTagName('textarea');     var i=0;     for (i=0; i<a.length; i++) {     if (a[i].value.indexOf('IMG_')==0) {     a[i].value='';     }     }     }     x();
I hope you find it useful!
 
Last edited:
Top