I wrote this script because I got tired of switching over to Safari,
selecting the URL, copy, switch back, paste, etc. I saved the script,
then assigned a trigger in Quicksilver. Hit the hotkey, and it will
create a list of all open URL's in all Safari windows, with the most
recent one at the top. Just hit enter, and it will paste the link into
wherever you are. Works great for sharing links in email, webmail,
chat, etc.
Since you can create the trigger in Quicksilver, you can save the
script wherever you want. Here's the code. If you use FireFox, or
another browser, just change the script to call it instead.
I appreciate any feedback or suggestions. The only unexpected behavior
I've had with it is it doesn't handle spaces very well. Sometimes it
has a hard time switching back to the initiating application if it's
in another space. If anyone has a suggestion of how to make it handle
spaces more gracefully, please share. This is my first script.
Script code:
set URL_List to {}
tell application "System Events"
set varAppName to first application process whose frontmost is true
end tell
tell application "Safari"
tell window 1 to activate
set first_choice to URL of document 1
end tell
set end of URL_List to first_choice as text
tell application "Safari"
activate
repeat with i from 1 to number of items in windows
set this_win to item i of windows
if ((name of this_win) as string) ≠ "downloads" then
tell window i
repeat with j from 1 to (count tabs)
set current tab to tab j
set end of URL_List to URL of document 1
end repeat
end tell
end if
end repeat
end tell
tell me to activate
set URL_choice to choose from list URL_List with title "Get URL From
Browser" with prompt "Which link do you want?" OK button name "Choose"
cancel button name "Cancel" default items item 1 of URL_List
tell application "Finder" to set the clipboard to URL_choice as text
tell application "System Events"
set frontmost of varAppName to true
keystroke "v" using {command down}
end tell