open current url in chrome

Sharing and discussing custom actions for LaunchBar
Posts: 1
Joined: Wed Mar 16, 2011 12:05 pm

open current url in chrome

Postby mbotta » Wed Mar 16, 2011 12:31 pm

if you've been following the discussions around flash-less browsing with contributions from john gruber, you may have come across this article on TUAW, "Use AppleScript to open current Safari URL in Google Chrome" -

i find that i tend to use netnewswire as often as i do safari, both of which use the system-wide flash instance. this applescript checks which of those two is the frontmost application and opens the current url in chrome. i'm an applescript newbie, so any improvements are more than welcome :)

Code: Select all

tell application "LaunchBar" to hide

tell application "System Events" to set currentApplication to name of 1st application process whose frontmost is true

set currentURL to getCurrentURL(currentApplication)

if currentURL is not "" then
   tell application "Google Chrome"
      if (exists window 1) and (URL of active tab of window 1 is "chrome://newtab/") then
         tell window 1 to set URL of active tab to currentURL
         open location currentURL
      end if
   end tell
end if

on getCurrentURL(currentApp)
   if currentApp = "Safari" then
      tell application "Safari" to set currentURL to URL of current tab of window 1
   else if currentApp = "NetNewsWire" then
      tell application "NetNewsWire"
         set allURLs to URLs of tabs
         set currentURL to item (index of selected tab + 1) of allURLs
      end tell
      currentURL = ""
   end if
   return currentURL
end getCurrentURL

if you use other browsers that use the system-wide flash instance, add your applescript code to getCurrentURL(currentApp).



Objective Development
Objective Development
Posts: 562
Joined: Sat Jul 31, 2010 9:47 am
Location: Vienna

Re: open current url in chrome

Postby manfred » Thu Mar 17, 2011 12:48 pm

Dear mbotta,

I followed John Grubers article too. Great idea to use an AppleScript and LaunchBar for triggering Chrome!

Thanks for sharing.

Return to “LaunchBar Actions”

Who is online

Users browsing this forum: Google [Bot] and 1 guest