Created
December 31, 2013 00:49
-
-
Save matthewmccullough/8190662 to your computer and use it in GitHub Desktop.
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
(* | |
====================================== | |
// CONFIGURATION (USER EDITABLE) | |
====================================== | |
*) | |
--CHANGE THIS PROPERTY TO THE HTML CODE YOU'D | |
--LIKE TO ADD TO THE BEGINNING OF YOUR NOTE. | |
--(DEFAULT IS 5 LINE BREAKS AND A HORIZONTAL RULE) | |
property add_to_top : "<hr/>" | |
(* | |
====================================== | |
// OTHER PROPERTIES (DO NOT CHANGE) | |
====================================== | |
*) | |
property noteHTML : "" | |
(* | |
====================================== | |
// MAIN PROGRAM | |
====================================== | |
*) | |
tell application id "com.evernote.Evernote" | |
set selected_Items to (find notes "tag:deliciousbookmarks") | |
repeat with theNote in selected_Items | |
set noteHTML to (HTML content of item 1 of theNote) | |
set addString to "<body>" & add_to_top | |
set editHTML to my replaceString(noteHTML, "<body>", addString) | |
set (HTML content of item 1 of theNote) to editHTML | |
end repeat | |
end tell | |
(* | |
====================================== | |
// HANDLER SUBROUTINES | |
====================================== | |
*) | |
--REPLACE SUBROUTINE | |
on replaceString(theString, theOriginalString, theNewString) | |
set {od, AppleScript's text item delimiters} to {AppleScript's text item delimiters, theOriginalString} | |
set theStringParts to text items of theString | |
if (count of theStringParts) is greater than 1 then | |
set theString to text item 1 of theStringParts as string | |
repeat with eachPart in items 2 thru -1 of theStringParts | |
set theString to theString & theNewString & eachPart as string | |
end repeat | |
end if | |
set AppleScript's text item delimiters to od | |
return theString | |
end replaceString |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment