Safari Web Clipping to Notes

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

Hello,

I found a way to make it happened!


tell application "System Events"
	tell application process "Safari"
		
		tell application "Safari" to set {theSource, theTitle} to {source, name} of current tab of window 1
		
		set NoteNameString to theTitle
		set NoteContentString to the theSource
		
		tell application "Notes"
			set theNoteID to make new note in folder "Notes" with properties {name:NoteNameString, body:NoteContentString}
		end tell
		
	end tell
end tell

[/AppleScript]

I still need to clean-up the text to make it look like the clean Reader version. Stepping up my looking at a Javascript script at:
http://blog.manbolo.com/2013/03/18/safari-reader.js

I am going to try to have it run on the source extracted from the page before creating the Note.

To copy the source of the current tab into a new note these lines are sufficient.

You have to specify also the account name because Notes is the default folder of any account

tell application "Safari" to set {source:theSource, name:tabName} to current tab of window 1
tell application "Notes"
	set theNoteID to make new note in folder "Notes" of account "iCloud" with properties {name:tabName, body:theSource}
end tell

But neither the text nor the source are the exact equivalent of the reader view