ksuzushima / uni-clipboard

Universal Clipboard API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Uni Clipboard API

Universal Clipboard API service on Cloudflare Workers.

  • Create own clipboard API service
  • Simple GET/POST API
  • Delete data automatically. Default: 60 seconds

Setup

  1. Fork this repository
git clone https://github.com/azu/uni-clipboard
cd uni-clipboard
  1. Create UNI_CLIPBOARD KV namespaces
wrangler kv:namespace create "UNI_CLIPBOARD" --preview
wrangler kv:namespace create "UNI_CLIPBOARD"
  1. Put UNI_TOKEN for security
$ wrangler secret put UNI_TOKEN
XXX

Usage

Get clipboard

await fetch('https://uni-clipboard.{your}.workers.dev/?token=XXX')

Update clipboard

await fetch("https://uni-clipboard.{your}.workers.dev/?token=XXX", { method: "post", body: "New Content"})

Client

You can use Shortcuts and Alfred as client.

For example, Alfred allow you to use ShellScript.

Push your clipboard to uni-clipboard.

c=$(pbpaste | /usr/local/bin/jq -aRs .)
curl -X POST -H "Content-Type: application/json" -d "{\"value\":${c}}" \
"https://uni-clipboard.{you}.workers.dev/?token={token}"

Read clipboard text from uni-clipboard

curl "https://uni-clipboard.{you}.workers.dev/?token={token}" | pbocpy

Development

wranger dev

Deploy

wranger publish

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

License

MIT

About

Universal Clipboard API

License:MIT License


Languages

Language:JavaScript 97.3%Language:Shell 2.7%