Idea: Restore Clipboard

Depending on the intention of the extension, sometimes I don’t want PopClip to modify the text on my clipboard. I understand that changing the way the app works entirely would be a lot of work, but I wonder if in the extension we could specify an option to restore the clipboard to the original after pasting?

1 Like

Thanks for this — that’s definitely a possibility. In fact at various times PopClip has handled this in different ways. At one time it restored by default, but didn’t fall back to Copy. Then when I added behaviour to Copy as fallback for non-editable text, I made it not restore by default because it seemed more consistent with that. Then later I added a per-extension restore option, then I took away the option again because it seemed to add arbitrary inconsistency. If that follows :upside_down_face:

But I’m thinking this was probably too far because you are not the first to ask for it again recently. I’m erring towards having the option in the extension author’s hands being best. I’ll give it some thought.

1 Like

I completely understand that! The problem I have with some things at work is I have an ID or similar on my clipboard and I need to format it several ways in fairly quick sequence (well, I can do it slower), and when I paste for the second time, I get what I just generated :smiley:

I’m not sure the best way to handle arbitrary inconsistency - perhaps you could just have an app preference? And/or let users set a preference per extension? At least then they are in control of things :smiley:

1 Like

Yes, that would probably be the best :slight_smile:

1 Like

On awaking this morning I realised that is is currently possible.

Whilst there’s currently no way to restore it using after: paste-result, it can be done with the new JavaScript extension type.

Here is an example (hope you don’t mind me using your Simil-ify as my example, @RosemaryOrchard - or at least something like it!):

# popclip JavaScript paste with restore example
name: AmazonSmile
icon: A:)
requirements: [url]
javascript: |
  let url = popclip.input.data.urls[0] // url is a string
  url = url.replace('www.amazon', 'smile.amazon')
  url = url.split('?')[0] // remove query nonsense
  popclip.pasteText(url, { restore: true })

(The above block is an extension snippet - select it to install the extension with PopClip)

I wouldn’t expect anyone to know this pasteText() method - is deep in the documentation I only published yesterday :books:!

1 Like

Amazing!! I needed an excuse to rewrite some extensions in JS, and now I get to do so :nerd_face:

1 Like

This is now implemented — there’s once more a restore pasteboard field (see action properties docs) in PopClip 2022.5.

1 Like