Creatively Technical

Thoughts on photography, electrical engineering, and management

0 notes

Removing Flash from your Mac

This post from November ‘10 on Daring Fireball lead me to uninstall Flash from my 4 year old Macbook Pro to preserve battery life while browsing the web.

So, whenever I hit a page with Flash content I wish to view, I open that page in Chrome. As soon as I’m done watching it, I quit Chrome, which ensures Flash Player isn’t left running in the background.

Using Chrome’s built-in Flash was a great workaround, but there were 2 behaviors of Safari’s “Open Page With” mechanism I wanted to tweak using AppleScript. First, it opened a new Tab all the time, even if it has to launch Chrome. Of course, when you launch Chrome you’re presented with a blank tab or your homepage, depending on settings. Since I wasn’t running Chrome before, I’m launching it for the sole purpose of viewing this URL and I don’t care about my Chrome homepage. Secondly, since Flash sites usually have a noticeable load time on my laptop, I don’t want Chrome to pop to the front. I let it pop under Safari, letting me continue to browse while Chrome and the Flash website loads.

Finally, I launch this script using Red Sweater’s excellent FastScripts.

tell application "Safari"
    set safariURL to URL of document 1
end tell

if appIsRunning("Google Chrome") then
    tell application "Google Chrome"
        set myTab to make new tab at end of tabs of window 1
        set URL of myTab to safariURL
    end tell
tell application "Google Chrome"
    set URL of active tab of window 1 to safariURL
    end tell
end if

on appIsRunning(appName)
    tell application "System Events" to (name of processes) contains appName
end appIsRunning