This is my first post!
Dear Community,
I am trying to write a simple scrip to bee able to clip the equivalent of the reader view of a safari article into a new note. After trying multiple ways through the reader view, I have reverted to a more - brutal way.
It seems that I can’t directly copy the ‘source’ of Document 1 (the front window) into the ‘body’ of a new note because the types do not match.
Any idea how to unlock this problem?
Thanks
tell application "System Events"
tell application process "Safari"
tell application "Safari" to set theTab to current tab of window 1
set frontmost to true
-- tell menu bar 1
-- click menu item "Show Reader" of menu "View" of menu bar item "View"
-- click menu item "Save As…" of menu "File" of menu bar item "File"
-- end tell
-- tell application "Safari" to set the clipboard to (text of current tab of front window) as string
set NoteNameString to name of theTab
-- repeat until sheet 1 exists
-- end repeat
-- tell sheet 1
-- set NoteNameString to "Test Note 1"
-- set NoteContentString to text of tab of front window
if document 1 exists then
set NoteContentString to the source of document 1
end if
-- tell menu bar 1
-- click menu item "Hide Reader" of menu "View" of menu bar item "View"
-- click menu item "Save As…" of menu "File" of menu bar item "File"
-- end tell
tell application "Notes"
set theNoteID to make new note in folder "Notes" with properties {name:NoteNameString, body:NoteContentString}
end tell
end tell
end tell