URL Trigger

One of the things I most often need to do is to grab the current URL and other page information from or and paste it somewhere.

Here is how I do that using and some (which is then bound to a trigger), getting a nice notification afterwards:

For :

tell application "Safari"
  set szURL to URL of document 1
  set szTitle to do JavaScript "document.title" in document 1
  set szReferrer to do JavaScript "document.referrer" in document 1
  set szSelection to do JavaScript "window.getSelection() + ''" in document 1
end tell
 
--copy URL and title to clipboard in Textile format
if (length of szSelection is not 0) then
  set the clipboard to "\"" & szTitle & "\":" & szURL & " | " & szSelection
else
  set the clipboard to "\"" & szTitle & "\":" & szURL
end if
 
tell application "GrowlHelperApp"
  notify with name "Quicksilver Notification" title "URL copied" application name "Quicksilver" description szURL
  --with sticky
end tell

If you need to add further metadata, I’ve found that you can also use to get to prompt you for it:

set szTags to do JavaScript prompt(Enter tags:) in document 1

For :

1.6 has better support than previous versions, but it can’t yet do the do JavaScript thing. So I use a simpler script:

tell application "Camino"
  set theTab to the current tab of front browser window
  set szURL to the URL of theTab
  set szTitle to the title of theTab
end tell

set the clipboard to "\"" & szTitle & "\":" & szURL

tell application "GrowlHelperApp"
	notify with name "Quicksilver Notification" title "URL copied" application name "Quicksilver" description szURL
	--with sticky
end tell

Mind you, trigger scope is known to be broken in for some reason, so you might want to avoid using the same hotkey for both scripts.