Last active
February 27, 2018 14:01
-
-
Save cmittendorf/d0fad6ff5dc10eaa627ee825e177a3f2 to your computer and use it in GitHub Desktop.
An AppleScript for adding the URL from the current tab to an OmniOutliner document.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use AppleScript version "2.4" -- Yosemite (10.10) or later | |
use scripting additions | |
set document_name to "Safari Links" | |
set row_topic to "Links" | |
set browser_url to missing value | |
tell application "Safari" | |
set browser_url to URL of first document | |
end tell | |
if browser_url is not missing value then | |
tell application "OmniOutliner" | |
-- check for an open document. if there is none, create a new document | |
if number of documents is 0 then | |
make new document with properties {title:document_name} | |
delay 1 | |
tell first document | |
make new row with properties {topic:row_topic} | |
delay 1 | |
end tell | |
end if | |
-- add url to document | |
tell first document | |
set items_list to children where name is row_topic | |
if (count of items in items_list) is 1 then | |
set links_item to item 1 of items_list | |
tell links_item | |
if (count of (children where name is browser_url)) is 0 then | |
make new row with properties {topic:browser_url} | |
else | |
activate | |
display alert "Document contains already an item named \"" & browser_url & "\"!" buttons {"OK"} default button 1 | |
end if | |
end tell | |
else | |
activate | |
display alert "Document does not contain a row named Links!" buttons {"OK"} default button 1 | |
end if | |
end tell | |
end tell | |
end if |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment