Open current web page in an alternate browser

And the laziness wins again.

on alfred_script(q)
    if appIsRunning("Google Chrome") and appIsInFront("Google Chrome") then
        openInSafari()
    else if appIsRunning("Safari") and appIsInFront("Safari") then
        openInChrome()
    end if
end alfred_script

on openInChrome()
    tell application "Safari"
        
        if exists URL of current tab of window 1 then
            set vURL to URL of current tab of window 1
            
            tell application "Google Chrome"
                --if windows ≠ {} then
                if (count windows) ≠ 0 then
                    make new tab at the end of window 1 with properties {URL:vURL}
                else
                    make new window
                    set URL of (active tab of window 1) to vURL
                end if
                activate
            end tell
            
            tell application "Safari"
                close current tab of window 1
                delay 0.1
                if (count documents) = 0 then
                    quit application "Safari"
                end if
            end tell
            
        end if
        
    end tell
end openInChrome

on openInSafari()
    tell application "Google Chrome"
        
        if (count windows) ≠ 0 then
            
            set vURL to URL of active tab of window 1
            
            if vURL ≠ "chrome://newtab/" then
                
                tell application "Safari"
                    open location vURL
                    activate
                end tell
                
                
                
                tell application "Google Chrome"
                    close active tab of window 1
                    delay 0.2
                    if (count windows) = 0 then
                        quit application "Google Chrome"
                    end if
                end tell
                
            end if
            
        end if
        
    end tell
end openInSafari

-- Check if application is running
on appIsRunning(appName)
    tell application "System Events"
        return (name of processes) contains appName
    end tell
end appIsRunning
 
-- Check if application is active and in front
on appIsInFront(appName)
    tell application "System Events"
        set theName to name of the first process whose frontmost is true
    end tell
    
    return appName = theName
end appIsInFront

Oh gee. It has been 3 months since the last post. I guess I have been busy. 😬