Webclipper functionality for Apple Notes

Hi.

I've been working with Evernote for quite some time and switched recently to Apple Notes.
The only thing I miss is the Web Clipper functionality in Apple Notes.

I've tried this Apple script and it's working with copy pasting plain text, but I need to copy and paste the rich / html text (so including images).

set noteHTMLText to "<pre style="font-family:Helvetica,sans-serif;">" & ¬

(the clipboard as Unicode text) & ""

tell application "Notes"

activate

set thisAccountName to my getNameOfTargetAccount("Choose an account:")

display dialog "Enter the title for the new note:" default answer ¬

"New Note" with icon 1 with title "New Note with Clipboard"

set the noteTitle to the text returned of the result

tell account thisAccountName

make new note at folder "Notes" with properties {name:noteTitle, body:noteHTMLText}

end tell

end tell

on getNameOfTargetAccount(thisPrompt)

tell application "Notes"

if the (count of accounts) is greater than 1 then

set theseAccountNames to the name of every account

set thisAccountName to ¬

(choose from list theseAccountNames with prompt thisPrompt)

if thisAccountName is false then error number -128

set thisAccountName to thisAccountName as string

else

set thisAccountName to the name of account 1

end if

return thisAccountName

end tell

end getNameOfTargetAccount

Your original script above seems to be one by Shane Stanley, from here on Mac OS X Automation.

What you are requesting is not as easy as it seems. The problem is that in AppleScript the body property of a note seems to accept only HTML text; RTF markup doesn’t get interpreted.

It’s not a problem to get the HTML clipboard flavor, but depending on the selection you have copied, the result will look different from what it looks on the source web page. (The HTML on the clipboard is the HTML “snippet” of the selection, and will not include other elements that affect the rendering on the web page. Also in most cases images will miss.)

I also experimented with getting the RTF clipboard and converting it to HTML, but the results are similar.

Nevertheless I post the script, because it can be useful for example when you select single paragraphs or a code block with syntax highlighting.

Script 1 (pure HTML clipboard)

use AppleScript version "2.4" -- Yosemite (10.10) or later
use framework "Foundation"
use scripting additions

set pb to current application's NSPasteboard's generalPasteboard()
set theData to pb's dataForType:(current application's NSPasteboardTypeHTML)

set noteHTMLText to current application's NSString's alloc()'s initWithData:theData encoding:(current application's NSUTF8StringEncoding)
set noteHTMLText to noteHTMLText as text


tell application "Notes"
  activate
  set thisAccountName to my getNameOfTargetAccount("Choose an account:")
  display dialog "Enter the title for the new note:" default answer ¬
    "New Note" with icon 1 with title "New Note with Clipboard"
  set the noteTitle to the text returned of the result
  tell account thisAccountName
    make new note at folder "Notes" with properties {name:noteTitle, body:noteHTMLText}
  end tell
end tell

on getNameOfTargetAccount(thisPrompt)
  tell application "Notes"
    if the (count of accounts) is greater than 1 then
      set theseAccountNames to the name of every account
      set thisAccountName to ¬
        (choose from list theseAccountNames with prompt thisPrompt)
      if thisAccountName is false then error number -128
      set thisAccountName to thisAccountName as string
    else
      set thisAccountName to the name of account 1
    end if
    return thisAccountName
  end tell
end getNameOfTargetAccount

The modifications are all at the beginning of the script, the rest is like the original.


In most cases the second script will be more useful, since it gives you the same results as when pasting “natively” (⌘V).

It is basically a UI script: When you run it, the script creates a new note (unchanged from the original script). Once you click OK, it simply simulates the necessary keystrokes to paste the clipboard into the note. That’s all.

Script 2 (simulating ⌘V)

use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions

tell application "Notes"
  activate
  set thisAccountName to my getNameOfTargetAccount("Choose an account:")
  display dialog "Enter the title for the new note:" default answer ¬
    "New Note" with icon 1 with title "New Note with Clipboard"
  set the noteTitle to the text returned of the result
  tell account thisAccountName
    make new note at folder "Notes" with properties {name:noteTitle}
    show note 1
  end tell
end tell

tell application "System Events"
  key code 124 using command down
  key code 125
  key code 36
  key code 9 using command down
  key code 36
end tell

on getNameOfTargetAccount(thisPrompt)
  tell application "Notes"
    if the (count of accounts) is greater than 1 then
      set theseAccountNames to the name of every account
      set thisAccountName to ¬
        (choose from list theseAccountNames with prompt thisPrompt)
      if thisAccountName is false then error number -128
      set thisAccountName to thisAccountName as string
    else
      set thisAccountName to the name of account 1
    end if
    return thisAccountName
  end tell
end getNameOfTargetAccount

Experiment with both scripts. As said, in my tests the second script worked better in most cases, especially with images. But in some cases text formatting was better preserved with the pure HTML script (script 1).

Sorry that I cannot come up with something better at the moment. Maybe another member has a better idea…

2 Likes

The Evernote Web Clipper is superb. I've never found another web clipper even close to it. As you are probably aware, it does much more than a simple copy of the web page. So you are likely to be displeased with the result of clipping to Apple Notes.

There is one possibility that may work for you, although I have NOT tested it.
Continue to use the Evernote Web Clipper and then export the resulting EN Note and import into Apple Notes. You may be able to do this with AppleScript.

If you can't get the AppleScript to work, you could also trying a manual export from EN to HTML files, and then import them into Apple Notes.

Good luck!

1 Like

Thanks @Tom, The first script is showing fine results for now :slight_smile:
@JMichaelTX The evernote webclipping is indeed state of the art, but for now I'm happy with the results.

1 Like

I know this thread goes back to March. Has anyone found an AppleScript, Automator or Keyboard Maestro action to automate taking a note in Evernote and exporting the .enex file?

Of course, I’d love to have a native Notes web clipper, I just don’t get why Apple hasn’t added that functionality given how many of us are fed up with Evernote. It’s a shame Evernote continues to bloat and charge more. When it first came out it was definitely the gold standard.

1 Like