Skip to content

Instantly share code, notes, and snippets.

@masnick
Last active December 18, 2015 12:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save masnick/5781837 to your computer and use it in GitHub Desktop.
Save masnick/5781837 to your computer and use it in GitHub Desktop.
AppleScript to make a list of links for all the tabs in the frontmost window in an Evernote note.
tell application "Safari"
set docText to ""
set tabcount to number of tabs in first window
repeat with y from 1 to tabcount
set tabName to do shell script "ruby -e 'require %q[cgi]; print CGI.escapeHTML(ARGV[0])' " & quoted form of (name of tab y of first window as string)
set tabURL to do shell script "ruby -e 'require %q[cgi]; print CGI.escapeHTML(ARGV[0])' " & quoted form of (URL of tab y of first window as string)
set docText to (docText & "<en-todo/> <a href=" & "\"" & tabURL & "\">" & tabName & "</a><br/>" & linefeed as string)
end repeat
end tell
tell application "Evernote"
activate
set the theDate to do shell script "date '+%Y-%m-%d'"
create note title "Links for " & theDate as string with enml docText notebook "Links"
end tell
(* Debug *)
(*
tell application "TextEdit"
activate
make new document
set theDate to current date
set text of document 1 to docText as text
end tell
*)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment