Skip to content

Instantly share code, notes, and snippets.

@lstroud
Created July 17, 2012 23:38
Show Gist options
  • Save lstroud/3132937 to your computer and use it in GitHub Desktop.
Save lstroud/3132937 to your computer and use it in GitHub Desktop.
Alfred App Applescript to create an Evernote note containing an html list of the titles/links from all open tabs in the frontmost Safari window. It also creates a todo in Things with the link to the Evernote note.
on alfred_script(q)
if q is missing value then
set listname to text returned of (display dialog "Please Enter a Name" default answer "")
else
set listname to q
end if
tell application "Safari"
set theurls to get URL of every tab of front window
set thetitles to get name of every tab of front window
end tell
tell application "Evernote"
set note1 to create note title listname with html "<h2>" & listname & " from Safari</h2><ul>"
repeat with i from 1 to count of theurls
set aurl to item i of theurls
set atitle to item i of thetitles
tell note1 to append html "<li><a href='" & aurl & "'>" & atitle & "</a></li>"
end repeat
tell note1 to append html "</ul>"
synchronize
set recheck_count to 0
repeat until recheck_count ≥ 10
set noteurl to the note link of note1
if noteurl is missing value then
set recheck_count to recheck_count + 1
delay 2
else
set recheck_count to 10
end if
end repeat
if noteurl is missing value then
tell application id "com.Growl.GrowlHelperApp"
notify with name ¬
"Other Error" title ¬
"Unable to Get Evernote Url" description ¬
"Created the Evernote not with the Safari tabs, but was unable to get a link to the note. So, no todo was created in Things." application name "AlfredAppleScript"
end tell
else
tell application "Things"
set newToDo to make new to do ¬
with properties {name:"Check Out " & listname} ¬
at the beginning of list "Inbox"
set notes of newToDo to "[url=" & noteurl & "]Link to Evernote List[/url]"
end tell
tell application id "com.Growl.GrowlHelperApp"
notify with name ¬
"Success" title ¬
"Saved Successfully" description ¬
"Saved the Safari tabs to Instapaper and Created a todo in Things referencing the note." application name "AlfredAppleScript"
end tell
end if
end tell
end alfred_script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment