NotePlan 3 Daily Note and New Note Snippets

I finally got around to doing something with my kludgy NotePlan clipper extensions that have limited formatting functionality. Instead of rewriting the python-based Daily_NotePlan and Clip2NotePlan extensions, I went for the simplicity of snippets.

Edit the below as needed, it should be pretty straightforward using the NotePlan x-callback docs.

Updated 2022-02-09: cleaner code, better headers for non-html sources

Clip to Daily Note

# PopClip - NotePlan Daily Note
name: DailyClipper
icon: symbol:calendar.badge.plus
capture html: true 
javascript: | 
  let clipping = popclip.input.markdown
  if (popclip.context.browserUrl.length > 0) { 
    let title = encodeURIComponent(popclip.context.browserTitle)
    clipping = `# ${title}\n` + clipping
    clipping += `\n[${popclip.context.browserTitle}](${popclip.context.browserUrl})\n#clipped`
  } else {
    let fname = popclip.input.markdown.split(' ').slice(0, 7).join(' ') + `…`
    clipping = `# ` + fname + `\n` + clipping + `\n#clipped`
  }
    clipping = encodeURIComponent(clipping)
    popclip.openUrl(`noteplan://x-callback-url/addText?noteDate=today&text=${clipping}&mode=append&openNote=yes`) 

Clip to New Note

# PopClip - NotePlan New Note
name: NP3Clipper
icon: symbol:asterisk
capture html: true 
javascript: | 
  let clipping = popclip.input.markdown
  if (popclip.context.browserUrl.length > 0) {
    let title = encodeURIComponent(popclip.context.browserTitle)
    clipping += `\n[${popclip.context.browserTitle}](${popclip.context.browserUrl})\n#clipped`
    clipping = encodeURIComponent(clipping)
    popclip.openUrl(`noteplan://x-callback-url/addNote?noteTitle=${title}&text=${clipping}&openNote=yes`)
  } else {
    let fname = popclip.input.markdown.split(' ').slice(0, 7).join(' ')
    clipping = `# ` + fname + `\n` + clipping + `\n#clipped`
    clipping = encodeURIComponent(clipping)
    popclip.openUrl(`noteplan://x-callback-url/addNote?text=${clipping}&openNote=yes`)
  }
7 Likes

Looks great @brokosz, welcome and thanks for sharing!

Cheers, @nick - thanks for all the functionality. If I get some more time this week, I’ll try to consolidate this down to a single with a modifier.

Love this. Thanks very much, @brokosz.

1 Like

Very useful indeed. Thanks!

Brokosz,

Many thanks - I wish I could buy you a beer!

Mark

Hello thanks for this but I am having a trouble getting it to work as I believe it should in either Firefox or Safari. No title or URL is included in the clip — URLs in the text are not rendered and there is no #clipping tag. It just ends with a capital A on a new line.

so for example i just get

I finally got around to doing something with my kludgy NotePlan clipper extensions that have limited formatting functionality. Instead of rewriting the python-based Daily_NotePlan 4 and Clip2NotePlan 2 extensions, I went for the simplicity of snippets.

Edit the below as needed, it should be pretty straightforward using the NotePlan x-callback docs 2.
A

any ideas? thanks!

1 Like

Hi @everythingness and welcome to the forum.

It won’t work fully in Firefox, because Firefox doesn’t provide an AppleScript interface for PopClip to read the current page URL and title.

In Safari (as well as in Chrome, Edge, Brave, Opera and other Chromium based browsers), it ought to get the source URL and title. Is it possible you have denied permission for PopClip to automate Safari (in Settings, Security & Priacy, Automation – see screenshot)?

I’m not sure about the capital A thing.

thanks @nick that fixed it (in safari at least) :slight_smile:

1 Like

Thanks for sharing this. Much appreciated.