能否使用Snippets为我编写一个适用于popclip.app的extensions?功能如下:当我用鼠标选中一段文本的时候,如果这段文本的长度为10,且都是数字。例如:1744792028,就转换为东八区的时间:2025-04-16 16:27:08,并在浮窗显示这个时间(不替换原始文本)。下面是参考文档:
Snippets
A snippet is the simplest kind of PopClip extension, because it is just plain text. PopClip can load a snippet directly from a text selection, without the need for separate files or folders.
Example
It is easiest to start with an example:
yaml
#popclip
name: Urban Dictionary
icon: UD
url: https://www.urbandictionary.com/define.php?term=***
When you select whole block of text above, PopClip will detect the snippet and offer an “Install Extension” action.
Format
A snippet always begins with #popclip
(or # popclip
) and can be up to 5000 characters long. It is parsed as YAML 1.2. The body of the snippet defines the extension’s config dictionary.
Commments in snippets
Note that #
begins a YAML comment. Thus the entire snippet including the #popclip
line parses as valid YAML.
Creating snippets
PopClip will display any errors it encounters while trying to load the snippet in the PopClip bar itself.
In the absence of an identifier
field, the name
acts as the identifier for the extension. Installing a snippet with the same name as an existing snippet will replace it.
A snippet can do everything that a package extension can do. The only limitation is that it can’t refer to any external files.
More examples
A Shortcuts example:
yaml
# popclip shortcuts example
name: Run My Shortcut
icon: symbol:moon.stars # Apple SF Symbols
macos version: '12.0' # shortcuts only work on Monterey and above!
shortcut name: My Shortcut Name
A Service example (this time using flow-style YAML markup, with braces):
yaml
#popclip service example
{ name: Stickies, service name: Make Sticky }
A Key Press example:
yaml
#popclip key press example
name: Key Press Example
key combo: command option J
An shell script example:
yaml
#popclip shellscript example
name: Say
interpreter: zsh
shell script: say -v Daniel $POPCLIP_TEXT
A JavaScript example, including multiple actions:yamljson
yaml
#popclip js + multi action example
name: Markdown Formatting
requirements: [text, paste]
actions:
- title: Markdown Bold # note: actions have a `title`, not a `name`
icon: circle filled B
javascript: popclip.pasteText('**' + popclip.input.text + '**')
- title: Markdown Italic
icon: circle filled I
javascript: popclip.pasteText('*' + popclip.input.text + '*')
#1 rule of YAML: Do not indent with tabs!
When writing snippets in YAML with indented parts, as in the example above, do not use tabs for indenting. YAML does not allow it — use spaces instead.