But than you are kind of limited to just one browser. I'm rather free to pick the URL from whereever it is with "Instand Send".
But this is up to you. If you just run the script it will pick the URL of the front window in Safari (or in the browser of your choice).
I also added Growl support. Like it better than beep.
This script uses is.gd to shorten the URL.
Enough words. Here is my script and how to use it:
1. Copy the following code
- Code: Select all
-- based on http://www.leancrew.com/all-this/2007/11/long-and-shortened-url-scripts/
-- & http://www.leancrew.com/all-this/2009/02/url-shortening-scripts-fixed-i-think/
-- by @drdrang
-- modified by @ptujec (for LaunchBar)
-------------------------------------------
on handle_string(longURL)
set escapedURL to URLescape(longURL)
set cmd to "curl 'http://is.gd/api.php?longurl=" & escapedURL & "'"
set shortURL to do shell script cmd
set the clipboard to shortURL as text
my growlRegister()
growlNotify("URL shortened", longURL & "\n" & "→ " & shortURL)
end handle_string
-------------------------------------------
on run
tell application "Safari"
set longURL to URL of front document
end tell
set escapedURL to URLescape(longURL)
set cmd to "curl 'http://is.gd/api.php?longurl=" & escapedURL & "'"
set shortURL to do shell script cmd
set the clipboard to shortURL as text
my growlRegister()
growlNotify("URL shortened", longURL & "\n" & "→ " & shortURL)
end run
-------------------------------------------
on URLescape(longURL)
set cmd to "\nfrom urllib import quote\nprint quote(\"\"\"" & longURL & "\"\"\", \"/:\")\n"
return (do shell script "python -c " & (quoted form of cmd))
end URLescape
-------------------------------------------
using terms from application "GrowlHelperApp"
on growlRegister()
tell application "GrowlHelperApp"
register as application "is.gd" all notifications {"Alert"} default notifications {"Alert"} icon of application "Launchbar.app"
end tell
end growlRegister
on growlNotify(grrTitle, grrDescription)
tell application "GrowlHelperApp"
notify with name "Alert" title grrTitle description grrDescription application name "is.gd"
end tell
end growlNotify
end using terms from
2. Open Script Editor ("/Applications/AppleScript/Script Editor.app")
3. Paste the code into the empty window of Script Editor. Save it as i.g. "tinyURL" in the LaunchBar Actions Folder ("~/Library/Application Support/LaunchBar/Actions")
4. Restart LaunchBar
5. Pick a URL hit space and start typing "tiny..." / or just run the script and it will pick the URL of the front window in Safari (or in the browser of your choice)
Enjoy!

