Clip selection to Obsidian

The pasteboard.text returns the clipboard content prior to running the snippet.

I’m guessing that the code is reading the clipboard too soon, before Superhuman has had a chance to actually place its link on there it.

The code to add a delay might be a little bit jarring to look at if you aren’t used to JavaScript callbacks:

# PopClip superhuman with link to obsidian
name: SHEntry
icon: circle S
capture html: true # this is needed when we want markdown text
javascript: |
  let clipping = popclip.input.markdown
  popclip.pressKey('/', util.constant.MODIFIER_CONTROL)
  setTimeout(function() {
    clipping += `\n[Email link](${pasteboard.text})`
    clipping = encodeURIComponent(clipping)
  }, 500)

The number 500 sets a delay of 500 milliseconds (half a second) – you might want to try other values, I haven’t actually tested it because I don’t have Superhuman installed.

That works just right! Thanks :slight_smile:
As I no longer need the append function, I just changed to the Obsidian URL to generate a new file:

1 Like

That works just right! Thanks :slight_smile:


If you want to dynamically generate a date string JavaScript can do that… I can’t remember off the top of my head but I’m about to update the Timestamp extension so that shoulld refresh my memory.

1 Like

Speaking of experimenting, I’m trying to modify the scripts in this thread to create a new full note in Obsidian. Everything works except for line 18 (let fname = popclip.input.markdown.slice(0, 20) ) where I’m trying to name the file with the beginning of the selected text for non-html text. I feel like I’m missing something obvious.

Edit: cleaner code with better header creation

# PopClip - Obsidian new note
name: OBClipper
- identifier: vault
  label: Vault Name
  type: string
capture html: true
javascript: | 
  const vaultName = encodeURIComponent(popclip.options.vault)
  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)
  } else {
    let fname = popclip.input.markdown.split(' ').slice(0, 7).join(' ')
    clipping = `# ` + fname + `\n` + clipping + `\n#clipped`
    fname = encodeURIComponent(fname)
    clipping = encodeURIComponent(clipping)
1 Like

The snippet wouldn’t load for me because it’s 1032 characters - I edited your post to remove a comment to get it under the 1000 character limit. After that it seems to work OK and my selection was shortened to 20 characters.

:man_facepalming: thanks @nick. I don’t think I would have figured that out on my own.

I think I shall add a visible message when the snippet is too long

5 posts were split to a new topic: Snippet length discussion

Hi, Thanks for the scripts. However, it seems that it fails to extract url when using it in Arc browser. It works well in Chrome and Safari, but sadly not with Arc. Do you know if there is a way of fixing that?

Hi @nick , any help would be greatly appreciated!

Hi, unfortunately PopClip does not support extracting the URL from Arc browser yet.

Hi and thanks for sharing @nick and @EdM .

I’ve made an Obsidian plugin that works with the extension snipept you shared.

Here is the Github repository of Obsidian Popclip plugin

1 Like

Thanks for this @webmeister . I’ve installed the Obsidian plugin, and also add your version of this snippet into PopClip.

I have a few questions for you, if you don’t mind:

  1. What’s the purpose of the Obsidian plugin? Does it mean Advanced URI plugin is no longer a requirement?
  2. You have added a Location to your popclip snippet. What is the purpose of that? I assumed, perhaps wrongly, that it was to enable adding the cilpped text to any folder in the Vault, rather than it being added by default to the daily folder. But that doesn’t appear to be the case.

I came here for two reasons.

The first is to say: thank you for this miracle of an app. Among the best purchases I have made haha. Really exceptional.

The second is to add my +1 to “send to Obsidian.” I followed the instructions on @webmeister’s repo for the plugin but it does not appear to be working for me.

1 Like