Add URL from Firefox

Often I avoid Firefox on my mac, because I can not easily add content to DTP. Here is my first script to use Firefox with DTP. This one captures the URL of the visible window (tab) to DTP.


-- Add URL from Firefox
-- Created by Gabriel Weatherhead on April 23, 2006.

tell application "System Events"
	if ((application processes whose (name is equal to "firefox-bin")) count) is greater than 0 then
		if (count of windows of application "Firefox") is greater than 0 then
			
			tell application "Firefox"
				set theUrl to «class curl» of window 1
				set theTitle to «class pTit» of window 1
				tell application "DEVONthink Pro"
					set theRecord to create record with {name:theTitle, type:link, URL:theUrl}
				end tell
				
			end tell
		else
			display alert "Error" message "Firefox is not running" as warning
		end if
	else
		display alert "Error" message "There is no Firefox window open" as warning
	end if
end tell