Created
April 26, 2012 02:53
-
-
Save yoko/2495353 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
on growl(str) | |
try | |
do shell script "/usr/local/bin/growlnotify -a BathyScaphe -t \"Send to Evernote\" -m " & quoted form of str | |
end try | |
end growl | |
tell application "BathyScaphe" | |
set selected_text to selected text of document 1 | |
set thread_title to thread title of document 1 | |
set thread_url to thread URL of document 1 | |
end tell | |
set selected_text to do shell script "/usr/bin/ruby -e \"puts " & quoted form of selected_text & ".gsub(/\\s\\d+ /) { \\\"\\n#{$&}\\\" }\"" | |
tell application "Evernote" | |
if (not (notebook named "Tmp" exists)) then | |
make notebook with properties {name:"Tmp"} | |
end if | |
if (not (tag named "2ch" exists)) then | |
make tag with properties {name:"2ch"} | |
end if | |
set existing_notes to find notes "intitle:" & thread_title | |
if length of existing_notes is 0 then | |
set new_note to create note title thread_title tags {"2ch"} with text selected_text notebook "Tmp" | |
tell new_note to set source URL to thread_url | |
else | |
set a_note to first item of existing_notes | |
tell a_note to append text " | |
" & selected_text | |
end if | |
end tell | |
growl("Added") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment