Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
(*
======================================
// 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