Open Links

Summary: Treats the text of the selected actions as URLs and opens them.
Requires: OmniFocus Pro 2
Install Location: ~/Library/Scripts/Applications/OmniFocus/
Last Modified: 2019-10-02

Description

I have many OmniFocus actions that consist solely of URLs for Web pages that I need to open. In OmniFocus 1, the text of selected items was available to system services, so I could open the links by selecting the actions and using Safari’s “Open URL” service. With OmniFocus 2, this is no longer possible unless you put an action in edit mode and select the text of the URL. Plus, this only works for a single action at a time. This script brings back the old functionality where I could select lots of actions, press a key, and have all the links open in my browser.

Installation Instructions · Download in Compiled Format · Download in Text Format

Script

on run {}
    
repeat with _action in my selectedActions()
        
my processAction(_action)
    
end repeat
end run

on selectedActions()
    
tell application "OmniFocus"
        
return my filterValues(my selectedValues(), {inbox task, task, available task, remaining task})
    
end tell
end selectedActions

on selectedValues()
    
tell application "OmniFocus"
        
return value of selected trees of content of first document window of front document
    
end tell
end selectedValues

on filterValues(_values, _classes)
    
tell application "OmniFocus"
        
set _result to {}
        
repeat with _value in _values
            
if _classes contains _value's class then
                
copy _value to end of _result
            
end if
        
end repeat
        
return _result
    
end tell
end filterValues

on processAction(_action)
    
tell application "OmniFocus"
        
set _url to _action's name
        
do shell script "open " & _url's quoted form
    
end tell
end processAction