FireFox-BonEcho save Webarchive to specific group

Thanks to Christian’s original script and Knight of Knee’s script for Safari.

This script allows you to choose a destination folder for a webarchive saved from FireFox/BonEcho.

Drop it into your /Users/USERNAME/Library/Scripts/Applications folder.

If you use FireFox, I suppose you should change “BonEcho” to “FireFox”.

tell application "BonEcho"
	try
		try
			set theWindow to window 1
			set this_title to the name of theWindow
			set this_url to «class curl» of theWindow
		on error
			error "No browser is open/in front."
		end try
		tell application "DEVONthink Pro"
			activate
			set theDestination to display group selector "Destination" buttons {"Cancel", "OK"}
			
			set theArchive to create record with {name:this_title, type:html, URL:this_url} in theDestination
			try
				with timeout of 60 seconds
					set data of theArchive to download web archive from this_url
				end timeout
			on error
				error "Download failed."
			end try
		end tell
	on error error_message number error_number
		if the error_number is not -128 then
			try
				display alert "Firefox" message error_message as warning
			on error number error_number
				if error_number is -1708 then display dialog error_message buttons {"OK"} default button 1
			end try
		end if
	end try
end tell

It’s my first FrankenScript® so be gentle.

Seems to work great. Thanks!