C-Command Software Forum

Site-specific capture script

I want EF to handle different domains differently.

If Safari shows an article from a certain newspaper, it is to be captured as rtf instead of the usual webarchive. When I’m on my favourite forum I want the print view to be captured, even when Safari shows the normal view. Twitter pages should go into a different library from all the rest.

Only the second point can be achieved by modifying the built-in capture script, which is fortunately pretty short. Maybe I can return an empty list and use the import command to force a library. But I see no way to set the page format from AppleScript.

For now, I think the closest you can do is use bookmarklets to choose the format. I’ll add a feature request to let capture scripts specify the desired Web page format.

Also matching and manipulating the URL is easier in JS than AS. Thanks!

Here’s an example:

url = window.location;
format = 'webarchive';
switch (window.location.host) {
	case 'www.newspaper.example':
		url = window.location + '?page=all&print=true';
		format = 'rtfd';
		break;
	case 'www.vBulletin.example':
		if (window.location.pathname.search(/^(\/forum.+?)(-\d+)?\.html/) != -1) {
			url = 'http://www.vBulletin.example'+RegExp.$1+'-print.html?pp=40';
		}
		break;
}
window.location='x-eaglefiler://import?url='+encodeURIComponent(url)+'&format='+format;

I use JavaScript Bookmarklet Builder and put it in Safari’s toolbar folder to be accessible via cmd+1.

That’s great; thanks for sharing!