Firefox capture script

I’ve cooked a little F1 capture script for Firefox to help me while evaluating EagleFiler. The excellent help provided made it very easy.

on capture()
	tell application "Firefox"
		set theURL to «class curl» of window 1
	end tell
	return {{|url|:theURL}}
end capture

or, if you are using one of the optimized builds, the equivalent for BonEcho:

on capture()
	tell application "BonEcho"
		set theURL to «class curl» of window 1
	end tell
	return {{|url|:theURL}}
end capture

Save either as “org.mozilla.firefox.applescript” in ~/Library/Application Support/EagleFiler/Capture Scripts/, creating the “Capture Scripts” folder if it does not exist. Do not save the BonEcho script as org.mozilla.bonecho.applescript!

If you run into trouble, paste the code in Script Editor and make sure it compiles cleanly. To debug, temporarily remove the first and last lines and hit F1 in Firefox. The output window of Script Editor will show the URL that will be passed to EagleFiler.

Good luck.

Thanks, Dylan! I didn’t realize it was possible to do this, since it doesn’t show up in Firefox’s dictionary. Here’s a modification to allow a single script to work with both application names:

on capture()
    tell application "System Events"
        set theProcess to first process whose creator type is "MOZB"
    end tell
    tell application (theProcess's displayed name)
        set theURL to «class curl» of window 1
    end tell
    return {{|url|:theURL}}
end capture

Great! I was actually wondering how you could accommodate both browsers with just one script. Thanks a lot, Michael.

As of EagleFiler 1.1, the Firefox capture script is built-in.

It gives me an error here (Can’t get «class curl» of window 1. (line 6) with Firefox 2).

It’s working for me with Firefox 2.0. Did you have a browser window in the front when you pressed the capture key?

Yes, the browser window was in the front but same error (as described) 3 times.
Now works well after restarting.